harpy.tb.weighted_channel_expression#
- harpy.tb.weighted_channel_expression(sdata, cell_clustering_table_name, table_name_pixel_cluster_intensity, output_table_name, clustering_key=ClusteringKey._METACLUSTERING_KEY, instance_size_key='shapeSize', raw_counts_key='raw_counts', overwrite=False)#
Calculation of weighted channel expression in the context of cell clustering.
Calculates the average channel expression (via
table_name_pixel_cluster_intensity) for each cell weighted by pixel SOM/META cluster count (viacell_clustering_table_name). Values are normalized by the size of the cell.Average marker expression for each cell weighted by pixel cluster count is added to
sdata.tables[output_table_name].obs. Mean over the obtained cell clusters (both SOM and meta clusters) of the average marker expression for each cell weighted by pixel cluster count is added tosdata.tables[output_table_name].uns.This function should be run after running
harpy.tb.flowsomandharpy.tb.cluster_intensity.- Parameters:
sdata (
SpatialData) – The input SpatialData object containing the necessary data tables.cell_clustering_table_name (
str) – The name of the table element insdatawhere FlowSOM cell clustering results are stored (obtained via ‘harpy.tb.flowsom’). This table element should contain the cell cluster labels derived from the FlowSOM clustering algorithm and the non-normalized pixel cluster counts in.layers[raw_counts_key], as obtained after runningharpy.tb.flowsom.table_name_pixel_cluster_intensity (
str) – The name of the table element insdatacontaining pixel cluster intensity values as obtained by runningharpy.tb.cluster_intensity. These intensities are used to calculate the weighted expression of each channel for the cell clusters.output_table_name (
str) – The name of the output table element insdatawhere the results of the weighted channel expression computation will be stored.clustering_key (
ClusteringKey(default:<ClusteringKey._METACLUSTERING_KEY: 'metaclustering'>)) – Specifies the key that was used for pixel clustering, indicating whether metaclustering or SOM clustering labels were used as input for flowsom cell clustering (harpy.tb.flowsom).instance_size_key (
str(default:'shapeSize')) – The key in the.obsattribute of theAnnDatatable at slot ‘cell_clustering_table_name’ that holds the size of the instances.raw_counts_key (
str(default:'raw_counts')) – The name of theAnnDatalayer, at slot ‘cell_clustering_table_name’ ofsdata, where the non-preprocessed counts are stored, seeflowsom().overwrite (
bool(default:False)) – If True, overwrites any existing data in theoutput_table_nameif it already exists.
- Return type:
- Returns:
: The updated
sdataobject with the results of the weighted channel expression added to the specifiedoutput_table_name.
See also
harpy.tb.cell_clustering_preprocessprepares data for cell clustering.
harpy.tb.flowsomflowsom cell clustering
harpy.tb.cluster_intensitycalculates average intensity SOM/meta cluster (pixel clusters).