Last updated: 2021-12-27

Checks: 7 0

Knit directory: cacoaAnalysis/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it's best to always run the code in an empty environment.

The command set.seed(20211123) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version c4d4786. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.Rhistory
    Ignored:    analysis/figure_cluster_based_de_bio.nb.html
    Ignored:    analysis/figure_cluster_free_expression.nb.html
    Ignored:    analysis/figure_compositional.nb.html
    Ignored:    analysis/figure_compositional_cf.nb.html
    Ignored:    analysis/figure_expression_shifts.nb.html
    Ignored:    analysis/figure_interpretation.nb.html
    Ignored:    analysis/prepare_cacoa_results.nb.html
    Ignored:    analysis/preprocess.nb.html
    Ignored:    analysis/report_asd.nb.html
    Ignored:    analysis/report_az.nb.html
    Ignored:    analysis/report_ep.nb.html
    Ignored:    analysis/report_ms.nb.html
    Ignored:    analysis/report_pf.nb.html
    Ignored:    analysis/report_scc.nb.html
    Ignored:    analysis/simulation_distances.nb.html
    Ignored:    analysis/simulation_variance.nb.html
    Ignored:    cache/
    Ignored:    data/ASD/
    Ignored:    data/AZ/
    Ignored:    data/EP/
    Ignored:    data/MS/
    Ignored:    data/PF/
    Ignored:    data/SCC/
    Ignored:    man/
    Ignored:    output/figures/

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/figure_cluster_free_expression.Rmd) and HTML (docs/figure_cluster_free_expression.html) files. If you've configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd eafb34e viktor_petukhov 2021-12-27 Updated cluster-free expression figures
Rmd 48929dd viktor_petukhov 2021-12-22 Cluster-free expression figure

library(tidyverse)
library(magrittr)
library(conos)
library(cowplot)
library(cacoa)
library(sccore)
library(dataorganizer)
library(ggrastr)

options(ggrastr.default.dpi=100)
rast <- function(...) rasterise(..., dev="ragg_png")

devtools::load_all()

theme_set(theme_bw())
N_CORES <- 50

score_palette <- brewerPalette("YlOrRd", rev=FALSE)

Cluster-free shifts, PF

cao_pf <- read_rds(DataPath("PF/cao.rds")) %>% Cacoa$new()
cao_endo <- readOrCreate(CachePath("cao_pf_endo.rds"), function() {
  cms_endo <- lapply(cao_pf$data.object$samples, function(p2) {
    p2$misc$rawCounts %>% .[cao_pf$cell.groups[rownames(.)] == "Endothelial Cells",] %>% t()
  }) %>% .[sapply(., ncol) > 80]
  
  p2s_endo <- plapply(cms_endo, createPagoda, n.pcs=50, n.cores=N_CORES, progress=TRUE, 
                      mc.preschedule=TRUE)
  if ("value" %in% names(p2s_endo)) p2s_endo <- p2s_endo$value
  
  con_endo <- conos::Conos$new(p2s_endo, n.cores=N_CORES)
  con_endo$buildGraph(k=30, k.self.weight=0.5)
  con_endo$embedGraph(min.prob.lower=1e-4, method="UMAP", verbose=FALSE)
  con_endo$findCommunities(method=leiden.community, resolution=1, n.iterations=10, name='leiden')
  
  endo_cluster_ann <- c(
    "general capillary", # (AFF3, BTNL9)
    "arterial", # (DKK2)
    "systemic-venous", # (COL15A1)
    "pulmonary-venous", # (CPE)
    "aerocyte" # (EDNRB)
  )
  
  clusts <- con_endo$clusters$leiden$groups
  ann_per_clust <- con_endo$samples[[1]]$counts[,c("AFF3", "DKK2", "COL15A1", "CPE", "EDNRB")] %>% 
    collapseCellsByType(clusts) %>% 
    {t(.) / colSums(.)} %>% t() %>% 
    apply(1, which.max) %>% endo_cluster_ann[.]
  ann_endo <- setNames(ann_per_clust[clusts], names(clusts))
  
  cao_endo <- Cacoa$new(
    con_endo, cell.groups=ann_endo, 
    sample.groups=cao_pf$sample.groups[names(con_endo$samples)], 
    ref.level=cao_pf$ref.level, target.level=cao_pf$target.level, n.cores=N_CORES
  )
  cao_endo$plot.theme %<>% `+`(theme(legend.background=element_blank()))
  
  cao_endo$estimateDEPerCellType(independent.filtering=TRUE, test="DESeq2.Wald")
  return(cao_endo)
})

