Last updated: 2026-04-01

Checks: 7 0

Knit directory: paediatric-cf-inflammation-citeseq/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). 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(20240216) 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 ff8cd64. 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/.DS_Store
    Ignored:    analysis/obsolete/
    Ignored:    code/obsolete/
    Ignored:    data/.DS_Store
    Ignored:    data/C133_Neeland_batch0/
    Ignored:    data/C133_Neeland_batch1/
    Ignored:    data/C133_Neeland_batch2/
    Ignored:    data/C133_Neeland_batch3/
    Ignored:    data/C133_Neeland_batch4/
    Ignored:    data/C133_Neeland_batch5/
    Ignored:    data/C133_Neeland_batch6/
    Ignored:    data/C133_Neeland_merged/
    Ignored:    data/Neeland_processed_data_1.h5ad
    Ignored:    data/Neeland_processed_data_2.h5ad
    Ignored:    data/Neeland_processed_data_3.h5ad
    Ignored:    data/intermediate_objects/.DS_Store
    Ignored:    data/updated_h5ad_files/
    Ignored:    output/.DS_Store
    Ignored:    renv/library/
    Ignored:    renv/staging/

Untracked files:
    Untracked:  analysis/cellxgene_submission.Rmd
    Untracked:  data/GOBP_CYTOKINE_MEDIATED_SIGNALING_PATHWAY.v2025.1.Hs.tsv
    Untracked:  data/cellxgene_cell_ontologies_ann_level_3.xlsx
    Untracked:  data/gencode.v44.primary_assembly.annotation.gtf

