harpy.tb.cell_clustering_preprocess#
- harpy.tb.cell_clustering_preprocess(sdata, cells_labels_name, cluster_labels_name, output_table_name, q=0.999, chunks=None, region_key='fov_labels', instance_key='cell_ID', cell_index_name='cells', instance_size_key='shapeSize', raw_counts_key='raw_counts', overwrite=False)#
Preprocesses spatial data for cell clustering.
This function prepares a SpatialData object for cell clustering by integrating cell segmentation masks (obtained via e.g.
harpy.im.segment) and SOM pixel/meta cluster (obtained via e.g.harpy.im.flosom). The function calculates the cluster count (clusters provided viacluster_labels_name) for each cell incells_labels_name, normalized by cell size, and optionally by quantile normalization ifqis provided. The results are stored in a specified table element within thesdataobject of shape (#cells, #clusters).- Parameters:
sdata (
SpatialData) – The input SpatialData object containing the spatial proteomics data.cells_labels_name (
str|Iterable[str]) – The labels element(s) insdatathat contain cell segmentation masks. These masks should be previously generated usingharpy.im.segment.cluster_labels_name (
str|Iterable[str]) – The labels element(s) insdatathat contain metacluster or cluster masks. These should be derived fromharpy.im.flowsom.output_table_name (
str) – The name of the table element withinsdatawhere the preprocessed data will be stored.q (
float|None(default:0.999)) – Quantile used for normalization. If specified, each pixel SOM/meta cluster column inoutput_table_nameis normalized by this quantile. Values are multiplied by 100 after normalization.chunks (
str|int|tuple[int,...] |None(default:None)) – Chunk sizes for processing the data. If provided as a tuple, it should detail chunk sizes for each dimension(z),y,x.instance_key (
str(default:'cell_ID')) – Instance key. The name of the column inAnnDatatable.obsthat will hold the instance ids.region_key (
str(default:'fov_labels')) – Region key. The name of the column inAnnDatatable.obsthat will hold the name of the element(s) that are annotated by the resulting table.cell_index_name (
str(default:'cells')) – The name of the index of the resultingAnnDatatable.instance_size_key (
str(default:'shapeSize')) – The key in theAnnDatatable.obsthat will hold the size of the instances (obtained fromcells_labels_name).raw_counts_key (
str(default:'raw_counts')) – Name of theAnnDatalayer where the non-preprocessed counts will be stored.overwrite (
bool(default:False)) – If True, overwrites the existing data in the specifiedoutput_table_nameif it already exists.
- Return type:
- Returns:
: The input
sdatawith a table element added (output_table_name).
See also
harpy.im.flowsomflowsom pixel clustering.
harpy.tb.flowsomflowsom cell clustering.