简体   繁体   English

大量节点的ggdendrogram

[英]ggdendrogram for a large number of nodes

I'm trying to plot a dendrogram with a large number of nodes using ggdendrogram and it's pretty slow (compared to dendextend for example): 我正在尝试使用ggdendrogram绘制具有大量节点的dendrogram ,并且它相当慢(例如,与dendextend相比):

set.seed(1)
mat <- matrix(rnorm(100*10),nrow=100,ncol=10)
dend <- as.dendrogram(hclust(dist(mat)))


require(ggdendro)
require(dendextend)
require(microbenchmark)
> microbenchmark(ggdendrogram(dend,rotate=T,labels=F,size=4,theme_dendro=F))
Unit: milliseconds
                                                                   expr      min       lq     mean  median       uq      max neval
 ggdendrogram(dend, rotate = T, labels = F, size = 4, theme_dendro = F) 394.3181 409.3591 431.0981 412.515 416.4568 1346.844   100

> microbenchmark(dend %>% plot(horiz = TRUE))
Unit: milliseconds
                        expr      min     lq     mean   median       uq      max neval
 dend %>% plot(horiz = TRUE) 138.7253 207.92 214.5278 208.8807 211.2602 640.0316   100

Is there any way to speed it up to make it comparable with dendextend 's plot's speed? 有什么方法可以使其加速,使其与dendextend的绘图速度可比吗?

Also, whether I specify rotate=T or 另外,是否指定rotate=T

ggdendrogram(dend,rotate=F,labels=F,size=4,theme_dendro=F)+coord_flip()

I get the dendrogram pointing left: 我得到了树状图指向左: 在此处输入图片说明

but I want it to point right instead. 但我希望它指向正确的位置。 Any idea how to get that to work? 任何想法如何使它工作?

At this stage, the dendextend package replaces ggdendro. 在此阶段,dendextend软件包将替换ggdendro。

set.seed(1)
mat <- matrix(rnorm(100*10),nrow=100,ncol=10)
dend <- as.dendrogram(hclust(dist(mat)))
require(dendextend)
gg_dend <- as.ggdend(dend)
require(ggplot2)
ggplot(gg_dend, labels = F)+coord_flip()+ scale_y_reverse()

在此处输入图片说明

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

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