dendextend中as.ggdend生成的ggplot2树状图叶标签空间不足
dendextend生成的ggplot2树状图叶标签空间不足问题
我使用ggplot2生成自动化报告,此前依赖ggdendro绘制配套树状图。但ggdendro已停止维护,且遇到了相关bug,因此转用dendextend。然而发现:dendextend输出的ggplot2版本树状图,叶标签没有足够的显示空间;但base绘图、ggdendro版本的输出都正常。
三种方法的输出差异对比:
无法手动为每个自动生成的图单独指定预留空间。
tmp <- structure(list(merge = structure(c(-2L, -17L, -4L, -8L, -9L, -18L, -6L, -1L, -13L, 3L, -22L, 2L, 8L, -5L, -21L, -11L, 12L, -14L, 16L, 11L, 15L, 19L, 21L, -3L, -20L, -12L, 1L, -10L, -19L, 4L, -7L, -16L, 5L, -23L, 7L, 10L, -15L, -24L, 6L, 13L, 9L, 17L, 14L, 18L, 20L, 22L), dim = c(23L, 2L)), height = c(45023.2309258232, 51012.7856326235, 58268.2644327081, 60190.454758209, 61767.4324786129, 66285.293896912, 73795.8493548248, 73915.5720738195, 90644.0966914007, 96920.4596202474, 102068.443095797, 107134.968399678, 115773.032503256, 117042.164244344, 121274.611506284, 127869.304201595, 131043.636743644, 158158.916403724, 203042.0850021, 204028.358261787, 267728.385874565, 289081.126533712, 575641.131737474), order = c(21L, 24L, 14L, 13L, 16L, 11L, 18L, 19L, 17L, 20L, 6L, 8L, 2L, 3L, 1L, 7L, 4L, 12L, 9L, 10L, 22L, 23L, 5L, 15L), labels = c("D10PBS_1", "D10PBS_2", "D10PBS_3", "D10PBS_4", "D10Myo_1", "D10Myo_2", "D10Myo_3", "D10Myo_4", "D15PBS_1", "D15PBS_2", "D15PBS_3", "D15PBS_4", "D15Myo_1", "D15Myo_2", "D15Myo_3", "D15Myo_4", "D21PBS_1", "D21PBS_2", "D21PBS_3", "D21PBS_4", "D21Myo_1", "D21Myo_2", "D21Myo_3", "D21Myo_4"), method = "complete", call = hclust(d = dist(t(count.data[gene.masks$Genes, ]))), dist.method = "euclidean"), class = "hclust") plot(as.dendrogram(tmp)) dendextend::as.ggdend(as.dendrogram(tmp)) ggdendro::ggdendrogram(tmp)
内容的提问来源于stack exchange,提问作者Ben Wright
相关产品推荐
相关产品推荐

