I am trying to create circular phylogenetic tree. I have this part of code:
fit<- hclust(dist(Data[,-4]), method = "complete", members = NULL)
nclus= 3
color=c('red','blue','green')
color_list=rep(color,nclus/length(color))
clus=cutree(fit,nclus)
plot(as.phylo(fit),type='fan',tip.color=color_list[clus],label.offset=0.2,no.margin=TRUE, cex=0.70, show.node.label = TRUE)
And this is result:
Also I am trying to show label for each node and to color branches. Any suggestion how to do that?
Thanks!
When you say "color branches" I assume you mean color the edges. This seems to work, but I have to think there's a better way.
Using the built-in
mtcars
dataset here, since you did not provide your data.Regarding "label the nodes", if you mean label the tips, it looks like you've already done that. If you want different labels, unfortunately, unlike
plot.hclust(...)
thelabels=...
argument is rejected. You could experiment with thetiplabels(....)
function, but it does not seem to work very well withtype="fan"
. The labels come from the row names ofData
, so your best bet IMO is to change the row names prior to clustering.If you actually mean label the nodes (the connection points between the edges, have a look at
nodelabels(...)
. I don't provide a working example because I can't imagine what labels you would put there.