Regression & multivariate

Hierarchical Cluster Analysis Online: Dendrogram and Clustered Heatmap

Group similar samples, genotypes, sites or respondents without deciding the groups in advance. Paste your data, choose how to standardise, the distance and the linkage method, and get a dendrogram coloured by cluster, the cluster means, silhouette widths to help you choose the number of clusters, and a clustered heatmap ready for your thesis or paper.

✅ No login needed100% freeRuns in your browserYour data stays on your device
Hierarchical Clustering Calculator✅ Free · no login📚 Cite this tool
Your data never leaves your PC. Your data is analysed on your own computer or phone, even when you upload a CSV or Excel file. Nothing is uploaded, stored or seen by Codanics, and no login is needed.

Variables to include

  • PriceFree, no login or sign-up needed
  • Your dataProcessed in your browser, never uploaded
  • Works onPhone, tablet or computer, any modern browser
  • Made byDr. Muhammad Aammar Tufail, Codanics
  • Published17 November 2026
  • Last updated16 November 2026

📚 How to cite this tool

This tool is free. If it helped your thesis, paper, report or assignment, please cite it. It keeps the tools free and helps other students find them.

Citation · APA 7th edition

Tufail, M. A. (2026). Hierarchical clustering calculator: dendrogram and clustered heatmap [Online tool]. Codanics. Retrieved 16 November 2026, from https://codanics.com/tools/hierarchical-clustering-calculator/

In-text citation: (Tufail, 2026) · Narrative: Tufail (2026)

The access date is today’s date, filled in automatically. Author: Muhammad Aammar Tufail. Published 17 November 2026.

🚀 Follow Codanics channel on WhatsApp for more updatesNew free tools, scholarships, PhD positions and research tips, straight to your phone. Free lessons on YouTube too.

How to use the hierarchical clustering calculator

  1. Paste your table or use Paste from Excel / Upload CSV / Excel: one row per object to cluster (genotype, site, patient, country) and one column per variable, with column names in the first row. The example is R’s USArrests data: crime rates and urban population for the 50 US states.
  2. Tick the variables, choose the column with row names, and keep z-scores so that variables measured in large units do not dominate the distances.
  3. Choose the distance (Euclidean is standard) and the linkage method. Ward gives compact, similar-sized clusters; average linkage (UPGMA) is common in ecology and genetics. Leave the number of clusters on automatic to use the best average silhouette, or pick k yourself.
  4. Click Run cluster analysis. Download the dendrogram and heatmap, copy the cluster profile table into Word and download the membership list as CSV.

What is hierarchical cluster analysis?

Hierarchical (agglomerative) clustering starts with every row as its own cluster and repeatedly merges the two closest clusters until only one remains. The sequence of merges is drawn as a dendrogram, a tree in which the height of each join shows how different the merged groups were. Cutting the tree at a chosen height gives the clusters.

It is widely used to group genotypes or accessions by agronomic traits, sites by species composition or soil properties, patients by biomarkers, and genes or samples in expression heatmaps. Unlike k-means, you don’t need to fix the number of clusters before running it.

Which distance and linkage should I use?

LinkageDistance between two clustersTypical result
Ward (ward.D2)Increase in within-cluster sum of squares after mergingCompact, similar-sized clusters; the most popular choice with Euclidean distance
CompleteLargest distance between membersCompact clusters, sensitive to outliers
Average (UPGMA)Mean distance between all pairs of membersA compromise; often the highest cophenetic correlation; standard in numerical taxonomy
McQuitty (WPGMA)Simple average of the two merged clusters’ distancesSimilar to UPGMA, less influenced by large clusters
SingleSmallest distance between membersLong chains; useful for detecting outliers, rarely for final groups

Use Euclidean distance on standardised variables for most continuous data. Manhattan is less affected by single large differences. 1 − Pearson correlation groups rows with similar profiles regardless of their overall level, which is common for gene expression. For species abundance data, Bray–Curtis distance is usually preferred; see the diversity index calculator.

How the results are calculated

