grassp.pl.protein_clustermap

grassp.pl.protein_clustermap#

protein_clustermap(data, annotation_key, distance_metric='correlation', linkage_method='average', linkage_metric='cosine', palette='Blues_r', show=True)[source]#

Clustered heat-map of pair-wise protein distances.

The function computes pairwise distances between proteins (rows of data.X) using scipy.spatial.distance.pdist() and performs hierarchical clustering on the resulting distance matrix. The heat-map is rendered with seaborn.clustermap(); protein annotations provided via annotation_key are visualised as coloured side bars.

Parameters:
data AnnData

Annotated matrix with proteins as observations (rows) and samples or features as variables (columns).

annotation_key str

Column in data.obs containing categorical annotations (e.g. curated sub-cellular compartments) to colour the rows/columns.

distance_metric Literal['euclidean', 'cosine', 'correlation', 'cityblock', 'jaccard', 'hamming'] (default: 'correlation')

Distance metric used for the pairwise distances passed to scipy.spatial.distance.pdist().

linkage_method Literal['single', 'complete', 'average', 'weighted', 'centroid', 'median', 'ward'] (default: 'average')

Linkage strategy for scipy.cluster.hierarchy.linkage().

linkage_metric Literal['euclidean', 'cosine', 'correlation', 'cityblock', 'jaccard', 'hamming'] (default: 'cosine')

Metric used within the linkage algorithm. Usually identical to distance_metric but can differ.

palette default: 'Blues_r'

Matplotlib/Seaborn palette used for the heat-map color scale.

show bool (default: True)

If True (default) the plot is shown and the function returns None. If False the underlying seaborn.matrix.ClusterGrid object is returned for further customisation.

Return type:

ClusterGrid | None

Returns:

ClusterGrid object if show is False, otherwise None.