I’ve been using ggplot2 for automated report generation, and had been using ggdendro for accompanying dendrograms. However, as ggdendro seem to no longer be actively supported and I encountered this bug, I am trying to move over to dendextend. However, there is inconsistency between the base graphics output (with dendextend loaded) and the ggplot2 version, with respect to the leaf labels. The ggplot2 output does not reserve enough space for the leaf labels, whereas the base plot and ggdendro versions do.
See below for the differences between the three methods.
Image showing the problem described above
Manually specifying the amount of room to leave for each generated plot is not an option.
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)
Ben Wright is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.