圆形系统发育树上的节点标签 [英] Node labels on circular phylogenetic tree

查看:380
本文介绍了圆形系统发育树上的节点标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建圆形的系统发育树.我有这部分代码:

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)

这是结果:

我也试图为每个节点显示标签并为分支着色.有什么建议怎么做吗?

Also I am trying to show label for each node and to color branches. Any suggestion how to do that?

谢谢!

推荐答案

当您说颜色分支"时,我假设您是指对边缘进行着色.这似乎可行,但我必须认为有更好的方法.

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.

在这里使用内置的mtcars数据集,因为您没有提供数据.

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)

关于标记节点",如果您的意思是标记提示,则好像已经完成了.不幸的是,如果您想要不同的标签,则与plot.hclust(...)不同,labels=...参数将被拒绝.您可以尝试使用tiplabels(....)函数,但对于type="fan"来说似乎不能很好地工作.标签来自Data的行名,因此,最好的选择IMO是在群集之前更改行名.

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.

如果您实际上是要标记节点(边缘之间的连接点,请查看nodelabels(...).我没有提供一个有效的示例,因为我无法想象您会在此处放置什么标签.

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.

这篇关于圆形系统发育树上的节点标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