cluster-assignment-extraction-and-labeling
Summary
Extract and record cluster assignments for individual samples after performing hierarchical clustering analysis (HCA) on metabolomic feature matrices. This skill captures the step of translating a dendrogram into discrete, labeled cluster memberships for downstream analysis.
When to use
After executing hierarchical clustering via Sample_Separation() with method='HCA' on a feature-by-sample metabolomic matrix, when you need to assign each sample to a discrete cluster group (typically k=2 clusters) for use in marker identification, batch effect assessment, or sample phenotyping workflows.
When NOT to use
- Input finalData is already a pre-computed distance or similarity matrix rather than a feature table; use distance-based clustering directly instead.
- Sample groups are not expected to separate into discrete clusters (e.g., continuous phenotypic gradients); consider ordination methods like PCA or OPLS-DA.
- You require soft cluster assignments (probability/membership scores) rather than hard labels; HCA produces hard assignments only.
Inputs
- finalData: numeric matrix of metabolomic features (rows) × samples (columns)
- finalLabel: vector of sample group labels or phenotype identifiers (length = number of samples)
- clusters: integer specifying number of clusters (e.g., k=2)
- method: string set to 'HCA' for hierarchical clustering analysis
Outputs
- cluster_assignments: vector of cluster IDs, one per sample, indexed to finalLabel
- hierarchical_dendrogram: visualization showing hierarchical tree structure and cluster boundaries
- cluster_membership_table: data frame mapping sample names/IDs to assigned cluster and original group label
How to apply
Call Sample_Separation(finalData, finalLabel, clusters=k, method='HCA') where finalData is a feature-by-sample matrix and finalLabel contains sample group identifiers. The function performs hierarchical clustering and returns cluster assignments that can be extracted and cross-referenced with original sample labels and metadata. Record the cluster ID for each sample and verify that cluster boundaries align with biological or experimental groupings visible in the dendrogram. Use the extracted assignments as categorical labels for subsequent statistical tests or marker discovery steps.
Related tools
- LargeMetabo (R package providing Sample_Separation() function that performs HCA clustering and enables cluster assignment extraction on metabolomic feature matrices) — https://github.com/LargeMetabo/LargeMetabo
- factoextra (R package used for extracting and visualizing hierarchical clustering dendrograms and cluster membership assignments)
- ggplot2 (R package for generating customized dendrograms and cluster assignment visualizations)
Examples
Sample_Separation(finalData, finalLabel, clusters = 2, method = "HCA")
Evaluation signals
- Each sample in finalLabel receives exactly one cluster assignment (no NAs, no duplicates, cardinality = nrow(finalData)).
- Cluster assignments correspond to cut heights in the dendrogram; verify by visual inspection that samples in the same cluster share high similarity in the tree.
- Cluster distribution aligns with expected biological groupings or phenotypic categories; use contingency tables to cross-tabulate assigned clusters vs. original finalLabel.
- Dendrogram visualization renders without errors and shows clear cluster boundaries at the specified k cutoff.
- Cluster assignments are reproducible: re-running Sample_Separation() with identical inputs yields identical cluster IDs.
Limitations
- HCA is sensitive to outliers and single-linkage chaining; verify dendrogram structure before accepting assignments.
- k=2 is a rigid choice; the optimal number of clusters is not determined by this skill and must be selected a priori or validated separately (e.g., via dendrogram inspection or silhouette analysis).
- Hierarchical clustering assumes a tree-like structure; if sample relationships are non-hierarchical or modular, recovered clusters may not reflect true biological groupings.
- The method does not account for missing values in finalData; feature matrix must be complete or pre-imputed.
Evidence
- [other] The Sample_Separation() function accepts finalData (feature matrix), finalLabel (sample group labels), clusters parameter (set to 2), and method parameter (set to 'HCA' for hierarchical clustering analysis) to produce a visualization of hierarchical clustering that separates and groups samples according to their metabolomic profiles.: "The Sample_Separation() function accepts finalData (feature matrix), finalLabel (sample group labels), clusters parameter (set to 2), and method parameter (set to 'HCA' for hierarchical clustering"
- [readme] There are four sample separation methods for visualizing the clustering and separation of different samples.: "There are four sample separation methods for visualizing the clustering and separation of different samples"
- [other] Extract and record cluster assignments for each sample. Generate hierarchical dendrogram visualization showing sample groupings and cluster boundaries.: "Extract and record cluster assignments for each sample. Generate hierarchical dendrogram visualization showing sample groupings and cluster boundaries"
- [readme] Sample_Separation(finalData, finalLabel, clusters = 2, method = "HCA"): "Sample_Separation(finalData, finalLabel, clusters = 2, method = "HCA")"
1---2name: cluster-assignment-extraction-and-labeling3description: Use when after executing hierarchical clustering via Sample_Separation() with method='HCA' on a feature-by-sample metabolomic matrix, when you need to assign each sample to a discrete cluster group (typically k=2 clusters) for use in marker identification, batch effect assessment, or sample.4license: CC-BY-4.05---67# cluster-assignment-extraction-and-labeling89## Summary1011Extract and record cluster assignments for individual samples after performing hierarchical clustering analysis (HCA) on metabolomic feature matrices. This skill captures the step of translating a dendrogram into discrete, labeled cluster memberships for downstream analysis.1213## When to use1415After executing hierarchical clustering via Sample_Separation() with method='HCA' on a feature-by-sample metabolomic matrix, when you need to assign each sample to a discrete cluster group (typically k=2 clusters) for use in marker identification, batch effect assessment, or sample phenotyping workflows.1617## When NOT to use1819- Input finalData is already a pre-computed distance or similarity matrix rather than a feature table; use distance-based clustering directly instead.20- Sample groups are not expected to separate into discrete clusters (e.g., continuous phenotypic gradients); consider ordination methods like PCA or OPLS-DA.21- You require soft cluster assignments (probability/membership scores) rather than hard labels; HCA produces hard assignments only.2223## Inputs2425- finalData: numeric matrix of metabolomic features (rows) × samples (columns)26- finalLabel: vector of sample group labels or phenotype identifiers (length = number of samples)27- clusters: integer specifying number of clusters (e.g., k=2)28- method: string set to 'HCA' for hierarchical clustering analysis2930## Outputs3132- cluster_assignments: vector of cluster IDs, one per sample, indexed to finalLabel33- hierarchical_dendrogram: visualization showing hierarchical tree structure and cluster boundaries34- cluster_membership_table: data frame mapping sample names/IDs to assigned cluster and original group label3536## How to apply3738Call Sample_Separation(finalData, finalLabel, clusters=k, method='HCA') where finalData is a feature-by-sample matrix and finalLabel contains sample group identifiers. The function performs hierarchical clustering and returns cluster assignments that can be extracted and cross-referenced with original sample labels and metadata. Record the cluster ID for each sample and verify that cluster boundaries align with biological or experimental groupings visible in the dendrogram. Use the extracted assignments as categorical labels for subsequent statistical tests or marker discovery steps.3940## Related tools4142- **LargeMetabo** (R package providing Sample_Separation() function that performs HCA clustering and enables cluster assignment extraction on metabolomic feature matrices) — https://github.com/LargeMetabo/LargeMetabo43- **factoextra** (R package used for extracting and visualizing hierarchical clustering dendrograms and cluster membership assignments)44- **ggplot2** (R package for generating customized dendrograms and cluster assignment visualizations)4546## Examples4748```49Sample_Separation(finalData, finalLabel, clusters = 2, method = "HCA")50```5152## Evaluation signals5354- Each sample in finalLabel receives exactly one cluster assignment (no NAs, no duplicates, cardinality = nrow(finalData)).55- Cluster assignments correspond to cut heights in the dendrogram; verify by visual inspection that samples in the same cluster share high similarity in the tree.56- Cluster distribution aligns with expected biological groupings or phenotypic categories; use contingency tables to cross-tabulate assigned clusters vs. original finalLabel.57- Dendrogram visualization renders without errors and shows clear cluster boundaries at the specified k cutoff.58- Cluster assignments are reproducible: re-running Sample_Separation() with identical inputs yields identical cluster IDs.5960## Limitations6162- HCA is sensitive to outliers and single-linkage chaining; verify dendrogram structure before accepting assignments.63- k=2 is a rigid choice; the optimal number of clusters is not determined by this skill and must be selected a priori or validated separately (e.g., via dendrogram inspection or silhouette analysis).64- Hierarchical clustering assumes a tree-like structure; if sample relationships are non-hierarchical or modular, recovered clusters may not reflect true biological groupings.65- The method does not account for missing values in finalData; feature matrix must be complete or pre-imputed.6667## Evidence6869- [other] The Sample_Separation() function accepts finalData (feature matrix), finalLabel (sample group labels), clusters parameter (set to 2), and method parameter (set to 'HCA' for hierarchical clustering analysis) to produce a visualization of hierarchical clustering that separates and groups samples according to their metabolomic profiles.: "The Sample_Separation() function accepts finalData (feature matrix), finalLabel (sample group labels), clusters parameter (set to 2), and method parameter (set to 'HCA' for hierarchical clustering"70- [readme] There are four sample separation methods for visualizing the clustering and separation of different samples.: "There are four sample separation methods for visualizing the clustering and separation of different samples"71- [other] Extract and record cluster assignments for each sample. Generate hierarchical dendrogram visualization showing sample groupings and cluster boundaries.: "Extract and record cluster assignments for each sample. Generate hierarchical dendrogram visualization showing sample groupings and cluster boundaries"72- [readme] Sample_Separation(finalData, finalLabel, clusters = 2, method = "HCA"): "Sample_Separation(finalData, finalLabel, clusters = 2, method = "HCA")"