Skip to contents

Introduction

This vignette demonstrates a typical workflow for differential expression, GO over-representation analysis (GO-ORA), pathway overlap network generation, and pathway module interpretation using GDSCtools.

The workflow includes:

  1. Differential expression analysis
  2. GO enrichment analysis
  3. Pathway overlap network construction
  4. Leiden clustering of GO pathways
  5. Word cloud generation
  6. Extraction of biologically related GO modules

Load Packages

library(GDSCtools)
library(org.Mm.eg.db)

Input Data

This workflow assumes a Seurat object named seurat_obj containing single-cell RNA-seq data.

The identities being compared in this example are:

  • Car
  • Bleo

across selected fibroblast clusters.

Differential Expression Analysis

Run differential expression analysis across selected clusters.

de_results <- run_cluster_de(
  obj        = seurat_obj,
  clusters   = c("Fibroblast 1", "Fibroblast 2"),
  cluster_col = "final_celltypes",
  ident1     = "Car",
  ident2     = "Bleo"
)

Write differential expression results to disk.

write_de_results(
  de_results,
  outSubDir = "results/DE/",
  type = "DE",
  split_direction = FALSE
)

GO Over-Representation Analysis

Define the gene universe.

universe <- rownames(seurat_obj)

Run GO enrichment analysis using Biological Process ontology and save results.

go_results <- run_go_ora(
  de_list   = de_results,
  org_db    = org.Mm.eg.db,
  universe  = universe,
  ont       = "BP",
  outputDir = "results/GO/"
)

Export GO enrichment results.

write_de_results(
  go_results,
  outSubDir = "results/GO/",
  type = "GO",
  split_direction = FALSE
)

Pathway Overlap Network Analysis

Generate pathway overlap networks from GO enrichment results. This function will automatically generate a folder called “network/” in your base_outdir

net_results <- run_comparison_networks(
  go_list     = go_results,
  de_list     = de_results,
  comp_label  = "Car_vs_Bleo",
  base_outdir = "results/"
)

The resulting networks:

  • represent GO terms as nodes,
  • connect pathways sharing DE genes,
  • cluster pathways using Leiden community detection,
  • and identify higher-order biological programs.

Export GO Cluster Membership

Export GO terms and their associated Leiden clusters. This is not baked into the function above yet.

for (i in names(net_results)) {

  x <- net_results[[i]]$go_term_df

  cluster <- gsub("/", "_", i)

  name <- paste0(cluster, "_cluster_membership.csv")

  write.csv(
    x,
    file = paste0(
      outputDir,
      "CD206_Car_vs_Bleo/networks/",
      name
    )
  )
}

Generate Word Clouds

Generate cluster-specific pathway word clouds.

write_cluster_wordclouds_patchwork(
  net_list   = net_results,
  outputDir  = "results/",
  comparison = "Car_vs_Bleo"
)

These word clouds summarize dominant biological themes within each Leiden pathway module.

Inspect a Specific Biological Module

Extract all GO terms belonging to the same Leiden cluster as a target GO term.

For example, the extracellular matrix organization module:

ecm_terms <- write_cluster_results(
  net_result = net_results[["Fibroblast_1"]],
  go_term    = "extracellular matrix organization",
  outdir     = "results/Car_vs_Bleo/networks/"
)

This can help identify coordinated biological programs.

Session Information

sessionInfo()
#> R version 4.4.1 (2024-06-14)
#> Platform: aarch64-apple-darwin20
#> Running under: macOS Sonoma 14.6
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib 
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.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: America/New_York
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.37     desc_1.4.3        R6_2.6.1          fastmap_1.2.0    
#>  [5] xfun_0.53         cachem_1.1.0      knitr_1.50        htmltools_0.5.8.1
#>  [9] rmarkdown_2.29    lifecycle_1.0.4   cli_3.6.5         sass_0.4.10      
#> [13] pkgdown_2.1.3     textshaping_1.0.3 jquerylib_0.1.4   systemfonts_1.3.1
#> [17] compiler_4.4.1    rstudioapi_0.17.1 tools_4.4.1       ragg_1.5.0       
#> [21] bslib_0.9.0       evaluate_1.0.5    yaml_2.3.10       jsonlite_2.0.0   
#> [25] rlang_1.1.6       fs_1.6.6          htmlwidgets_1.6.4