z = (x − mean) / SD (standardisation, optional) Euclidean distance d(a, b) = √ Σ (aⱼ − bⱼ)² Lance–Williams update after merging clusters i and j: d(k, i∪j) = αᵢ d(k,i) + αⱼ d(k,j) + β d(i,j) + γ |d(k,i) − d(k,j)| Ward (ward.D2) works on squared distances and reports √ of the merge criterion Silhouette of a row: s = (b − a) / max(a, b) a = mean distance to its own cluster, b = mean distance to the nearest other cluster Cophenetic correlation = correlation between the original distances and the dendrogram heights

The tool uses the same algorithm as R’s hclust() (Murtagh’s nearest-neighbour implementation), so merges, heights and the leaf order of the dendrogram are identical to hclust(dist(scale(x)), method = "ward.D2"), and the clusters equal cutree(). Silhouette widths match cluster::silhouette().

How to report a cluster analysis

Hierarchical cluster analysis of the 50 states (four variables standardised to z-scores, Euclidean distance, Ward’s method) produced four clusters. The average silhouette width was .34 and the cophenetic correlation .70. Cluster 1 combined high murder and assault rates…

Report the variables, standardisation, distance, linkage, how you chose the number of clusters, and a table of cluster means. Learn to do this in R in the R with Aammar course.

Learn the statistics behind these numbers. Codanics has free statistics, R and Python lessons on YouTube and full courses for researchers.

Frequently asked questions

How do I choose the number of clusters?

Look for a large jump in merge height in the dendrogram (a long vertical branch) and cut below it. The tool also calculates the average silhouette width for 2 to 10 clusters: higher is better, and values above 0.5 indicate a reasonable structure. Finally, the clusters must make sense for your research question.

Should I standardise my variables before clustering?

Yes, whenever the variables are measured in different units or on different scales. Otherwise the variable with the largest numbers dominates the distances. Z-scores (mean 0, SD 1) are the usual choice. Use raw values only if all variables share a unit and their spread is meaningful.

What is the difference between ward.D and ward.D2?

ward.D2 squares the distances before applying Ward’s criterion and is the correct implementation of Ward’s minimum-variance method for Euclidean distances. ward.D (the only Ward option in R before version 3.1.0) applies the formula to unsquared distances. Most textbooks and recent papers mean ward.D2.

What does the cophenetic correlation tell me?

It is the correlation between the original pairwise distances and the heights at which pairs of rows are joined in the dendrogram. Values above about 0.75 mean the tree is a faithful summary of the distances. Comparing it across linkage methods helps you pick a method.

Hierarchical clustering or k-means?

Hierarchical clustering suits small to medium data sets (up to a few thousand rows), gives a full tree and does not need k in advance. K-means is faster for large data and optimises compact clusters for a fixed k. Many studies use both: the dendrogram to choose k, then k-means to refine the clusters.

Can I cluster variables instead of rows?

Yes. Transpose your table in Excel so that the variables become rows, then paste it. The clustered heatmap also orders the variables by their similarity.

Is my data uploaded?

No. All calculations run in your browser. Pasted and uploaded data never leave your device.

Do I need to log in or create an account to use the hierarchical clustering calculator?

No. There is no login, no sign-up and no email required. Open the page and start using it straight away, for free, on any device.

How do I cite this tool in my thesis or paper?

Use the citation box on this page. In APA 7th edition: Tufail, M. A. (2026). Hierarchical clustering calculator: dendrogram and clustered heatmap [Online tool]. Codanics. Retrieved [date you used it], from https://codanics.com/tools/hierarchical-clustering-calculator/. BibTeX, RIS (EndNote, Mendeley, Zotero), MLA, Harvard, Chicago and Vancouver formats are also available.

Free guides and courses from Codanics

More free tools

See all free Codanics tools → · Codanics on YouTube · WhatsApp channel

Made by Dr. Muhammad Aammar Tufail, Codanics. First published 17 November 2026, last updated 16 November 2026. Found a bug or have an idea for a new tool? Tell us on the WhatsApp channel or in the comments on YouTube. Results are for learning and planning; check important analyses with a statistician or your supervisor.