sparrow.tb.weighted_channel_expression

sparrow.tb.weighted_channel_expression#

sparrow.tb.weighted_channel_expression(sdata, table_layer_cell_clustering, table_layer_pixel_cluster_intensity, output_layer, clustering_key=ClusteringKey._METACLUSTERING_KEY, overwrite=False)#

Calculation of weighted channel expression in the context of cell clustering.

Calculates the average channel expression (via table_layer_pixel_cluster_intensity) for each cell weighted by pixel SOM/META cluster count (via table_layer_cell_clustering). 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_layer].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_layer].uns.

This function should be run after running sp.tb.flowsom and sp.tb.cluster_intensity.

Parameters:
  • sdata (SpatialData) – The input SpatialData object containing the necessary data tables.

  • table_layer_cell_clustering (str) – The name of the table layer in sdata where FlowSOM cell clustering results are stored (obtained via ‘sp.tb.flowsom’). This layer 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 sp.tb.flowsom.

  • table_layer_pixel_cluster_intensity (str) – The name of the table layer in sdata containing pixel cluster intensity values as obtained by running sp.tb.cluster_intensity. These intensities are used to calculate the weighted expression of each channel for the cell clusters.

  • output_layer (str) – The name of the output table layer 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 (sp.tb.flowsom).

  • overwrite (bool (default: False)) – If True, overwrites any existing data in the output_layer 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_layer.

See also

sparrow.tb.flowsom

flowsom cell clustering

sparrow.tb.cluster_intensity

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