Unstaged changes:
    Modified:   .DS_Store
    Modified:   .gitignore
    Modified:   analysis/13.0_DGE_analysis_macrophages.Rmd
    Modified:   analysis/13.1_DGE_analysis_macro-alveolar.Rmd
    Modified:   analysis/13.2_DGE_analysis_macro-APOC2+.Rmd
    Modified:   analysis/13.3_DGE_analysis_macro-CCL.Rmd
    Modified:   analysis/13.4_DGE_analysis_macro-IFI27.Rmd
    Modified:   analysis/13.5_DGE_analysis_macro-lipid.Rmd
    Modified:   analysis/13.6_DGE_analysis_macro-monocyte-derived.Rmd
    Modified:   analysis/13.7_DGE_analysis_macro-proliferating.Rmd
    Modified:   analysis/14.0_DGE_analysis_CD4-T-cells.Rmd
    Modified:   analysis/14.1_DGE_analysis_CD8-T-cells.Rmd
    Modified:   analysis/14.2_DGE_analysis_DC-cells.Rmd
    Modified:   analysis/15.0_proportions_analysis_ann_level_1.Rmd
    Modified:   analysis/15.1_proportions_analysis_ann_level_3_non-macrophages.Rmd
    Modified:   analysis/15.2_proportions_analysis_ann_level_3_macrophages.Rmd
    Modified:   analysis/16.0_Figure_1.Rmd
    Modified:   analysis/16.1_Figure_2.Rmd
    Modified:   analysis/16.2_Figure_3.Rmd
    Modified:   analysis/16.3_Figure_4.Rmd
    Modified:   analysis/16.4_Figure_5.Rmd
    Modified:   analysis/16.5_Figure_6.Rmd
    Modified:   analysis/getting_started.Rmd
    Deleted:    output/Figure1A.jpeg
    Modified:   output/Figure1A.png
    Modified:   output/dge_analysis/macrophages/CAM.FIBROSIS.CF.IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.FIBROSIS.CF.IVAvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CAM.FIBROSIS.CF.LUMA_IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.FIBROSIS.CF.NO_MOD.SvCF.NO_MOD.M.csv
    Modified:   output/dge_analysis/macrophages/CAM.FIBROSIS.CF.NO_MODvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CAM.GO.CF.IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.GO.CF.IVAvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CAM.GO.CF.LUMA_IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.GO.CF.NO_MOD.SvCF.NO_MOD.M.csv
    Modified:   output/dge_analysis/macrophages/CAM.GO.CF.NO_MODvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CAM.HALLMARK.CF.IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.HALLMARK.CF.IVAvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CAM.HALLMARK.CF.LUMA_IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.HALLMARK.CF.NO_MOD.SvCF.NO_MOD.M.csv
    Modified:   output/dge_analysis/macrophages/CAM.HALLMARK.CF.NO_MODvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CAM.REACTOME.CF.IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.REACTOME.CF.IVAvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CAM.REACTOME.CF.LUMA_IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.REACTOME.CF.NO_MOD.SvCF.NO_MOD.M.csv
    Modified:   output/dge_analysis/macrophages/CAM.REACTOME.CF.NO_MODvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CAM.WP.CF.IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.WP.CF.IVAvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CAM.WP.CF.LUMA_IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CAM.WP.CF.NO_MOD.SvCF.NO_MOD.M.csv
    Modified:   output/dge_analysis/macrophages/CAM.WP.CF.NO_MODvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CF.IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CF.IVAvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/CF.LUMA_IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/CF.NO_MOD.SvCF.NO_MOD.M.csv
    Modified:   output/dge_analysis/macrophages/CF.NO_MODvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/ORA.GO.CF.IVAvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/ORA.GO.CF.NO_MOD.SvCF.NO_MOD.M.csv
    Modified:   output/dge_analysis/macrophages/ORA.GO.CF.NO_MODvNON_CF.CTRL.csv
    Modified:   output/dge_analysis/macrophages/ORA.HALLMARK.CF.IVAvCF.NO_MOD.csv
    Modified:   output/dge_analysis/macrophages/ORA.REACTOME.CF.NO_MODvNON_CF.CTRL.csv
    Modified:   output/pdf_figures/Figure_1.pdf
    Modified:   output/pdf_figures/Figure_4.pdf
    Modified:   output/pdf_figures/Figure_5.pdf
    Modified:   output/pdf_figures/Figure_6.pdf

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/16.7_Supplementary_Figures.Rmd) and HTML (docs/16.7_Supplementary_Figures.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
html 72ac736 Jovana Maksimovic 2025-09-10 Build site.
Rmd 83a4048 Jovana Maksimovic 2025-09-10 wflow_publish("analysis/16.7_Supplementary_Figures.Rmd")

Load libraries.

suppressPackageStartupMessages({
 library(SingleCellExperiment)
 library(edgeR)
 library(tidyverse)
 library(ggplot2)
 library(Seurat)
 library(glmGamPoi)
 library(dittoSeq)
 library(here)
 library(clustree)
 library(patchwork)
 library(AnnotationDbi)
 library(org.Hs.eg.db)
 library(glue)
 library(speckle)
 library(tidyHeatmap)
 library(paletteer)
 library(dsb)
 library(ggh4x)
  library(readxl)
  library(gt)
})

source(here("code/utility.R"))

Load data

files <- list.files(here("data/C133_Neeland_merged"),
                    pattern = "C133_Neeland_full_clean.*(t_cells|other_cells)_annotated_diet.SEU.rds",
                    full.names = TRUE)

seuLst <- lapply(files, function(f) readRDS(f))

seu <- merge(seuLst[[1]], 
             y = seuLst[[2]])
seu
An object of class Seurat 
19973 features across 29198 samples within 1 assay 
Active assay: RNA (19973 features, 0 variable features)
            used   (Mb) gc trigger   (Mb) limit (Mb)  max used   (Mb)
Ncells  10081079  538.4   18292021  976.9         NA  13248671  707.6
Vcells 135391886 1033.0  371693820 2835.8      65536 325547687 2483.8

Prepare figure panels

seu@meta.data %>% 
    data.frame %>% 
    dplyr::select(ann_level_1) %>%
    group_by(ann_level_1) %>% 
    count() %>%
    arrange(-n) %>%
    dplyr::rename(cell = ann_level_1) -> cell_freq

cell_freq
# A tibble: 14 × 2
# Groups:   cell [14]
   cell                      n
   <chr>                 <int>
 1 CD8 T cells            7268
 2 CD4 T cells            5482
 3 DC cells               4094
 4 B cells                3769
 5 monocytes              3225
 6 epithelial cells       1847
 7 innate lymphocyte      1481
 8 NK cells                695
 9 neutrophils             477
10 proliferating T/NK      250
11 gamma delta T cells     244
12 dividing innate cells   176
13 mast cells               99
14 NK-T cells               91
files <- list.files(here("data/intermediate_objects"),
            pattern = ".*all_samples", 
            full.names = TRUE) 
files <- files[!str_detect(files, "macro")]

cutoff <- 0.05 
cont_name <- "CF.NO_MODvNON_CF.CTRL"  
lfc_cutoff <- 0
suffix <- ".all_samples.fit.rds"
  
get_deg_data(files, cont_name, cell_freq, treat_lfc = lfc_cutoff,
             suffix = suffix) -> dat
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
bind_rows(lapply(files, function(f){
  deg_results <- readRDS(f)
  lrt <- glmLRT(deg_results$fit, 
                contrast = deg_results$contr[,cont_name])
  tmp <- cbind(summary(decideTests(lrt, p.value = cutoff)) %>% data.frame,
                    cell = str_extract(basename(f), "^[^.]+"))
  tmp
})) -> dat_deg
dat_deg %>% 
  left_join(cell_freq) -> dat_deg

pal_dt <- c(paletteer::paletteer_d("RColorBrewer::Set1")[2:1], "grey") 

dat_deg %>%
  dplyr::filter(Var1 != "NotSig") %>%
  ggplot(aes(x = fct_reorder(cell, -n), y = Freq, fill = Var1)) +
  geom_col(position = "dodge") +
  scale_fill_manual(values = pal_dt) +
  theme_classic() +
  theme(legend.position = "top") +
  geom_text(aes(label = Freq), 
            position = position_dodge(width = 0.9),
            vjust = -0.5,
            size = 2.5) +
  labs(x = "Cell Type",
       y = "No. DEG (FDR < 0.05)",
       fill = "Direction") -> deg_barplot

deg_barplot

Version Author Date
72ac736 Jovana Maksimovic 2025-09-10
get_deg_data(files, cont_name, cell_freq, treat_lfc = lfc_cutoff,
             suffix = suffix, cutoff = 1) -> dat_all
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
dat_all %>% 
  left_join(cell_freq) %>%
  mutate(Direction = as.factor(ifelse(sig == -1, "Down",
                                      ifelse(sig == 1, "Up", "N.S."))),
         cell = fct_reorder(cell, -n)) -> dat_all

ggplot(dat_all, aes(x = logFC, y = -log10(FDR), colour = Direction)) + 
  geom_point(size = 0.5) + 
  facet_wrap(~cell, ncol = 4) + 
  theme_classic() +
  scale_color_manual(values = pal_dt[c(1,3,2)]) +
  ggrepel::geom_text_repel(data = dat_all[dat_all$sig != 0,], 
                           aes(label = gene), size = 2) -> volc_plot

volc_plot

Version Author Date
72ac736 Jovana Maksimovic 2025-09-10
dat_all %>%
  dplyr::select(-sig, -n, -Direction) %>%
  dplyr::filter(FDR < cutoff) %>%
  group_by(cell) %>%
  arrange(FDR, .by_group = TRUE) %>% 
  gt() %>%
  tab_header(title = "Differentially expressed genes by cell type",
             subtitle = cont_name) %>%
  tab_style(cell_text(size = px(10)),
            locations = list(cells_body())) %>%
  tab_style(cell_text(size = px(12), weight = "bold"),
            locations = list(cells_column_labels())) %>%
  tab_style(cell_text(size = px(12), weight = "bold"),
            locations = list(cells_row_groups())) -> tab

tab
Differentially expressed genes by cell type
CF.NO_MODvNON_CF.CTRL
gene logFC FDR
CD8 T cells
ADGRG1 2.5021012 0.00758679
SULF2 -1.9413497 0.01467086
CTSB 1.7399768 0.01467086
REL 0.8640961 0.03411823
ANKRD36C 1.1218820 0.03411823
DC cells
CEACAM4 2.2610736 0.02775101
SLC16A10 2.9741874 0.02775101
ALDH1A2 4.8973876 0.02775101
TGM2 3.6728039 0.02868435
CCL5 3.3089485 0.04566559

Supplementary Figure 3

layout <- "
A
B
C
"

(wrap_elements(deg_barplot + theme(axis.title.x = element_blank(),
                                   legend.text = element_text(size = 8),
                                   plot.margin = margin(rep(0,4))))) +
  wrap_elements(volc_plot + theme(strip.text = element_text(size = 7),
                                   plot.margin = margin(rep(0,4)))) +
  wrap_table(tab, panel = "full") +
  plot_layout(design = layout) +
  plot_annotation(tag_levels = "A")  &
  theme(plot.tag = element_text(size = 24,
                                face = "bold",
                                family = "arial"))

Version Author Date
72ac736 Jovana Maksimovic 2025-09-10

Prepare figure panels

seu@meta.data %>% 
    data.frame %>% 
    dplyr::select(ann_level_1) %>%
    group_by(ann_level_1) %>% 
    count() %>%
    arrange(-n) %>%
    dplyr::rename(cell = ann_level_1) -> cell_freq

cell_freq
# A tibble: 14 × 2
# Groups:   cell [14]
   cell                      n
   <chr>                 <int>
 1 CD8 T cells            7268
 2 CD4 T cells            5482
 3 DC cells               4094
 4 B cells                3769
 5 monocytes              3225
 6 epithelial cells       1847
 7 innate lymphocyte      1481
 8 NK cells                695
 9 neutrophils             477
10 proliferating T/NK      250
11 gamma delta T cells     244
12 dividing innate cells   176
13 mast cells               99
14 NK-T cells               91
files <- list.files(here("data/intermediate_objects"),
            pattern = ".*CF_samples", 
            full.names = TRUE) 
files <- files[!str_detect(files, "macro")]

cutoff <- 0.05 
cont_name <- "CF.NO_MOD.SvCF.NO_MOD.M"  
lfc_cutoff <- 0
suffix <- ".CF_samples.fit.rds"
  
get_deg_data(files, cont_name, cell_freq, treat_lfc = lfc_cutoff,
             suffix = suffix) -> dat
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
bind_rows(lapply(files, function(f){
  deg_results <- readRDS(f)
  lrt <- glmLRT(deg_results$fit, 
                contrast = deg_results$contr[,cont_name])
  tmp <- cbind(summary(decideTests(lrt, p.value = cutoff)) %>% data.frame,
                    cell = str_extract(basename(f), "^[^.]+"))
  tmp
})) -> dat_deg
dat_deg %>% 
  left_join(cell_freq) -> dat_deg

pal_dt <- c(paletteer::paletteer_d("RColorBrewer::Set1")[2:1], "grey") 

dat_deg %>%
  dplyr::filter(Var1 != "NotSig") %>%
  ggplot(aes(x = fct_reorder(cell, -n), y = Freq, fill = Var1)) +
  geom_col(position = "dodge") +
  scale_fill_manual(values = pal_dt) +
  theme_classic() +
  theme(legend.position = "top") +
  geom_text(aes(label = Freq), 
            position = position_dodge(width = 0.9),
            vjust = -0.5,
            size = 2.5) +
  labs(x = "Cell Type",
       y = "No. DEG (FDR < 0.05)",
       fill = "Direction") -> deg_barplot

deg_barplot

Version Author Date
72ac736 Jovana Maksimovic 2025-09-10
get_deg_data(files, cont_name, cell_freq, treat_lfc = lfc_cutoff,
             suffix = suffix, cutoff = 1) -> dat_all
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
Zero log2-FC threshold detected. Switch to glmLRT() instead. 
dat_all %>% 
  left_join(cell_freq) %>%
  mutate(Direction = as.factor(ifelse(sig == -1, "Down",
                                      ifelse(sig == 1, "Up", "N.S."))),
         cell = fct_reorder(cell, -n)) -> dat_all

ggplot(dat_all, aes(x = logFC, y = -log10(FDR), colour = Direction)) + 
  geom_point(size = 0.5) + 
  facet_wrap(~cell, ncol = 4) + 
  theme_classic() +
  scale_color_manual(values = pal_dt[c(1,3,2)]) +
  ggrepel::geom_text_repel(data = dat_all[dat_all$sig != 0,], 
                           aes(label = gene), size = 2) -> volc_plot

volc_plot

Version Author Date
72ac736 Jovana Maksimovic 2025-09-10
dat_all %>%
  dplyr::select(-sig, -n, -Direction) %>%
  dplyr::filter(FDR < cutoff) %>%
  group_by(cell) %>%
  arrange(FDR, .by_group = TRUE) %>% 
  gt() %>%
  tab_header(title = "Differentially expressed genes by cell type",
             subtitle = cont_name) %>%
  tab_style(cell_text(size = px(10)),
            locations = list(cells_body())) %>%
  tab_style(cell_text(size = px(12), weight = "bold"),
            locations = list(cells_column_labels())) %>%
  tab_style(cell_text(size = px(12), weight = "bold"),
            locations = list(cells_row_groups())) -> tab

tab
Differentially expressed genes by cell type
CF.NO_MOD.SvCF.NO_MOD.M
gene logFC FDR
CD8 T cells
IER2 -0.6465572 0.0152957508
CMC1 1.2609872 0.0184005852
MSMO1 -1.1619299 0.0368874786
FBLN5 -1.9805997 0.0399874695
CST7 1.0002086 0.0399874695
CD4 T cells
AREG -3.6207178 0.0382842050
DC cells
FABP4 3.0135376 0.0009380894
SCD 2.9594586 0.0268390379

Supplementary Figure 5

layout <- "
A
B
C
"

(wrap_elements(deg_barplot + theme(axis.title.x = element_blank(),
                                   legend.text = element_text(size = 8),
                                   plot.margin = margin(rep(0,4))))) +
  wrap_elements(volc_plot + theme(strip.text = element_text(size = 7),
                                   plot.margin = margin(rep(0,4)))) +
  wrap_table(tab, panel = "full") +
  plot_layout(design = layout) +
  plot_annotation(tag_levels = "A")  &
  theme(plot.tag = element_text(size = 24,
                                face = "bold",
                                family = "arial"))

Version Author Date
72ac736 Jovana Maksimovic 2025-09-10

Prepare figure panels

file <- here("data", 
             "intermediate_objects",
             "macrophages.all_samples.fit.rds") 

deg_results <- readRDS(file = file)

contr <- deg_results$contr[,1:2]

lapply(1:ncol(contr), function(i) {
  lrt <- glmLRT(deg_results$fit, contrast = contr[,i])
  topTags(lrt, n = Inf) %>%
    data.frame %>%
    rownames_to_column(var = "Symbol") %>%
    dplyr::arrange(Symbol) %>%
    dplyr::rename_with(~ paste0(.x, ".", i))
}) %>% bind_cols -> all_lrt
all_lrt %>%
  mutate(IVA = ifelse(FDR.1 < 0.05 & FDR.2 < 0.05, "#FF6B6B",
                      ifelse(FDR.1 < 0.05 & FDR.2 >= 0.05, "#CC8E00", 
                             ifelse(FDR.1 >= 0.05 & FDR.2 < 0.05, "#20A4A4",
                                    "lightgrey")))) -> all_lrt

ggplot(all_lrt, aes(x = logFC.1,
                    y = logFC.2)) +
  geom_point(data = subset(all_lrt, IVA %in% "lightgrey"), 
             aes(colour = "lightgrey"),
             alpha = 0.25) +
  geom_point(data = subset(all_lrt, IVA %in% "#20A4A4"), 
             aes(colour = "#20A4A4"),
             alpha = 0.5) +
  geom_point(data = subset(all_lrt, IVA %in% "#CC8E00"), 
             aes(colour = "#CC8E00"),
             alpha = 0.5) +
  geom_point(data = subset(all_lrt, IVA %in% "#FF6B6B"), 
             aes(colour = "#FF6B6B")) +
  ggrepel::geom_text_repel(data = subset(all_lrt, (IVA %in% "#20A4A4")),
                           aes(x = logFC.1, y = logFC.2,
                               label = Symbol.1),
                           size = 2, colour = "#20A4A4", max.overlaps = 5) +
    ggrepel::geom_text_repel(data = subset(all_lrt, (IVA %in% "#CC8E00")),
                           aes(x = logFC.1, y = logFC.2,
                               label = Symbol.1),
                           size = 2, colour = "#CC8E00", max.overlaps = 5) +
    ggrepel::geom_text_repel(data = subset(all_lrt, (IVA %in% "#FF6B6B")), 
                           aes(x = logFC.1, y = logFC.2, 
                               label = Symbol.1), 
                           size = 2, colour = "#FF6B6B", max.overlaps = Inf) +
  geom_hline(yintercept = 0, linetype = "dashed", colour = "darkgrey") +
  geom_vline(xintercept = 0, linetype = "dashed", colour = "darkgrey") +
  labs(x = "log2FC CF.NO_MODvNON_CF.CTRL",
       y = "log2FC CF.IVAvNON_CF.CTRL") +
  scale_colour_identity(guide = "legend",
                        breaks = c("#FF6B6B", "#20A4A4", "#CC8E00","lightgrey"),
                        labels = c("Sig. in both", 
                                   "Sig. in CF.IVAvNON_CF.CTRL", 
                                   "Sig. in CF.NO_MODvNON_CF.CTRL",
                                   "N.S. in either"),
                        name = "Statistical significance") +
  theme_classic() +
  theme(legend.position = "right",
        legend.direction = "vertical") -> p1

p1

Version Author Date
72ac736 Jovana Maksimovic 2025-09-10
Hs.c2.all <- convert_gmt_to_list(here("data/c2.all.v2024.1.Hs.entrez.gmt"))
Hs.h.all <- convert_gmt_to_list(here("data/h.all.v2024.1.Hs.entrez.gmt"))
Hs.c5.all <- convert_gmt_to_list(here("data/c5.all.v2024.1.Hs.entrez.gmt"))

fibrosis <- create_custom_gene_lists_from_file(here("data/fibrosis_gene_sets.csv"))
# add fibrosis sets from REACTOME and WIKIPATHWAYS
fibrosis <- c(lapply(fibrosis, function(l) l[!is.na(l)]),
              Hs.c2.all[str_detect(names(Hs.c2.all), "FIBROSIS")])

gene_sets_list <- list(HALLMARK = Hs.h.all,
                       GO = Hs.c5.all,
                       REACTOME = Hs.c2.all[str_detect(names(Hs.c2.all), "REACTOME")],
                       WP = Hs.c2.all[str_detect(names(Hs.c2.all), "^WP")],
                       FIBROSIS = fibrosis)
num <- 10

hallmark <- rbind(read_csv(file = here("output",
                                       "dge_analysis",
                                       "macrophages",
                                       "ORA.HALLMARK.CF.IVAvNON_CF.CTRL.csv")) %>%
                    slice_head(n = num) %>%
                    mutate(contrast = "CF.IVAvNON_CF.CTRL",
                           Rank = 1:min(num, n())),
                  read_csv(file = here("output",
                                       "dge_analysis",
                                       "macrophages",
                                       "ORA.HALLMARK.CF.NO_MODvNON_CF.CTRL.csv")) %>%
                    slice_head(n = num) %>%
                    mutate(contrast = "CF.NO_MODvNON_CF.CTRL",
                           Rank = 1:min(num, n()))) %>%
  mutate(dups = duplicated(Set) | duplicated(Set, fromLast = TRUE)) %>%
  mutate(Set = str_wrap(str_replace_all(Set, "_", " "), width = 75),
         Set = str_remove_all(Set, "GO |REACTOME |HALLMARK |WP "))

pal <- c(paletteer::paletteer_d("RColorBrewer::Set1")[2:1], "grey") 

sub <- 1:10
hallmark[sub, ]%>%
  ggplot(aes(x = -log10(FDR), y = -Rank, colour = GR)) +
  geom_point(aes(size = N)) +
  geom_point(shape = 8, colour = "white", size = 3,
             data = hallmark[sub,][hallmark$dups[sub],],
             aes(x = -log10(FDR), y = -Rank)) +
  geom_vline(xintercept = -log10(0.05),
             linetype = "dashed")  +
  facet_wrap(~contrast) +
  scale_colour_viridis_c(option = "cividis") +
  scale_y_continuous(breaks = -hallmark$Rank[sub], 
                     labels = hallmark$Set[sub]) +
  labs(y = "Hallmark Gene Set", size = "Set size") +
  theme_classic(base_size = 10) -> p2

sub <- 11:20
hallmark[sub, ]%>%
  ggplot(aes(x = -log10(FDR), y = -Rank, colour = GR)) +
  geom_point(aes(size = N)) +
  geom_point(shape = 8, colour = "white", size = 3,
             data = hallmark[sub,][hallmark$dups[sub],],
             aes(x = -log10(FDR), y = -Rank)) +
  geom_vline(xintercept = -log10(0.05),
             linetype = "dashed")  +
    facet_wrap(~contrast) +
  scale_colour_viridis_c(option = "cividis") +
  scale_y_continuous(breaks = -hallmark$Rank[sub], 
                     labels = hallmark$Set[sub]) +
  labs(y = "Hallmark Gene Set", size = "Set size") +
  theme_classic(base_size = 10) -> p3

p2 / p3

Version Author Date
72ac736 Jovana Maksimovic 2025-09-10

Supplementary Figure 6

layout <- "
AAA
AAA
BBB
CCC
"

wrap_elements(p1 + theme(text = element_text(size = 8))) + 
  wrap_elements(p2 + theme(text = element_text(size = 8),
                           legend.margin = margin(-0.5,0,0,0, unit="lines"),
                           legend.key.size = unit(1, "lines"))) + 
  wrap_elements(p3 + theme(text = element_text(size = 8),
                           legend.margin = margin(-0.5,0,0,0, unit="lines"),
                           legend.key.size = unit(1, "lines"))) + 
  plot_layout(design = layout) +
  plot_annotation(tag_levels = "A")   &
  theme(plot.tag = element_text(size = 16,
                                face = "bold",
                                family = "arial"))

Version Author Date
72ac736 Jovana Maksimovic 2025-09-10

Session info


sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 15.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Australia/Melbourne
tzcode source: internal

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

other attached packages:
 [1] gt_1.0.0                    readxl_1.4.3               
 [3] ggh4x_0.3.1                 dsb_1.0.3                  
 [5] paletteer_1.6.0             tidyHeatmap_1.8.1          
 [7] speckle_1.2.0               glue_1.8.0                 
 [9] org.Hs.eg.db_3.18.0         AnnotationDbi_1.64.1       
[11] patchwork_1.3.1             clustree_0.5.1             
[13] ggraph_2.2.0                here_1.0.1                 
[15] dittoSeq_1.14.2             glmGamPoi_1.14.3           
[17] SeuratObject_4.1.4          Seurat_4.4.0               
[19] lubridate_1.9.3             forcats_1.0.0              
[21] stringr_1.5.1               dplyr_1.1.4                
[23] purrr_1.0.2                 readr_2.1.5                
[25] tidyr_1.3.1                 tibble_3.2.1               
[27] ggplot2_3.5.2               tidyverse_2.0.0            
[29] edgeR_4.0.15                limma_3.58.1               
[31] SingleCellExperiment_1.24.0 SummarizedExperiment_1.32.0
[33] Biobase_2.62.0              GenomicRanges_1.54.1       
[35] GenomeInfoDb_1.38.6         IRanges_2.36.0             
[37] S4Vectors_0.40.2            BiocGenerics_0.48.1        
[39] MatrixGenerics_1.14.0       matrixStats_1.2.0          
[41] workflowr_1.7.1            

loaded via a namespace (and not attached):
  [1] fs_1.6.6                spatstat.sparse_3.0-3   bitops_1.0-7           
  [4] httr_1.4.7              RColorBrewer_1.1-3      doParallel_1.0.17      
  [7] tools_4.3.3             sctransform_0.4.1       utf8_1.2.4             
 [10] R6_2.5.1                lazyeval_0.2.2          uwot_0.1.16            
 [13] GetoptLong_1.0.5        withr_3.0.0             sp_2.1-3               
 [16] gridExtra_2.3           progressr_0.14.0        cli_3.6.5              
 [19] spatstat.explore_3.2-6  labeling_0.4.3          prismatic_1.1.1        
 [22] sass_0.4.10             spatstat.data_3.0-4     ggridges_0.5.6         
 [25] pbapply_1.7-2           parallelly_1.37.0       rstudioapi_0.15.0      
 [28] RSQLite_2.3.5           generics_0.1.3          shape_1.4.6            
 [31] vroom_1.6.5             ica_1.0-3               spatstat.random_3.2-2  
 [34] dendextend_1.17.1       Matrix_1.6-5            fansi_1.0.6            
 [37] abind_1.4-5             lifecycle_1.0.4         whisker_0.4.1          
 [40] yaml_2.3.8              SparseArray_1.2.4       Rtsne_0.17             
 [43] grid_4.3.3              blob_1.2.4              promises_1.2.1         
 [46] crayon_1.5.2            miniUI_0.1.1.1          lattice_0.22-5         
 [49] cowplot_1.1.3           KEGGREST_1.42.0         pillar_1.9.0           
 [52] knitr_1.50              ComplexHeatmap_2.18.0   rjson_0.2.21           
 [55] future.apply_1.11.1     codetools_0.2-19        leiden_0.4.3.1         
 [58] getPass_0.2-4           data.table_1.15.0       vctrs_0.6.5            
 [61] png_0.1-8               cellranger_1.1.0        gtable_0.3.6           
 [64] rematch2_2.1.2          cachem_1.0.8            xfun_0.52              
 [67] S4Arrays_1.2.0          mime_0.12               tidygraph_1.3.1        
 [70] survival_3.5-8          pheatmap_1.0.12         iterators_1.0.14       
 [73] statmod_1.5.0           ellipsis_0.3.2          fitdistrplus_1.1-11    
 [76] ROCR_1.0-11             nlme_3.1-164            bit64_4.0.5            
 [79] RcppAnnoy_0.0.22        rprojroot_2.0.4         bslib_0.6.1            
 [82] irlba_2.3.5.1           KernSmooth_2.23-22      colorspace_2.1-0       
 [85] DBI_1.2.1               tidyselect_1.2.1        processx_3.8.3         
 [88] bit_4.0.5               compiler_4.3.3          git2r_0.33.0           
 [91] xml2_1.3.6              DelayedArray_0.28.0     plotly_4.10.4          
 [94] scales_1.3.0            lmtest_0.9-40           callr_3.7.3            
 [97] digest_0.6.34           goftest_1.2-3           spatstat.utils_3.0-4   
[100] rmarkdown_2.29          XVector_0.42.0          htmltools_0.5.8.1      
[103] pkgconfig_2.0.3         fastmap_1.1.1           rlang_1.1.6            
[106] GlobalOptions_0.1.2     htmlwidgets_1.6.4       shiny_1.8.0            
[109] farver_2.1.1            jquerylib_0.1.4         zoo_1.8-12             
[112] jsonlite_1.8.8          mclust_6.1              RCurl_1.98-1.14        
[115] magrittr_2.0.3          GenomeInfoDbData_1.2.11 munsell_0.5.0          
[118] Rcpp_1.0.12             viridis_0.6.5           reticulate_1.42.0      
[121] stringi_1.8.3           zlibbioc_1.48.0         MASS_7.3-60.0.1        
[124] plyr_1.8.9              parallel_4.3.3          listenv_0.9.1          
[127] ggrepel_0.9.5           deldir_2.0-2            Biostrings_2.70.2      
[130] graphlayouts_1.1.0      splines_4.3.3           tensor_1.5             
[133] hms_1.1.3               circlize_0.4.15         locfit_1.5-9.8         
[136] ps_1.7.6                igraph_2.0.1.1          spatstat.geom_3.2-8    
[139] reshape2_1.4.4          evaluate_0.23           renv_1.1.4             
[142] BiocManager_1.30.22     tzdb_0.4.0              foreach_1.5.2          
[145] tweenr_2.0.3            httpuv_1.6.14           RANN_2.6.1             
[148] polyclip_1.10-6         future_1.33.1           clue_0.3-65            
[151] scattermore_1.2         ggforce_0.4.2           xtable_1.8-4           
[154] later_1.3.2             viridisLite_0.4.2       memoise_2.0.1          
[157] cluster_2.1.6           timechange_0.3.0        globals_0.16.2