hierarchical-clustering-euclidean-complete-linkage
Summary
Hierarchical clustering using Euclidean distance and complete linkage to organize rows and columns of a normalized microbe-metabolite attribution score matrix into dendrograms, enabling identification of natural groupings before consensus-based optimal cluster selection.
When to use
Apply this skill when you have a normalized microbe-metabolite feature attribution score matrix (rows = microbes, columns = metabolites) and need to explore hierarchical structure and visually assess similarity patterns before determining the optimal number of clusters via consensus clustering. Use it specifically after normalizing attribution scores by dividing by background distribution threshold and clipping to [-1, 1].
When NOT to use
- Input attribution matrix is already manually clustered or pre-assigned to fixed k clusters; hierarchical clustering should precede consensus methods, not follow them.
- Score matrix contains missing values (NaN) or infinite values without prior imputation or removal.
- You have only a single microbe or metabolite feature; hierarchical clustering requires at least 2 observations per dimension to form meaningful dendrograms.
Inputs
- Feature attribution score matrix S_i (unnormalized, dimensions: microbes × metabolites)
- Significant threshold score from background distribution (scalar, 97.5th percentile of null distribution)
- Background distribution of feature attribution scores (for threshold determination)
Outputs
- Dendrograms for microbes (tree structure showing hierarchical relationships)
- Dendrograms for metabolites (tree structure showing hierarchical relationships)
- Clustered heatmap visualization (with row and column dendrograms)
- Normalized and clipped attribution score matrix S* (values in [-1, 1])
How to apply
Normalize the feature attribution score matrix S_i by dividing each value by the significant threshold score derived from the background distribution and clip all values to the range [-1, 1]. Perform hierarchical clustering independently on microbe rows and metabolite columns using Euclidean distance as the distance metric and complete linkage as the agglomeration criterion. This produces dendrograms that visually organize microbes and metabolites by their similarity in attribution patterns. Use Seaborn's clustermap function to generate both dendrograms and a clustered heatmap simultaneously. The resulting dendrograms serve as input for subsequent consensus clustering analysis to determine optimal cluster numbers k₁* and k₂*.
Related tools
- Seaborn clustermap (Generates hierarchical clustering dendrograms and heatmap for visualization of microbe and metabolite relationships)
- scipy.cluster.hierarchy (Computes hierarchical clustering using Euclidean distance and complete linkage agglomeration)
- scikit-learn linkage functions (Provides alternative hierarchical clustering implementation with support for Euclidean distance and complete linkage)
- MiMeNet (Full pipeline that incorporates hierarchical clustering as a preparatory step before consensus clustering) — https://github.com/YDaiLab/MiMeNet
Examples
import seaborn as sns; import pandas as pd; S_norm = pd.DataFrame(S_i / threshold).clip(-1, 1); g = sns.clustermap(S_norm, metric='euclidean', method='complete', figsize=(10, 8))
Evaluation signals
- Dendrograms show logical hierarchical structure with interpretable groupings; microbes/metabolites with similar attribution patterns cluster together at lower merge heights.
- Normalized score matrix S* has all values strictly within [-1, 1]; spot-check confirms clipping was applied correctly.
- Seaborn clustermap visualization is generated without errors and displays both row (microbe) and column (metabolite) dendrograms with corresponding heatmap.
- Dendrogram structure is stable and reproducible across multiple runs with identical input data and random seed.
- Subsequent consensus clustering (k-means on dendrograms for k ∈ [2, 20]) produces meaningful variation in connectivity matrices that can be used to identify optimal cluster numbers.
Limitations
- Complete linkage is sensitive to outliers; a single microbe or metabolite with extreme attribution scores can inflate distances between clusters.
- Euclidean distance in high-dimensional spaces (many features) can suffer from the 'curse of dimensionality'; results may be less interpretable if the attribution matrix is very wide.
- Hierarchical clustering does not explicitly optimize for any cluster quality metric; the resulting dendrograms are exploratory and require downstream consensus clustering to identify statistically robust cluster numbers.
- Method assumes normalized, clipped values; if input matrix contains features outside [-1, 1] or has unnormalized scales, clustering distances become incomparable across microbe–metabolite pairs.
- No internal stopping criterion; dendrograms extend to n clusters (where n = number of microbes or metabolites), requiring external methods (e.g. elbow method, silhouette analysis) to select interpretable cluster numbers.
Evidence
- [methods] Perform hierarchical clustering separately on microbe rows and metabolite columns using Euclidean distance and complete linkage with Seaborn's clustermap.: "Perform hierarchical clustering separately on microbe rows and metabolite columns using Euclidean distance and complete linkage with Seaborn's clustermap"
- [methods] Normalize the feature attribution score matrix S_i by dividing by the significant threshold score from background distribution and clip values to range [-1, 1].: "Normalize the feature attribution score matrix S_i by dividing by the significant threshold score from background distribution and clip values to range [-1, 1]"
- [methods] For each fixed cluster number k ranging from 2 to 20, generate a k-clustering and compute a consensus matrix by averaging connectivity matrices across all 100 trained models.: "For each fixed cluster number k ranging from 2 to 20, generate a k-clustering and compute a consensus matrix"
- [methods] Bicluster the normalized score matrix S* using k₁* and k₂* to assign microbes and metabolites to their final module memberships.: "Bicluster the normalized score matrix S* using k₁* and k₂* to assign microbes and metabolites to their final module memberships"
- [results] MiMeNet then trains multiple network models using 10-fold cross-validation. The resulting models are then used to construct a score matrix of microbe-metabolite feature attributions between the microbes and well-predicted metabolites. Then MiMeNet biclusters the score matrix into microbial and metabolomic modules.: "MiMeNet then trains multiple network models using 10-fold cross-validation. The resulting models are then used to construct a score matrix of microbe-metabolite feature attributions"
- [discussion] the predictive model in MiMeNet distinguishes it from MelonnPan [26], which uses a regularized linear regression to model each metabolite separately.: "MiMeNet can group microbes and metabolites with similar interaction patterns and functions to illuminate the underlying structure of the microbe-metabolite interaction network"
1---2name: hierarchical-clustering-euclidean-complete-linkage3description: Use when you have a normalized microbe-metabolite feature attribution score matrix (rows = microbes, columns = metabolites) and need to explore hierarchical structure and visually assess similarity patterns before determining the optimal number of clusters via consensus clustering.4license: CC-BY-4.05---67# hierarchical-clustering-euclidean-complete-linkage89## Summary1011Hierarchical clustering using Euclidean distance and complete linkage to organize rows and columns of a normalized microbe-metabolite attribution score matrix into dendrograms, enabling identification of natural groupings before consensus-based optimal cluster selection.1213## When to use1415Apply this skill when you have a normalized microbe-metabolite feature attribution score matrix (rows = microbes, columns = metabolites) and need to explore hierarchical structure and visually assess similarity patterns before determining the optimal number of clusters via consensus clustering. Use it specifically after normalizing attribution scores by dividing by background distribution threshold and clipping to [-1, 1].1617## When NOT to use1819- Input attribution matrix is already manually clustered or pre-assigned to fixed k clusters; hierarchical clustering should precede consensus methods, not follow them.20- Score matrix contains missing values (NaN) or infinite values without prior imputation or removal.21- You have only a single microbe or metabolite feature; hierarchical clustering requires at least 2 observations per dimension to form meaningful dendrograms.2223## Inputs2425- Feature attribution score matrix S_i (unnormalized, dimensions: microbes × metabolites)26- Significant threshold score from background distribution (scalar, 97.5th percentile of null distribution)27- Background distribution of feature attribution scores (for threshold determination)2829## Outputs3031- Dendrograms for microbes (tree structure showing hierarchical relationships)32- Dendrograms for metabolites (tree structure showing hierarchical relationships)33- Clustered heatmap visualization (with row and column dendrograms)34- Normalized and clipped attribution score matrix S* (values in [-1, 1])3536## How to apply3738Normalize the feature attribution score matrix S_i by dividing each value by the significant threshold score derived from the background distribution and clip all values to the range [-1, 1]. Perform hierarchical clustering independently on microbe rows and metabolite columns using Euclidean distance as the distance metric and complete linkage as the agglomeration criterion. This produces dendrograms that visually organize microbes and metabolites by their similarity in attribution patterns. Use Seaborn's clustermap function to generate both dendrograms and a clustered heatmap simultaneously. The resulting dendrograms serve as input for subsequent consensus clustering analysis to determine optimal cluster numbers k₁* and k₂*.3940## Related tools4142- **Seaborn clustermap** (Generates hierarchical clustering dendrograms and heatmap for visualization of microbe and metabolite relationships)43- **scipy.cluster.hierarchy** (Computes hierarchical clustering using Euclidean distance and complete linkage agglomeration)44- **scikit-learn linkage functions** (Provides alternative hierarchical clustering implementation with support for Euclidean distance and complete linkage)45- **MiMeNet** (Full pipeline that incorporates hierarchical clustering as a preparatory step before consensus clustering) — https://github.com/YDaiLab/MiMeNet4647## Examples4849```50import seaborn as sns; import pandas as pd; S_norm = pd.DataFrame(S_i / threshold).clip(-1, 1); g = sns.clustermap(S_norm, metric='euclidean', method='complete', figsize=(10, 8))51```5253## Evaluation signals5455- Dendrograms show logical hierarchical structure with interpretable groupings; microbes/metabolites with similar attribution patterns cluster together at lower merge heights.56- Normalized score matrix S* has all values strictly within [-1, 1]; spot-check confirms clipping was applied correctly.57- Seaborn clustermap visualization is generated without errors and displays both row (microbe) and column (metabolite) dendrograms with corresponding heatmap.58- Dendrogram structure is stable and reproducible across multiple runs with identical input data and random seed.59- Subsequent consensus clustering (k-means on dendrograms for k ∈ [2, 20]) produces meaningful variation in connectivity matrices that can be used to identify optimal cluster numbers.6061## Limitations6263- Complete linkage is sensitive to outliers; a single microbe or metabolite with extreme attribution scores can inflate distances between clusters.64- Euclidean distance in high-dimensional spaces (many features) can suffer from the 'curse of dimensionality'; results may be less interpretable if the attribution matrix is very wide.65- Hierarchical clustering does not explicitly optimize for any cluster quality metric; the resulting dendrograms are exploratory and require downstream consensus clustering to identify statistically robust cluster numbers.66- Method assumes normalized, clipped values; if input matrix contains features outside [-1, 1] or has unnormalized scales, clustering distances become incomparable across microbe–metabolite pairs.67- No internal stopping criterion; dendrograms extend to n clusters (where n = number of microbes or metabolites), requiring external methods (e.g. elbow method, silhouette analysis) to select interpretable cluster numbers.6869## Evidence7071- [methods] Perform hierarchical clustering separately on microbe rows and metabolite columns using Euclidean distance and complete linkage with Seaborn's clustermap.: "Perform hierarchical clustering separately on microbe rows and metabolite columns using Euclidean distance and complete linkage with Seaborn's clustermap"72- [methods] Normalize the feature attribution score matrix S_i by dividing by the significant threshold score from background distribution and clip values to range [-1, 1].: "Normalize the feature attribution score matrix S_i by dividing by the significant threshold score from background distribution and clip values to range [-1, 1]"73- [methods] For each fixed cluster number k ranging from 2 to 20, generate a k-clustering and compute a consensus matrix by averaging connectivity matrices across all 100 trained models.: "For each fixed cluster number k ranging from 2 to 20, generate a k-clustering and compute a consensus matrix"74- [methods] Bicluster the normalized score matrix S* using k₁* and k₂* to assign microbes and metabolites to their final module memberships.: "Bicluster the normalized score matrix S* using k₁* and k₂* to assign microbes and metabolites to their final module memberships"75- [results] MiMeNet then trains multiple network models using 10-fold cross-validation. The resulting models are then used to construct a score matrix of microbe-metabolite feature attributions between the microbes and well-predicted metabolites. Then MiMeNet biclusters the score matrix into microbial and metabolomic modules.: "MiMeNet then trains multiple network models using 10-fold cross-validation. The resulting models are then used to construct a score matrix of microbe-metabolite feature attributions"76- [discussion] the predictive model in MiMeNet distinguishes it from MelonnPan [26], which uses a regularized linear regression to model each metabolite separately.: "MiMeNet can group microbes and metabolites with similar interaction patterns and functions to illuminate the underlying structure of the microbe-metabolite interaction network"