Figure 4C

Code
# Enrique Blanco Carmona
# e.blancocarmona@kitz-heidelberg.de
# PhD Student – Clinical Bioinformatics
# Division of Pediatric Neurooncology (B062)
# DKFZ-KiTZ | Germany

# Read in metadata.
sample <- readRDS("/omics/odcf/analysis/OE0145_projects/idh_gliomas/Figures_Science/revision/IDH_gliomas_book/datasets/integrated_paired_AS.rds")
sample$relabelling[sample$relabelling == "RA"] <- "RE"
Seurat::Idents(sample) <- sample$relabelling

cluster_cols <- c("RE" = "#ECA809",
                  "OPC-like" = "#043362",                    
                  "Gradient" = "#D6D6D6",                    
                  "Astro-like" = "#9A031E",                  
                  "Cycling" = "#5F0F40")

idents.keep <- c("OPC-like", "Astro-like", "RE", "Gradient", "Cycling")
sample <- sample[, sample$relabelling %in% idents.keep]
Code
p1 <- SCpubr::do_BarPlot(sample = sample[, sample$orig.ident %in% c("IDH_NCH557", "IDH_NCH758A")],
                         group.by = "relabelling",
                         split.by = "orig.ident",
                         font.size = 18,
                         flip = TRUE,
                         colors.use = cluster_cols,
                         position = "fill",
                         legend.position = "none",
                         order = FALSE,
                         plot.grid = FALSE,
                         add.n = TRUE,
                         add.n.expand = c(0, 1.15),
                         axis.text.face = "plain",
                         add.n.size = 5) +
      ggplot2::xlab("Pair 1") +
      ggplot2::ylab("") + 
      ggplot2::theme(axis.text.x = ggplot2::element_blank(),
                     axis.ticks.x = ggplot2::element_blank(),
                     strip.text = ggplot2::element_blank(),
                     plot.margin = ggplot2::margin(t = 0, r = 10, b = 0, l = 10)) 

p2 <- SCpubr::do_BarPlot(sample = sample[, sample$orig.ident %in% c("IDH_NCH511B", "IDH_NCH678K")],
                         group.by = "relabelling",
                         split.by = "orig.ident",
                         font.size = 18,
                         flip = TRUE,
                         colors.use = cluster_cols,
                         position = "fill",
                         legend.position = "none",
                         order = FALSE,
                         plot.grid = FALSE,
                         add.n = TRUE,
                         add.n.expand = c(0, 1.15),
                         axis.text.face = "plain",
                         add.n.size = 5) +
      ggplot2::xlab("Pair 2") +
      ggplot2::ylab("") + 
      ggplot2::theme(axis.text.x = ggplot2::element_blank(),
                     axis.ticks.x = ggplot2::element_blank(),
                     strip.text = ggplot2::element_blank(),
                     plot.margin = ggplot2::margin(t = 0, r = 10, b = 0, l = 10))

p3 <- SCpubr::do_BarPlot(sample = sample[, sample$orig.ident %in% c("IDH_NCH302", "IDH_NCH645")],
                         group.by = "relabelling",
                         split.by = "orig.ident",
                         font.size = 18,
                         flip = TRUE,
                         colors.use = cluster_cols,
                         position = "fill",
                         legend.position = "none",
                         order = FALSE,
                         plot.grid = FALSE,
                         add.n = TRUE,
                         add.n.expand = c(0, 1.15),
                         axis.text.face = "plain",
                         add.n.size = 5) +
      ggplot2::xlab("Pair 3") +
      ggplot2::ylab("") + 
      ggplot2::theme(axis.text.x = ggplot2::element_blank(),
                     axis.ticks.x = ggplot2::element_blank(),
                     strip.text = ggplot2::element_blank(),
                     plot.margin = ggplot2::margin(t = 0, r = 10, b = 0, l = 10))

