5

My dendrograms are horribly ugly, on the verge of unreadable, and usually look like this:

enter image description here

library(TraMineR)
library(cluster)
data(biofam)
lab <- c("P","L","M","LM","C","LC","LMC","D")
biofam.seq <- seqdef(biofam[1:500,10:25], states=lab)

ccost <- seqsubm(biofam.seq, method = "CONSTANT", cval = 2, with.missing=TRUE)
sequences.OM <- seqdist(biofam.seq, method = "OM", norm= TRUE, sm = ccost,     
with.missing=TRUE)

clusterward <- agnes(sequences.OM, diss = TRUE, method = "ward")
plot(clusterward, which.plots = 2)

What I would like to create is something like the following, meaning a round dendrogram, where the size of the labels can be carefully controlled so that they are actually visible:

enter image description here

How can I accomplish this in R?

plannapus
  • 18,529
  • 4
  • 72
  • 94
histelheim
  • 4,938
  • 6
  • 33
  • 63

1 Answers1

9

The following solution may not be optimal but worth a try:

library(ape)
CL1 <- as.hclust(clusterward)
CL2 <- as.phylo(CL1)
plot(CL2, type="fan", cex=0.5)

enter image description here

The main issue obviously being the fact that there is still too many objects, hence too many labels. To turn the labels off, use argument show.tip.label=FALSE. You can also get rid of the margins to occupy the complete device with no.margin=TRUE:

plot(CL2, type="fan", show.tip.label=FALSE, no.margin=TRUE)

enter image description here

plannapus
  • 18,529
  • 4
  • 72
  • 94
  • Can you also just turn off the labels? They don't add much information to the plot, given the overlaps. – histelheim Jan 28 '14 at 16:17
  • This may be out of scope, but is there a simple way of cutting the tree? I've tried `cutree` as well as the `members` argument for `as.hclust`, but can't seem to make it work. – histelheim Jan 28 '14 at 16:45
  • @histelheim You should probably ask it as a new question as more people will be able to answer you. Right now I'm not entirely sure of the best method to do that. – plannapus Jan 29 '14 at 07:32
  • You also have a lot a neat solutions for [this question](http://stackoverflow.com/questions/7404035/how-to-plot-dendrograms-with-large-datasets) that might help you. – plannapus Jan 29 '14 at 07:49