pneuvial / adjclust

Adjacency-constrained hierarchical clustering of a similarity matrix
https://pneuvial.github.io/adjclust/
16 stars 8 forks source link

Add option to label merges on dendrogram #31

Closed pneuvial closed 6 years ago

pneuvial commented 6 years ago

Goal: be able to see reversals in small examples

pneuvial commented 6 years ago

(example to be added by @Zlamouche ) The following dissimilarity matrix (first given in terms of linkage between singletons->Delta, then in terms of dissimilarity->D) provides a contiguity constrained clustering where singletons are merged from left to right. In this particular case, the within-cluster dispersion and total dispersion for each merge (I_t and ESS_t) are equal; that explains graphics are the same for "total-disp" and "within-disp". Although the reversal is clearly visible in the first two dendrograms, it is less clear for "average-disp" since we do not know the order of merging when looking at the graphic.

Delta <- matrix(c(0,1.99,1.99,1.99,0.01,1,1.99,0,2,1.99,0.01,1,1.99,2,0,2,0.01,1,1.99,1.99,2,0,2,1,0.01,0.01,0.01,2,0,2,1,1,1,1,2,0),nrow=6)
D <- sqrt(2*Delta)
fit <- adjClust(D, type = "dissimilarity")
plot(fit,mode = "total-disp")
plot(fit,mode = "within-disp")
plot(fit,mode = "average-disp")
pneuvial commented 6 years ago

Clarification: the goal is to label the nodes using the ordering of the merges.

pneuvial commented 6 years ago

see packages dendextend and ape

ghost commented 6 years ago

It is now possible through the logical argument nodeLabel of plot.chac.