p4 <- SCpubr::do_BarPlot(sample = sample[, sample$orig.ident %in% c("IDH_NCH988", "IDH_NCH2375")],
                         group.by = "relabelling",
                         split.by = "orig.ident",
                         font.size = 18,
                         flip = TRUE,
                         colors.use = cluster_cols,
                         position = "fill",
                         legend.position = "none",
                         order = FALSE,
                         plot.grid = FALSE,
                         add.n = TRUE,
                         add.n.expand = c(0, 1.15),
                         axis.text.face = "plain",
                         add.n.size = 5) +
      ggplot2::xlab("Pair 4") +
      ggplot2::ylab("") + 
      ggplot2::theme(axis.text.x = ggplot2::element_blank(),
                     axis.ticks.x = ggplot2::element_blank(),
                     strip.text = ggplot2::element_blank(),
                     plot.margin = ggplot2::margin(t = 0, r = 10, b = 0, l = 10))

p5 <- SCpubr::do_BarPlot(sample = sample[, sample$orig.ident %in% c("IDH_NCH740W", "IDH_NCH2367")],
                         group.by = "relabelling",
                         split.by = "orig.ident",
                         font.size = 18,
                         flip = TRUE,
                         colors.use = cluster_cols,
                         position = "fill",
                         legend.position = "none",
                         order = FALSE,
                         plot.grid = FALSE,
                         add.n = TRUE,
                         add.n.expand = c(0, 1.15),
                         axis.text.face = "plain",
                         add.n.size = 5) +
      ggplot2::xlab("Pair 5") +
      ggplot2::ylab("") + 
      ggplot2::theme(axis.text.x = ggplot2::element_blank(),
                     axis.ticks.x = ggplot2::element_blank(),
                     strip.text = ggplot2::element_blank(),
                     plot.margin = ggplot2::margin(t = 0, r = 10, b = 0, l = 10))

p6 <- SCpubr::do_BarPlot(sample = sample[, sample$orig.ident %in% c("IDH_NCH673D", "IDH_NCH2260")],
                         group.by = "relabelling",
                         split.by = "orig.ident",
                         font.size = 18,
                         flip = TRUE,
                         colors.use = cluster_cols,
                         position = "fill",
                         legend.position = "none",
                         order = FALSE,
                         plot.grid = FALSE,
                         add.n = TRUE,
                         add.n.expand = c(0, 1.15),
                         axis.text.face = "plain",
                         add.n.size = 5) +
      ggplot2::xlab("Pair 6") +
      ggplot2::ylab("") + 
      ggplot2::theme(axis.text.x = ggplot2::element_blank(),
                     axis.ticks.x = ggplot2::element_blank(),
                     strip.text = ggplot2::element_blank(),
                     plot.margin = ggplot2::margin(t = 0, r = 10, b = 10, l = 10))

p7 <- SCpubr::do_BarPlot(sample = sample,
                         group.by = "relabelling",
                         split.by = "time",
                         font.size = 18,
                         flip = TRUE,
                         colors.use = cluster_cols,
                         position = "fill",
                         legend.position = "none",
                         order = FALSE,
                         plot.grid = FALSE,
                         add.n = TRUE,
                         add.n.expand = c(0, 1.15),
                         axis.text.face = "plain",
                         add.n.size = 5) +
      ggplot2::xlab("Status") +
      ggplot2::ylab("") + 
      ggplot2::theme(axis.text.x = ggplot2::element_blank(),
                     axis.ticks.x = ggplot2::element_blank(),
                     plot.margin = ggplot2::margin(t = 0, r = 10, b = 10, l = 10))


p8 <- SCpubr::do_BarPlot(sample = sample,
                         group.by = "relabelling",
                         split.by = "grade",
                         font.size = 18,
                         flip = TRUE,
                         colors.use = cluster_cols,
                         legend.title = "",
                         position = "fill",
                         order = FALSE,
                         plot.grid = FALSE,
                         add.n = TRUE,
                         add.n.expand = c(0, 1.15),
                         axis.text.face = "plain",
                         add.n.size = 5,
                         legend.ncol = 3) +
      ggplot2::xlab("Grade") +
      ggplot2::theme(plot.margin = ggplot2::margin(t = 0, r = 10, b = 0, l = 10))

layout <- paste(c(rep("A", 2), rep("B", 2), rep("C", 2), rep("D", 2), rep("E", 2), rep("F", 2), rep("G", 2), rep("H", 3), "I"), collapse = "\n")

p <- patchwork::wrap_plots(A = p1,
                           B = p2,
                           C = p3,
                           D = p4,
                           E = p5,
                           F = p6,
                           G = p7,
                           H = p8,
                           I = patchwork::guide_area(),
                           design = layout)