anndict.wrappers.simplify_obs_column_adata_dict#
- anndict.wrappers.simplify_obs_column_adata_dict(adata, column, new_column_name, simplification_level='')[source]#
Simplifies labels in the specified column of the AnnData object and stores the result in a new column using
map_cell_type_labels_to_simplified_set().- Parameters:
- adata
AnnData The
AnnDataobject containing the data.- column
str The column in
adata.obscontaining the cell type labels to simplify.- new_column_name
str The name of the new column to store the simplified labels.
- simplification_level
str(default:'') A qualitative description of how much you want the labels to be simplified. Could be anything, like
'extremely','barely', or'compartment-level'.
- adata
- Return type:
dict- Returns:
A
dictmapping the original labels to the simplified set of labels.
Notes
Modifies
adataby addingadata.obs[new_column_name](i.e. the new labels) in-place.Example
import anndict as adt print(adata.obs) > cell_subtype > 0 cd8+ t cell > 1 cd4+ t cell > 2 venous endothelial cell > 3 arterial endothelial cell label_mapping = adt.simplify_obs_column(adata, 'cell_subtype', new_column_name = 'cell_type', simplification_level = 'cell type level' ) print(adata.obs) # New column added > cell_subtype cell_type_level > 0 cd8+ t cell t cell > 1 cd4+ t cell t cell > 2 venous endothelial cell endothelial cell > 3 arterial endothelial cell endothelial cell