harpy.tb.cluster_intensity_SOM#
- harpy.tb.cluster_intensity_SOM(sdata, mapping, image_name, labels_name, output_table_name, to_coordinate_system='global', channels=None, chunks=10000, instance_key='SOM_cluster_ID', instance_size_key='SOM_cluster_size', index_name='SOM_cluster_ID_index', overwrite=False)#
Calculates average intensity of each channel in
image_nameper SOM cluster as available in thelabels_name, and saves it as a table element insdataasoutput_table_name. Average intensity per metacluster is calculated using themapping.This function computes average intensity for each SOM cluster identified in the
labels_nameand stores the results in a new table element (output_table_name). Average intensity per metacluster is added tosdata.tables[output_table_name].uns. The intensity calculation can be subset by channels and adjusted for chunk size for efficient processing. SOM clusters can be calculated usingharpy.im.flowsom.- Parameters:
sdata (
SpatialData) – The input SpatialData object.mapping (
Series) – A pandas Series mapping SOM cluster IDs (index) to metacluster IDs (values).image_name (
str|Iterable[str]) – The image element ofsdatafrom which the intensity is calculated.labels_name (
str|Iterable[str]) – The labels element insdatathat contains the SOM cluster IDs. I.e. theoutput_cluster_labels_namelabels element obtained throughharpy.im.flowsom.output_table_name (
str) – The output table element insdatawhere results are stored.to_coordinate_system (
str|Iterable[str] (default:'global')) – The coordinate system that holdsimage_nameandlabels_name. Ifimage_nameandlabels_nameare provided as a list, elements into_coordinate_systemare the respective coordinate systems that holds the elements inimage_nameandlabels_name.channels (
int|str|Iterable[int] |Iterable[str] |None(default:None)) – Specifies the channels to be included in the intensity calculation.chunks (
str|int|tuple[int,...] |None(default:10000)) – Chunk sizes for processing. If provided as atuple, it should contain chunk sizes forc,(z),y,x.instance_key (
str(default:'SOM_cluster_ID')) – Instance key. The name of the column inAnnDatatable.obsthat will hold the instance ids (SOM cluster IDs).instance_size_key (
str(default:'SOM_cluster_size')) – The key in theAnnDatatable.obsthat will hold the size of the instances.index_name (
str(default:'SOM_cluster_ID_index')) – The name of the index of the resultingAnnDatatable.overwrite (default:
False) – If True, overwrites theoutput_table_nameif it already exists insdata.
- Return type:
- Returns:
: The input
sdatawith the new table element added.- Raises:
AssertionError – If number of provided
image_name,labels_nameandto_coordinate_systemis not equal.AssertionError – If some labels in
labels_nameare not found in the provided mapping pandas Series.
See also
harpy.im.flowsomflowsom pixel clustering.