# Joining subcluster based on distance

I have the following sequence data:

data = {"TTGTTCTTGATA", "TACTTGAACGTT", "TTTGGAGAATAT", "GGGGTGTGAAAA",
"TGCGGTTGAGTG", "TAGACTCGCTAC", "ATTGTAAAGACA", "TTCACGGTGGTT",
"TATCTTCGTTTG", "TATACTGGTTTG"}


I did hierarchical clustering on them using HammingDistance. And the dendrogram plot is something like this:

The code I used is:

Needs["HierarchicalClustering"];
DendrogramPlot[data, Axes -> {False, True},
DistanceFunction -> HammingDistance, Linkage -> "Single"]


What I want to do is joining the subclusters that are below a certain distance. For example, I'd like to join the subclusters that are within distance 4 and to report the final number of clusters after joining subclusters.

The Findcluster in Mathematica lets one choose the number of clusters, not the cutoff distance. Any idea is highly appreciated.

• Your last edit was a major improvement. However, the only thing that I can contribute at the moment is that you can obtain essentially the same functionality with G = ClusteringTree[data, DistanceFunction -> HammingDistance, ClusterDissimilarityFunction -> "Single"]; Dendrogram[G]. The advantage is that G is now a Graph object, which can be analyzed further (in contrast to Dendrogram and DendrogramPlot, which are Graphics` objects). – Henrik Schumacher May 18 '18 at 21:50