came.utils.preprocess.merge_adata_groups

came.utils.preprocess.merge_adata_groups(adata: AnnData, key: str, group_lists: Sequence, new_key=None, rename=False, copy=False)

Merge the given groups into one single group which is named as '_'.join(groups[i]) by default.

Parameters:
  • adata (AnnData) –

  • key – a column name in adata.obs

  • group_lists – a list of lists of group names

  • new_key – a column name to be added to adata.obs

  • rename (bool) – wheter to re-label the groups after merge

  • copy (bool) –

Examples

>>> adata_new = merge_adata_groups(
...     adata, 'batch', group_lists=[['A', 'B'], ['E', 'F']], copy=True)
>>> adata