.hclustv_silhouette
- proteopy.pl.hclustv_silhouette(adata, linkage_key='auto', values_key='auto', k=15, figsize=(6.0, 4.0), show=True, ax=False, save=None, verbose=True)[source]
Plot silhouette scores for hierarchical clustering.
Evaluates clustering quality by computing the average silhouette score for cluster counts ranging from 2 to
k. Higher silhouette scores indicate better-defined clusters.- Parameters:
adata (AnnData) –
AnnDatawith clustering results fromproteopy.tl.hclustv_tree()stored in.uns.linkage_key (str) – Key in
adata.unsfor the linkage matrix. When'auto', auto-detects keys matchinghclustv_linkage;*.values_key (str) – Key in
adata.unsfor the profile values DataFrame. When'auto', auto-detects keys matchinghclustv_values;*.k (int) – Maximum number of clusters to evaluate. Silhouette scores are computed for cluster counts from 2 to
k(inclusive).figsize (tuple[float, float]) – Matplotlib figure size in inches.
show (bool) – Display the figure.
ax (bool) – Return the Matplotlib Axes object instead of displaying.
save (str | Path | None) – File path for saving the figure.
verbose (bool) – Print status messages including auto-detected keys.
- Returns:
Axes object when
axisTrue; otherwiseNone.- Return type:
Axes | None
- Raises:
ValueError – If no clustering results are found in
adata.uns, if multiple candidates exist and keys are not specified, or ifk < 2.KeyError – If the specified
linkage_keyorvalues_keyis not found.
Examples
>>> import proteopy as pp >>> adata = pp.datasets.example_peptide_data() >>> pr.tl.hclustv_tree(adata, group_by="condition") >>> pr.pl.hclustv_silhouette(adata, k=5)