cao_endo$plotEmbedding(color.by='cell.groups')

leg_theme <- theme(legend.key.width=unit(12, "pt"), legend.key.height=unit(14, "pt"))

ggs_pf <- cao_pf$plotClusterFreeExpressionShifts(
  legend.position=c(0, 1), size=0.1, alpha=0.1, cell.groups=NULL, build.panel=FALSE,
  adj.list=leg_theme
)

p_lims <- getCellTypeEmbeddingLimits(
  cao_pf$embedding, cell.groups=cao_pf$cell.groups, groups.to.plot="Endothelial Cells", quant=0.005
)

gg_endo <- cao_pf$plotClusterFreeExpressionShifts(
  legend.position=c(1, 1), size=0.3, alpha=1, cell.groups=NULL, build.panel=FALSE,
)[[1]] + lims(x=p_lims$x, y=p_lims$y) + leg_theme

# ggs_pf[[1]] %<>% transferLabelLayer(cao_pf$plotEmbedding(color.by='cell.groups'), font.size=2)
gg_endo %<>% cacoa:::transferLabelLayer(cao_pf$plotEmbedding(groups=cao_endo$cell.groups), font.size=3)

plot_grid(plotlist=c(ggs_pf, list(gg_endo)), ncol=3)

end_mt_genes <- c("FN1", "S100A4") # endothelial-to-mesenchymal transition
t_sub_cm <- cao_endo$cache$joint.count.matrix[,end_mt_genes]
expr_df <- cao_endo$sample.per.cell %>% {split(names(.), .)} %>% 
  lapply(function(samp.cbs) {
    lapply(split(samp.cbs, cao_endo$cell.groups[samp.cbs]), function(cg.cbs) {
      tibble(expr=colMeans(t_sub_cm[cg.cbs,,drop=FALSE]), gene=colnames(t_sub_cm))
    }) %>% bind_rows(.id="Type")
  }) %>% bind_rows(.id="Sample") %>% 
  mutate(Condition=cao_endo$sample.groups[Sample])

p_df <- lapply(cao_endo$test.results$de, function(de) {
  de$res[colnames(t_sub_cm),] %>% 
    select(Gene, pvalue) %>% as_tibble()
}) %>% 
  bind_rows(.id='Type') %>% 
  mutate(padj=p.adjust(pvalue, method='BH'), Type=stringr::str_wrap(Type, width=6))

expr_df$Type %<>% stringr::str_wrap(width=6) %>% as.factor()
ggs_box_endo <- split(expr_df, expr_df$gene) %>% lapply(function(df) {
  pvals <- filter(p_df, Gene == df$gene[1]) %$% setNames(padj, Type)
  pval.df <- cacoa:::pvalueToCode(pvals, ns.symbol="") %>%
    tibble(Type=factor(names(.), levels=levels(df$Type)), pvalue=.) %>% na.omit()
  
  pvalue.y <- 1.01 * max(df$expr, na.rm=TRUE)
  ggplot(df) + 
    geom_boxplot(aes(x=Type, y=expr, fill=Condition), outlier.alpha=0) +
    ggbeeswarm::geom_quasirandom(aes(x=Type, y=expr, group=Condition), width=0.1, dodge.width=0.75, size=0.5) +
    geom_text(data=pval.df, mapping=aes(x=Type, label=pvalue), y=pvalue.y, color="black") +
    scale_y_continuous(limits=c(0, 1.1 * pvalue.y), expand=c(0, 0), name=paste(df$gene[1], "expression")) +
    scale_fill_manual(values=cao_endo$sample.groups.palette) +
    cao_endo$plot.theme + theme_legend_position(c(1, 0.9)) +
    theme(
      legend.background=element_blank(), 
      axis.title.x=element_blank(), axis.line.y.left=element_line(size=0.25), axis.line.x.bottom=element_line(size=0.25), 
      panel.border=element_blank(), panel.grid.major.x=element_blank(), panel.grid.minor.y=element_blank()
    )
})

ggs_box_endo[[1]] %<>% {. + theme(legend.position="none")}

plot_grid(plotlist=ggs_box_endo, ncol=2)

