harpy.tb.cluster_cleanliness#
- harpy.tb.cluster_cleanliness(sdata, labels_name, table_name, output_table_name, celltypes, celltype_indexes=None, colors=None, celltype_column='annotation', unknown_celltype_key='unknown_celltype', cleanliness_key='Cleanliness', overwrite=False)#
Re-calculates annotations, potentially following corrections to the list of celltypes, or after a manual update of the assigned scores per cell type via e.g.
correct_marker_genes.Celltypes can also be grouped together via the celltype_indexes parameter. Returns a
SpatialDataobject alongside a dictionary mapping cell types to colors.Deprecated since version 0.3.0:
harpy.tb.cluster_cleanlinessis deprecated and may be removed in a future release.- Parameters:
sdata (
SpatialData) – Data containing spatial information.labels_name (
list[str]) – The labels element(s) ofsdataused to select the cells via the region key insdata.tables[table_name].obs. Note that ifoutput_table_nameis equal totable_nameand overwrite is True, cells insdata.tables[table_name]linked to otherlabels_name(via the region key), will be removed fromsdata.tables[table_name]. If a list of labels elements is provided, they will therefore be scored together (e.g. multiple samples).table_name (
str) – The table element insdataon which to perform cleaning on.output_table_name (
str) – The output table element insdatato which table element with results of cleaned annotations will be written.celltypes (
list[str]) – List of celltypes that you want to use for annotation, can be a subset of what is available in the.obsattribute of the corresponding table.celltype_indexes (
dict[str,int] |None(default:None)) – Dictionary with cell type as keys and indexes as values. Cell types with provided indexes will be grouped together under new cell type provided as key. E.g.: celltype_indexes = {“fibroblast”: [4,5,23,25], “stellate”: [28,29,30]} -> celltypes at index 4,5,23 and 25 in provided list of celltypes (after an alphabetic sort) will be grouped together as “fibroblast”.colors (
list[str] |None(default:None)) – List of colors to be used for visualizing different cell types. If not provided, a default colormap will be generated.celltype_column (
str(default:'annotation')) – The column name in the.obsattribute of theanndata.AnnDatatable where the predicted cell type is stored (obtained throughscore_genes()orscore_genes_iter()).unknown_celltype_key (
str(default:'unknown_celltype')) – The name reserved for cells that could not be assigned a specific cell type.cleanliness_key (
str(default:'Cleanliness')) – The column name in the.obsattribute of theanndata.AnnDatawhere we will store a score for the cleanliness of the predicted cell type.overwrite (
bool(default:False)) – If True, overwrites theoutput_table_nameif it already exists insdata.
- Return type:
tuple[SpatialData,dict|None]- Returns:
: tuple:
Updated
SpatialDataobject after the cleanliness analysis.Dictionary with cell types as keys and their corresponding colors as values.
See also
harpy.tb.score_genesscore genes using
score_genes().