I have the following sequence data:


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

enter image description here

The code I used is:

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.

  • $\begingroup$ 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). $\endgroup$ – Henrik Schumacher May 18 '18 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.