leg_theme <- theme(legend.key.width=unit(10, "pt"), legend.key.height=unit(12, "pt"), legend.text=element_text(size=8))
p_embs <- c(ggs_pf, list(gg_endo)) %>% lapply(`+`, leg_theme) %>% rast()

scale <- 0.97
plot_grid(
  plot_grid(plotlist=p_embs, ncol=3, scale=scale),
  plot_grid(plotlist=ggs_box_endo, ncol=2, scale=scale),
  ncol=1, rel_heights=c(1, 0.6), scale=scale
)

Cluster-free DE, Epilepsy

cao_ep <- read_rds(DataPath("EP/cao.rds")) %>% Cacoa$new()
cao_ep$plot.params <- list(size=0.1, alpha=0.1, font.size=c(2, 3), legend.position=c(0, 1))

org.db <- org.Hs.eg.db::org.Hs.eg.db
go.environment <- cao_ep$getGOEnvironment(org.db, verbose=TRUE, ignore.cache=FALSE)

cao_ep$plotEmbedding(color.by='cell.groups')

Global programs

cao_ep$estimateGenePrograms(method="leiden", z.adj=TRUE, smooth=TRUE, n.top.genes=1000,
                            resolution=1, abs.scores=TRUE, min.z=0.5)
cao_ep$plotGeneProgramScores(plot.na=FALSE)

Gene program genes:

prog_id <- 2
# cao_ep$plotGeneProgramGenes(prog_id, ordering="similarity", max.genes=9, plot.na=FALSE) %>% 
#   plot_grid(plotlist=., ncol=3)
cao_ep$test.results$gene.programs$sim.scores[[prog_id]] %>% {tibble(Gene=names(.), Score=.)}
# A tibble: 177 x 2
   Gene   Score
   <chr>  <dbl>
 1 NEGR1  0.951
 2 MAGI2  0.949
 3 EFNA5  0.948
 4 FBXL17 0.946
 5 SHISA9 0.944
 6 HIVEP2 0.944
 7 GLS    0.940
 8 CADPS2 0.940
 9 CELF5  0.939
10 AKT3   0.937
# ... with 167 more rows
ggs_shisa9 <- cao_ep$plotGeneExpressionComparison(
  genes="SHISA9", gene.palette=brewerPalette('YlOrRd', rev=FALSE), plot.na=FALSE, 
  build.panel=FALSE, plots=c("expression", "z", "z.adj")
) %>% .[c(3, 4, 1, 2)]

plot_grid(plotlist=ggs_shisa9, nrow=1)

ex_cells <- cao_ep$cell.groups %>% .[grep("^L.*", .)] %>% names()
gene_universe_global <- which(colMeans(cao_ep$cache$joint.count.matrix[ex_cells,] > 0) > 0.1) %>% 
  names() %>% cacoa:::mapGeneIds(org.db)

length(gene_universe_global)
[1] 6477
go_global <- cao_ep$test.results$gene.programs$sim.scores[[prog_id]] %>%
  head(100) %>% names() %>% cacoa:::mapGeneIds(org.db) %>% list() %>%
  cacoa:::estimateEnrichedGO(org.db=org.db, go.environment=go.environment,
                             universe=gene_universe_global, readable=TRUE) %>%
  lapply(`[[`, 1)

gg_godot_global <- clusteredOntologyDotplot(go_global$BP, min.genes=5) +
  scale_size_continuous(range=c(1, 5), limits=c(5, 25), breaks=c(5, 10, 20, 25)) + 
  xlab("Gene ratio") +
  theme_legend_position(c(1, 0)) + 
  theme(legend.background=element_blank(), legend.box="horizontal", axis.text.y=element_text(size=11),
        legend.key.height=unit(8, "pt"), legend.key.width=unit(8, "pt"),
        plot.title=element_blank())
gg_godot_global

Local programs

p_type <- "L2_Cux2_Lamp5"
cell_subset <- cao_ep$cell.groups %>% .[. == p_type] %>% names()
genes <- cao_ep$getMostChangedGenes(200, method="z.adj", cell.subset=cell_subset)
cao_ep$estimateGenePrograms(
  name="gp.local", genes=names(genes), method="pam", z.adj=TRUE, smooth=FALSE, 
  cell.subset=cell_subset, n.programs=4, abs.scores=TRUE, min.z=1
)
local_prog_genes <- c('CADM1', 'CAMK2D', 'CADPS2', 'NTRK2')
sapply(cao_ep$test.results$gp.local$sim.scores, function(sc) 
  setNames(local_prog_genes %in% names(sc), local_prog_genes))
        [,1]  [,2]  [,3]  [,4]
