sparrow.tb.correct_marker_genes

sparrow.tb.correct_marker_genes#

sparrow.tb.correct_marker_genes(sdata, labels_layer, table_layer, output_layer, celltype_correction_dict, overwrite=False)#

Correct celltype expression in sdata.tables[table_layer] using celltype_correction_dict.

Corrects celltypes that are higher expessed by dividing them by a value if they exceed a certain threshold. The celltype_correction_dict has as keys the celltypes that should be corrected and as values the threshold and the divider.

Parameters:
  • sdata (SpatialData) – The SpatialData object.

  • labels_layer (list[str]) – The labels layer(s) of sdata used to select the cells via the _REGION_KEY in sdata.tables[table_layer].obs. Note that if output_layer is equal to table_layer and overwrite is True, cells in sdata.tables[table_layer] linked to other labels_layer (via the _REGION_KEY), will be removed from sdata.tables[table_layer] (also from the backing zarr store if it is backed).

  • table_layer (str) – The table layer in sdata.

  • output_layer (str) – The output table layer in sdata.

  • celltype_correction_dict (Dict[str, Tuple[float, float]]) – The celltype_correction_dict has as keys the celltypes that should be corrected and as values the threshold and the divider.

Return type:

SpatialData

Returns:

: The updated SpatialData object.