harpy.pl.pixel_clusters_heatmap#
- harpy.pl.pixel_clusters_heatmap(sdata, table_name, metaclusters=True, z_score=True, clip_value=3, ax=None, output=None, instance_key='SOM_cluster_ID', figsize=(20, 20), fig_kwargs=mappingproxy({}), **kwargs)#
Generate and visualize a heatmap of mean channel intensities for clusters or metaclusters.
- Parameters:
sdata (
SpatialData) – The input SpatialData object.table_name (
str) – The table element insdatacontaining cluster intensity for clusters and metaclusters, obtained viaharpy.tb.cluster_intensity().metaclusters (
bool(default:True)) – Whether to display mean channel intensity per metacluster (True) or per cluster (False).z_score (
bool(default:True)) – Whether to z-score the intensity values for normalization. We recommend setting this toTrue.clip_value (
float|None(default:3)) – The value to clip the z-scored data to, for better visualization. IfNone, no clipping is performed. Ignored ifz_scoreisFalse.ax (
Axes(default:None)) – Matplotlib axes object to plot on. If None, a new figure is created.output (
str|Path|None(default:None)) – The path to save the generated heatmap.instance_key (
str(default:'SOM_cluster_ID')) – Instance key. The name of the column inAnnDatatable.obsthat holds the instance ids (SOM cluster IDs).figsize (
tuple[int,int] (default:(20, 20))) – Tuple specifying the size of the figure in inches as(width, height). The width determines the spacing available for cluster IDs, while the height adjusts space for channels. If labels (cluster IDs or channel names) are truncated, increase the respective dimension. Increasewidthif cluster IDs or are not fully visible. Increaseheightif channel names are not fully visible.fig_kwargs (
Mapping[str,Any] (default:mappingproxy({}))) – Additional keyword arguments passed tomatplotlib.pyplot.figure(), such asdpi. Ignored ifaxisNone.**kwargs – Additional keyword arguments passed to
seaborn.heatmap(), such asannot,cmap, orcbar_kws.
- Return type:
- Returns:
: The function generates and displays or saves a heatmap.
Notes
The heatmap shows mean channel intensities for either clusters or metaclusters, optionally normalized using z-scoring. Clusters and metaclusters are ordered based on hierarchical clustering of their channel intensity profiles.
The function uses cosine similarity to compute the distance matrix for hierarchical clustering of channels.
Example
>>> harpy.tb.pixel_clusters_heatmap( ... sdata, ... table_name="counts_clusters", ... figsize=(30, 20), ... fig_kwargs={"dpi": 100}, ... metaclusters=True, ... z_score=True, ... output="heatmap.png" ... )
See also