CADM1  FALSE  TRUE FALSE FALSE
CAMK2D FALSE  TRUE FALSE FALSE
CADPS2  TRUE FALSE FALSE FALSE
NTRK2   TRUE FALSE FALSE FALSE
cont <- cao_ep$.__enclos_env__$private$getDensityContours(p_type, color="black", conf="10%")[[1]]
loc_lims <- getCellTypeEmbeddingLimits(cao_ep$embedding, cao_ep$cell.groups, groups.to.plot=p_type, 
                                       quant=0.01)

adj_list <- list(cont, lims(x=loc_lims$x, y=loc_lims$y))

cao_ep$plotGeneProgramScores(
  name="gp.local", plot.na=FALSE, adj.list=adj_list, build.panel=FALSE, 
  palette=score_palette, alpha=0.25
) %>% plot_grid(plotlist=., nrow=1)

# cao_ep$test.results$gp.local$sim.scores[[1]] %>% head(16) %>% 
#   cao_ep$plotGeneExpressionComparison(scores=., plots="z.adj", plot.na=FALSE, alpha=0.5) %>% 
#   lapply(`+`, adj_list) %>% 
#   plot_grid(plotlist=., ncol=4)

cao_ep$test.results$gp.local$sim.scores[[1]] %>% {tibble(Gene=names(.), Score=.)}
# A tibble: 28 x 2
   Gene          Score
   <chr>         <dbl>
 1 PLCB1         0.914
 2 GRIA2         0.910
 3 PPP3CA        0.909
 4 KCND2         0.906
 5 ATP2B1        0.906
 6 ERC2          0.888
 7 ITPR1         0.869
 8 RP11-701H24.9 0.862
 9 NTRK2         0.859
10 EFNA5         0.838
# ... with 18 more rows
cao_ep$test.results$gp.local$sim.scores[[2]] %>% {tibble(Gene=names(.), Score=.)}
# A tibble: 54 x 2
   Gene      Score
   <chr>     <dbl>
 1 CALN1     0.847
 2 LINC00486 0.845
 3 MAPT      0.844
 4 FAM153B   0.834
 5 PDE4DIP   0.832
 6 SSH2      0.830
 7 LARGE     0.820
 8 ADGRL2    0.818
 9 CELF4     0.817
10 CADM1     0.817
# ... with 44 more rows
gene_universe_local <- colMeans(cao_ep$cache$joint.count.matrix[cell_subset,] > 0) %>% 
  {which(. > 0.1)} %>% names() %>% cacoa:::mapGeneIds(org.db)

length(gene_universe_local)
[1] 6159
go_local <- cao_ep$test.results$gp.local$sim.scores %>% 
  lapply(function(x) head(names(x)[x > 0.5], 20)) %>%
  lapply(cacoa:::mapGeneIds, org.db) %>% 
  cacoa:::estimateEnrichedGO(org.db=org.db, go.environment=go.environment, readable=TRUE,
                             universe=gene_universe_local)

sapply(go_local$BP, function(r) sum(r@result$p.adjust < 0.05)) %>% setNames(1:length(.))
  1   2   3   4 
 69   0 128   0 
gg_godot_local <- clusteredOntologyDotplot(go_local$BP[[1]], min.genes=4) +
  scale_size_continuous(range=c(1, 5), limits=c(4, 7), breaks=c(4, 6, 7)) +
  xlab("Gene ratio") +
  guides(color=guide_none()) +
  theme_legend_position(c(1, 0)) + 
  theme(legend.background=element_blank(), legend.box="horizontal", axis.text.y=element_text(size=11),
        legend.key.height=unit(8, "pt"), legend.key.width=unit(8, "pt"), plot.title=element_blank())
gg_godot_local

# cao_ep$plotGeneExpressionComparison(
#   genes=c('CADM1', 'CAMK2D', 'CADPS2', 'NTRK2'),
#   plot.na=FALSE, gene.palette=score_palette,
#   size=0.2, alpha=0.2#, adj.list=lims(x=c(7, 27), y=c(15, 37))
# )

Figure

