To use ggplot2 to draw dendrogram, another option would be ggalign
knitr::opts_knit$set(upload.fun = identity)
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 = quote(hclust(d = dist(t(count.data[gene.masks$Genes, ])))),
dist.method = "euclidean"
), class = "hclust")
library(ggalign)
#> Loading required package: ggplot2
ggstack(NULL, "v") +
align_dendro(method = as.dendrogram(tmp)) +
theme(axis.text.x = element_text(angle = 90))
Created on 2024-10-12 with reprex v2.1.0