.hclustv_profiles
- proteopy.tl.hclustv_profiles(adata, cluster_key='auto', layer=None, group_by=None, method='median', zero_to_na=False, fill_na=None, skip_na=True, inplace=True, key_added=None, verbose=True)[source]
Compute cluster profiles from cluster annotations.
Summarizes variables within each cluster using mean or median to create cluster profile intensities across all observations.
- Parameters:
adata (AnnData) –
AnnDatawith cluster annotations in.var(fromhclustv_cluster_ann()).cluster_key (str) – Column in
adata.varcontaining cluster assignments. When'auto', auto-detects from available'hclustv_cluster;...'columns. When multiple columns exist, must be specified explicitly.layer (str | None) – Layer to use for computing profiles. When
None, usesadata.X.group_by (str | None) – Column in
adata.obsto group observations by before computing cluster profiles. When specified, observations are first summarized by this column usingmethod, then cluster profiles are computed on the grouped data.method (str) – Summarization method for computing cluster profiles. One of
"mean"or"median". Also used for grouping observations whengroup_byis specified.zero_to_na (bool) – If
True, convert zeros in the data matrix tonp.nanbefore any computation.fill_na (float | int | None) – If specified, replace
np.nanvalues with this constant before computing profiles. Applied afterzero_to_na.skip_na (bool) – If
True, excludenp.nanvalues when computing summaries. IfFalse, returnnp.nanif any value in the group isnp.nan.inplace (bool) – If
True, store results inadata.unsand returnNone. IfFalse, return a modified copy ofadata.key_added (str | None) – Custom key for storing results in
adata.uns. WhenNone, uses the default format'hclustv_profiles;<group_by>;<var_hash>;<layer>'derived from the cluster key components.verbose (bool) – Print storage location key after computation.
- Returns:
If
inplace=True, returnsNone. Ifinplace=False, returns a copy ofadatawith cluster profiles stored in.uns.- Return type:
AnnData | None
- Raises:
ValueError – If no cluster annotations are found in
adata.var. If multiple cluster columns exist andcluster_keyis not specified. Ifmethodis not"mean"or"median". If auto-generated storage key cannot be derived.KeyError – If specified
cluster_keyis not found inadata.var. If specifiedlayeris not found inadata.layers. If specifiedgroup_bycolumn is not found inadata.obs.
Notes
The cluster profiles DataFrame is stored at
adata.uns['hclustv_profiles;<group_by>;<var_hash>;<layer>'].Examples
>>> import proteopy as pr >>> adata = pr.datasets.karayel_2020() >>> pr.tl.hclustv_tree(adata, group_by="condition") >>> pr.tl.hclustv_cluster_ann(adata, 5) >>> pr.tl.hclustv_profiles(adata)