cont <- cao_ep$.__enclos_env__$private$getDensityContours("L2_Cux2_Lamp5", color="black", conf="10%")[[1]]

Global

# cao_ep$plotEmbedding(color.by='cell.groups', show.ticks=TRUE) +
#   scale_x_continuous(limits=c(-12, 70), expand=c(0, 0))
prog_id <- 2
prog_genes <- cao_ep$test.results$gene.programs$loading.scores[[prog_id]]
prog_cells <- cao_ep$test.results$gene.programs$program.scores[prog_id,] %>% {names(.)[. > 0.1]}
prog_genes <- cao_ep$test.results$cluster.free.de$z.adj[prog_cells, names(prog_genes)] %>% 
  colMeans(na.rm=TRUE) %>% sign() %>% {split(prog_genes, .)} %>% setNames(c("neg", "pos"))

# p_genes <- c(prog_genes$pos[1:2], prog_genes$neg[1:2]) %>% names()
glob_genes <- names(prog_genes$pos[3]) %>% c('NCAM2', 'GABRB2', 'EFNA5')
ggs <- cao_ep$plotGeneExpressionComparison(genes=glob_genes, plots="z.adj",legend.position="none", plot.na=FALSE)

en_x_lims <- c(-12, 70)
ggs[[1]] <- ggs[[1]] + theme_legend_position(c(0, 1)) + 
  theme(legend.key.height=unit(12, "pt"), legend.key.width=unit(12, "pt"))

theme_gene <- theme(plot.title=element_blank(), panel.grid.minor.x=element_blank())

# gg_global_genes <- ggs %>% lapply(`+`, list(xlim(en_x_lims), theme_gene)) %>%
#   plot_grid(plotlist=., ncol=4, labels=glob_genes, label_fontface="plain", 
#             hjust=0, label_x=0.04, label_size=12, label_y=0.1)

ggs_global_genes <- ggs %>% lapply(`+`, list(xlim(en_x_lims), theme_gene))

gg_prog_score <- cao_ep$plotGeneProgramScores(prog.ids=prog_id, legend.position=c(0, 1), 
                                              plot.na=FALSE, palette=score_palette) +
  cont + theme(plot.title=element_blank(), legend.key.height=unit(12, "pt"), legend.key.width=unit(12, "pt"))

plot_grid(plotlist=c(list(gg_prog_score), ggs_global_genes), nrow=1, rel_widths=c(2, 1, 1, 1, 1))

Local

adj_list <- list(
  scale_x_continuous(limits=loc_lims$x, expand=c(0, 0)),
  scale_y_continuous(limits=loc_lims$y, expand=c(0, 0)),
  theme(plot.title=element_blank(), panel.grid.minor.x=element_blank()),
  cont
)

ggs_ls <- cao_ep$plotGeneProgramScores(
  prog.ids=c(1, 2), name="gp.local", plot.na=FALSE, legend.position="none", 
  color.range=c(0, 2), build.panel=FALSE, adj.list=adj_list, palette=score_palette
)

ggs_local_genes <- cao_ep$plotGeneExpressionComparison(
  genes=local_prog_genes, plots="z.adj",legend.position="none", plot.na=FALSE, adj.list=adj_list,
  alpha=0.25
) %>% setNames(local_prog_genes)
plot_grid(
  plotlist=c(ggs_ls, ggs_local_genes),
  nrow=1,
  labels=c("", "", names(ggs_local_genes)), 
  label_fontface="plain", hjust=0, label_x=0.04, label_size=12, label_y=0.2
)

Compile main figure

leg_theme <- theme(
  plot.title=element_blank(), legend.key.width=unit(6, "pt"), legend.key.height=unit(8, "pt"),
  legend.text=element_text(size=8)
) + theme_legend_position(c(0, 0))


p_embs <- c(ggs_pf, list(gg_endo)) %>% 
  lapply(`+`, leg_theme + theme_legend_position(c(0, 1)))

scale <- 0.95

sg_ggs <- lapply(ggs_shisa9, `+`, list(xlim(en_x_lims), leg_theme))
sg_ggs[[2]] %<>% {. + theme(legend.position="none")}

ggs_global_genes[[1]] %<>% {. + leg_theme}

