Node labels on circular phylogenetic tree

我与影子孤独终老i 提交于 2019-12-04 09:59:47

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.

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)

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(...) the labels=... argument is rejected. You could experiment with the tiplabels(....) function, but it does not seem to work very well with type="fan". The labels come from the row names of Data, 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!