作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建圆形系统发育树。我有这部分代码:
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)
最佳答案
当你说“颜色分支”时,我假设你的意思是给边缘上色。这似乎有效,但我必须认为有更好的方法。
使用内置 mtcars
数据集在这里,因为您没有提供您的数据。
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(...)
。我没有提供工作示例,因为我无法想象您会在那里放置什么标签。
关于r - 圆形系统发育树上的节点标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27475106/
我是一名优秀的程序员,十分优秀!