plot_grid(
  plot_grid(
    plot_grid(plotlist=rast(p_embs), ncol=3, scale=scale),
    plot_grid(plotlist=ggs_box_endo, ncol=2, scale=scale),
    ncol=1, rel_heights=c(1, 0.6), scale=scale
  ),
  plot_grid(plotlist=rast(c(
    list(cao_ep$plotEmbedding(color.by='cell.groups', font.size=2)), sg_ggs,
    list(gg_prog_score + leg_theme), ggs_global_genes,
    list(plot_grid(plotlist=rast(ggs_ls), ncol=2)), ggs_local_genes
    )), 
    labels=c(
      "", "SHISA9, Control", "SHISA9, Epilepsy", "", "",
      "", glob_genes,
      "", names(ggs_local_genes)),
    label_fontface="italic", hjust=0, label_x=0.07, label_y=0.98, label_size=11,
    nrow=3, ncol=5, rel_widths=c(2, 1, 1, 1, 1), rel_heights=c(2, 2, 1), scale=scale * 0.98
  ),
  ncol=1, rel_heights=c(4.2, 11 - 4.2)
)

ggsave(figurePath("6_de_cf.pdf"))

Compile supp. figure

scale <- 0.95

leg_theme <- theme(legend.key.width=unit(12, "pt"), legend.key.height=unit(14, "pt"))

theme_go <- theme(
  axis.text.y=element_text(size=10), plot.title=element_blank(), plot.margin=margin()
)

score_theme <- theme(
  plot.title=element_blank(), 
  legend.key.width=unit(10, "pt"), legend.key.height=unit(10, "pt")
)

ggs_glob_scores <- cao_ep$plotGeneProgramScores(
  plot.na=FALSE, prog.ids=2:9, adj.list=score_theme,
  build.panel=FALSE
)

plot_grid(
  plot_grid(
    plotlist=rast(ggs_glob_scores), ncol=4, scale=0.98
  ),
  plot_grid(
    plot_grid(
      gg_godot_global + theme_go + theme(plot.margin=margin(t=-2)),
      gg_godot_local + theme_go,
      ncol=1, rel_heights=c(2.5, 1), align="v", scale=scale
    ),
    plot_grid(
      rast(cao_ep$plotDiffCellDensity(name='cell.density.graph', type='subtract', color.range=c("1%", "99%"))) +
        leg_theme,
      rast(cao_ep$plotDiffCellDensity(name='cell.density.graph', type='wilcox')) + leg_theme,
      ncol=1, scale=scale
    ),
    nrow=1, rel_widths=c(2, 1)
  ),
  ncol=1, rel_heights=c(4.4, 5.6), scale=0.97
)

ggsave(figurePath("6s_de_cf.pdf"))

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /usr/local/R/R-4.0.3/lib/R/lib/libRblas.so
LAPACK: /usr/local/R/R-4.0.3/lib/R/lib/libRlapack.so

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] cacoaAnalysis_0.1.0 ggrastr_1.0.1       dataorganizer_0.1.0
 [4] sccore_1.0.1        cacoa_0.2.0         cowplot_1.1.1      
 [7] conos_1.4.4         igraph_1.2.6        Matrix_1.2-18      
[10] magrittr_2.0.1      forcats_0.5.1       stringr_1.4.0      
[13] dplyr_1.0.7         purrr_0.3.4         readr_1.4.0        
[16] tidyr_1.1.4         tibble_3.1.5        ggplot2_3.3.5      
[19] tidyverse_1.3.0     workflowr_1.6.2    

