harpy.tb.weighted_channel_expression

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 (via cell_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 to sdata.tables[output_table_name].uns.

This function should be run after running harpy.tb.flowsom and harpy.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 in sdata where 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 running harpy.tb.flowsom.

  • table_name_pixel_cluster_intensity (str) – The name of the table element in sdata containing pixel cluster intensity values as obtained by running harpy.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 in sdata where 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 .obs attribute of the AnnData table at slot ‘cell_clustering_table_name’ that holds the size of the instances.

  • raw_counts_key (str (default: 'raw_counts')) – The name of the AnnData layer, at slot ‘cell_clustering_table_name’ of sdata, where the non-preprocessed counts are stored, see flowsom().

  • overwrite (bool (default: False)) – If True, overwrites any existing data in the output_table_name if it already exists.

Return type:

SpatialData

Returns:

: The updated sdata object with the results of the weighted channel expression added to the specified output_table_name.

See also

harpy.tb.cell_clustering_preprocess

prepares data for cell clustering.

harpy.tb.flowsom

flowsom cell clustering

harpy.tb.cluster_intensity

calculates average intensity SOM/meta cluster (pixel clusters).