Node labels on a round phylogenetic tree

I am trying to create a circular phylogenetic tree. I have this piece 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 the result: enter image description here

I am also trying to show a shortcut for each node and for colored branches. Any suggestion how to do this?

Thank!

+4
source share
1 answer

When you say β€œcolor branches,” I assume that you mean the color of the edges. It seems to work, but I have to think that there is a better way.

Using the built-in dataset mtcarshere, as you did not provide your data.

plot.fan <- function(hc, nclus=3) {
  palette <- c('red','blue','green','orange','black')[1:nclus]
  clus    <-cutree(hc,nclus)
  X <- as.phylo(hc)
  edge.clus <- sapply(1:nclus,function(i)max(which(X$edge[,2] %in% which(clus==i))))
  order     <- order(edge.clus)
  edge.clus <- c(min(edge.clus),diff(sort(edge.clus)))
  edge.clus <- rep(order,edge.clus)
  plot(X,type='fan',
       tip.color=palette[clus],edge.color=palette[edge.clus],
       label.offset=0.2,no.margin=TRUE, cex=0.70)  
}
fit <- hclust(dist(mtcars[,c("mpg","hp","wt","disp")]))
plot.fan(fit,3); plot.fan(fit,5)

" ", , , . , , plot.hclust(...) labels=... . tiplabels(....), type="fan" . Data, IMO .

( , nodelabels(...)). , , .

+3

All Articles