loaded via a namespace (and not attached):
  [1] utf8_1.2.2             ks_1.13.1              reticulate_1.22       
  [4] R.utils_2.10.1         tidyselect_1.1.1       RSQLite_2.2.8         
  [7] AnnotationDbi_1.52.0   BiocParallel_1.24.1    grid_4.0.3            
 [10] Rtsne_0.15             scatterpie_0.1.5       devtools_2.3.2        
 [13] munsell_0.5.0          codetools_0.2-16       ragg_0.4.1            
 [16] withr_2.4.2            GOSemSim_2.16.1        colorspace_2.0-2      
 [19] Biobase_2.50.0         highr_0.9              knitr_1.36            
 [22] rstudioapi_0.13        stats4_4.0.3           ggsignif_0.6.1        
 [25] DOSE_3.16.0            labeling_0.4.2         git2r_0.27.1          
 [28] urltools_1.7.3         polyclip_1.10-0        bit64_4.0.5           
 [31] farver_2.1.0           downloader_0.4         rprojroot_2.0.2       
 [34] Matrix.utils_0.9.8     vctrs_0.3.8            generics_0.1.0        
 [37] xfun_0.26              R6_2.5.1               doParallel_1.0.16     
 [40] graphlayouts_0.7.1     ggbeeswarm_0.6.0       clue_0.3-59           
 [43] fgsea_1.16.0           cachem_1.0.6           assertthat_0.2.1      
 [46] promises_1.1.1         scales_1.1.1           ggraph_2.0.4          
 [49] enrichplot_1.10.1      beeswarm_0.4.0         gtable_0.3.0          
 [52] processx_3.4.5         tidygraph_1.2.0        drat_0.1.8            
 [55] rlang_0.4.11           systemfonts_1.0.0      GlobalOptions_0.1.2   
 [58] splines_4.0.3          rstatix_0.7.0          broom_0.7.9           
 [61] brew_1.0-6             BiocManager_1.30.10    yaml_2.2.1            
 [64] reshape2_1.4.4         abind_1.4-5            modelr_0.1.8          
 [67] backports_1.2.1        httpuv_1.5.4           qvalue_2.22.0         
 [70] clusterProfiler_3.18.0 tools_4.0.3            usethis_1.6.3         
 [73] ellipsis_0.3.2         jquerylib_0.1.4        RColorBrewer_1.1-2    
 [76] BiocGenerics_0.36.1    sessioninfo_1.1.1      Rcpp_1.0.7            
 [79] plyr_1.8.6             ps_1.4.0               prettyunits_1.1.1     
 [82] ggpubr_0.4.0           dendsort_0.3.3         viridis_0.6.1         
 [85] GetoptLong_1.0.5       S4Vectors_0.28.1       grr_0.9.5             
 [88] haven_2.4.1            ggrepel_0.9.1          cluster_2.1.0         
 [91] fs_1.5.0               data.table_1.14.2      DO.db_2.9             
 [94] openxlsx_4.2.3         circlize_0.4.13        triebeard_0.3.0       
 [97] reprex_0.3.0           mvtnorm_1.1-2          whisker_0.4           
[100] matrixStats_0.61.0     pkgload_1.2.1          hms_1.1.1             
[103] evaluate_0.14          rio_0.5.26             mclust_5.4.7          
[106] RMTstat_0.3            readxl_1.3.1           N2R_0.1.1             
[109] IRanges_2.24.1         gridExtra_2.3          shape_1.4.6           
[112] testthat_3.0.0         compiler_4.0.3         KernSmooth_2.23-17    
[115] shadowtext_0.0.7       crayon_1.4.1           R.oo_1.24.0           
[118] htmltools_0.5.2        mgcv_1.8-33            later_1.1.0.1         
[121] lubridate_1.7.9.2      DBI_1.1.1              tweenr_1.0.1          
[124] dbplyr_2.0.0           pagoda2_1.0.7          ComplexHeatmap_2.9.4  
[127] MASS_7.3-53            car_3.0-10             cli_3.0.1             
[130] R.methodsS3_1.8.1      parallel_4.0.3         pkgconfig_2.0.3       
[133] rvcheck_0.1.8          foreign_0.8-80         xml2_1.3.2            
[136] foreach_1.5.1          vipor_0.4.5            leidenAlg_0.1.0       
[139] rvest_0.3.6            callr_3.5.1            digest_0.6.28         
[142] pracma_2.3.3           fastmatch_1.1-0        rmarkdown_2.11        
[145] cellranger_1.1.0       Rook_1.1-1             curl_4.3.2            
[148] rjson_0.2.20           lifecycle_1.0.1        nlme_3.1-149          
[151] jsonlite_1.7.2         carData_3.0-4          viridisLite_0.4.0     
[154] desc_1.3.0             fansi_0.5.0            pillar_1.6.3          
[157] lattice_0.20-41        GO.db_3.12.1           fastmap_1.1.0         
[160] httr_1.4.2             pkgbuild_1.1.0         glue_1.4.2            
[163] remotes_2.2.0          zip_2.2.0              png_0.1-7             
[166] iterators_1.0.13       bit_4.0.4              ggforce_0.3.2         
[169] stringi_1.7.5          blob_1.2.2             textshaping_0.2.1     
[172] org.Hs.eg.db_3.12.0    memoise_2.0.0          irlba_2.3.3           
[175] ape_5.5