【发布时间】:2017-02-02 00:02:23
【问题描述】:
我有一个dendrogram:
set.seed(10)
mat <- matrix(rnorm(20*10),nrow=20,ncol=10)
dend <- as.dendrogram(hclust(dist(mat)))
并给出一个深度截止:
我想剪掉该截止点右侧的所有分支。
depth.cutoff <- 4.75
我想剪掉虚线右侧的所有分支:
plot(dend,horiz = TRUE)
abline(v=depth.cutoff,col="red",lty=2)
最后得到这个dendrogram:
我得到的最接近的是使用ape 的drop.tip,但问题是如果我的depth.cutoff 包含所有叶子,如本例所示,它返回NULL。
如果他们的depth 低于depth.cutoff,也许有人知道我是否以及如何从代表我的dendrogram 的nested list 中删除元素?
或者,也许我可以将dendrogram 转换为data.frame,其中还列出了每个node 的depth(包括具有depth=0 的叶子),删除所有带有@987654343 的行@<depth.cutoff 从那个data.frame,然后将它转换回dendrogram?
【问题讨论】:
标签: r list dendrogram ape