繁体   English   中英

如何在R中使用猿包绘制树状图?

[英]How to draw dendrogram using ape package in R?

我的距离矩阵大小约为200 x 200,我无法使用R中的ape库的BioNJ选项绘制树状图。该尺寸很大,可以使该图可见。如何改善可见度? 在此处输入图片说明

两种选择取决于您的数据

如果您需要计算数据的距离矩阵,请使用

set.seed(1)                          # makes random sampling with rnorm reproducible
# example matrix
m <- matrix(rnorm(100), nrow = 5)    # any MxN matrix
distm <- dist(m)                     # distance matrix
hm <- hclust(distm)
plot(hm)

如果您的数据是距离矩阵(必须是平方矩阵!)

set.seed(1)
# example matrix
m <- matrix(rnorm(25), nrow=5)       # must be square matrix!
distm <- as.dist(m)
hm <- hclust(distm)
plot(hm)

200 x 200距离矩阵给我一个合理的图

set.seed(1)
# example matrix
m <- matrix(rnorm(200*200), nrow=200)       # must be square matrix!
distm <- as.dist(m)
hm <- hclust(distm)
plot(hm)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM