bioalpha.singlecell.preprocessing.combine_keys
- bioalpha.singlecell.preprocessing.combine_keys(adata: AnnData, keys: Sequence[str], key_added: str | None = None, combine_fn: Callable[[Sequence[str]], str] | None = None, inplace=True, copy=False) Series | AnnData | None
Combine keys in
adata.obs
. This implementation usingpandas.DataFrame.apply
.- Parameters:
adata (
AnnData
) – The annotated data matrix of shapen_obs
xn_vars
. Rows correspond to cells and columns to genes.keys (Sequence[
str
]) – Keys to be combined. All ofkeys
must be inadata.obs
.key_added (Optional[
str
], default =None
) – Key to be saved ifinplace = True
. IfNone
, automatically set to"combine(', '.join(keys))"
combine_fn (Optional[(Sequence[
str
]) ->str
], default =None
.) – Combine function. default is"-".join
.inplace (
bool
, default =True
) – Whether to updateadata
or return series of combined keys.copy (
bool
, default =False
) – Whether to modify copied input object. Not compatible withinplace = False
.
- Returns:
combined_keys (
Series
) – Ifinplace = False
adata (
AnnData
) – Ifcopy=True
it returns or else adds fields toadata
:.obsm[
key_added
] The combined keys.