Zenith gene set testing after dream analysis

zenith performs gene set analysis on the result of differential expression using linear (mixed) modeling with dream by considering the correlation between gene expression traits. This package implements the camera method from the limma package proposed by Wu and Smyth (2012). zenith() is a simple extension of camera() to be compatible with linear (mixed) models implemented in dream().

Standard workflow

# Load packages
library(zenith)
library(edgeR)
library(variancePartition)
library(tweeDEseqCountData)
library(kableExtra)

# Load RNA-seq data from LCL's
data(pickrell)
geneCounts = exprs(pickrell.eset)
df_metadata = pData(pickrell.eset)

# Filter genes
# Note this is low coverage data, so just use as code example
dsgn = model.matrix(~ gender, df_metadata)
keep = filterByExpr(geneCounts, dsgn, min.count=5)

# Compute library size normalization
dge = DGEList(counts = geneCounts[keep,])
dge = calcNormFactors(dge)

# Estimate precision weights using voom
vobj = voomWithDreamWeights(dge, ~ gender, df_metadata)

# Apply dream analysis
fit = dream(vobj, ~ gender, df_metadata)
fit = eBayes(fit)

# Load get_MSigDB database, Hallmark genes
# use gene 'SYMBOL', or 'ENSEMBL' id
# use get_GeneOntology() to load Gene Ontology
msdb.gs = get_MSigDB("H", to="ENSEMBL")
   
# Run zenith analysis, and specific which coefficient to evaluate
res.gsa = zenith_gsa(fit, msdb.gs, 'gendermale', progressbar=FALSE )

# Show top gene sets: head(res.gsa)
kable_styling(kable(head(res.gsa), row.names=FALSE))
coef Geneset NGenes Correlation delta se p.less p.greater PValue Direction FDR
gendermale M5890_HALLMARK_TNFA_SIGNALING_VIA_NFKB 118 0.01 -0.9999389 0.1621467 0.0000000 1.0000000 0.0000000 Down 0.0000021
gendermale M5892_HALLMARK_CHOLESTEROL_HOMEOSTASIS 37 0.01 -1.0915363 0.2296170 0.0000055 0.9999945 0.0000110 Down 0.0002582
gendermale M5932_HALLMARK_INFLAMMATORY_RESPONSE 93 0.01 -0.7819360 0.1722474 0.0000120 0.9999880 0.0000241 Down 0.0003769
gendermale M5947_HALLMARK_IL2_STAT5_SIGNALING 105 0.01 -0.6493291 0.1672385 0.0001194 0.9998806 0.0002389 Down 0.0028066
gendermale M5930_HALLMARK_EPITHELIAL_MESENCHYMAL_TRANSITION 53 0.01 -0.6136470 0.2031832 0.0017867 0.9982133 0.0035735 Down 0.0335905
gendermale M5925_HALLMARK_E2F_TARGETS 109 0.01 0.4817527 0.1659106 0.9975051 0.0024949 0.0049898 Up 0.0355160
# for each cell type select 3 genesets with largest t-statistic
# and 1 geneset with the lowest
# Grey boxes indicate the gene set could not be evaluted because
#    to few genes were represented
plotZenithResults(res.gsa)

Session Info

## R version 4.4.2 (2024-10-31)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.1 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Etc/UTC
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] org.Hs.eg.db_3.20.0       AnnotationDbi_1.69.0     
##  [3] IRanges_2.41.1            S4Vectors_0.45.2         
##  [5] msigdbr_7.5.1             kableExtra_1.4.0         
##  [7] tweeDEseqCountData_1.44.0 Biobase_2.67.0           
##  [9] BiocGenerics_0.53.3       generics_0.1.3           
## [11] variancePartition_1.37.1  BiocParallel_1.41.0      
## [13] ggplot2_3.5.1             edgeR_4.5.1              
## [15] zenith_1.9.0              limma_3.63.2             
## [17] knitr_1.49               
## 
## loaded via a namespace (and not attached):
##   [1] rstudioapi_0.17.1           sys_3.4.3                  
##   [3] jsonlite_1.8.9              magrittr_2.0.3             
##   [5] farver_2.1.2                nloptr_2.1.1               
##   [7] rmarkdown_2.29              zlibbioc_1.52.0            
##   [9] vctrs_0.6.5                 memoise_2.0.1              
##  [11] minqa_1.2.8                 RCurl_1.98-1.16            
##  [13] htmltools_0.5.8.1           S4Arrays_1.7.1             
##  [15] progress_1.2.3              curl_6.0.1                 
##  [17] broom_1.0.7                 SparseArray_1.7.2          
##  [19] sass_0.4.9                  KernSmooth_2.23-24         
##  [21] bslib_0.8.0                 pbkrtest_0.5.3             
##  [23] plyr_1.8.9                  cachem_1.1.0               
##  [25] buildtools_1.0.0            lifecycle_1.0.4            
##  [27] iterators_1.0.14            pkgconfig_2.0.3            
##  [29] Matrix_1.7-1                R6_2.5.1                   
##  [31] fastmap_1.2.0               GenomeInfoDbData_1.2.13    
##  [33] rbibutils_2.3               MatrixGenerics_1.19.0      
##  [35] digest_0.6.37               numDeriv_2016.8-1.1        
##  [37] colorspace_2.1-1            GenomicRanges_1.59.1       
##  [39] RSQLite_2.3.8               labeling_0.4.3             
##  [41] filelock_1.0.3              RcppZiggurat_0.1.6         
##  [43] fansi_1.0.6                 httr_1.4.7                 
##  [45] abind_1.4-8                 compiler_4.4.2             
##  [47] withr_3.0.2                 bit64_4.5.2                
##  [49] aod_1.3.3                   backports_1.5.0            
##  [51] DBI_1.2.3                   gplots_3.2.0               
##  [53] MASS_7.3-61                 DelayedArray_0.33.2        
##  [55] corpcor_1.6.10              gtools_3.9.5               
##  [57] caTools_1.18.3              tools_4.4.2                
##  [59] remaCor_0.0.18              glue_1.8.0                 
##  [61] nlme_3.1-166                grid_4.4.2                 
##  [63] reshape2_1.4.4              gtable_0.3.6               
##  [65] tidyr_1.3.1                 hms_1.1.3                  
##  [67] xml2_1.3.6                  utf8_1.2.4                 
##  [69] XVector_0.47.0              pillar_1.9.0               
##  [71] stringr_1.5.1               babelgene_22.9             
##  [73] splines_4.4.2               dplyr_1.1.4                
##  [75] BiocFileCache_2.15.0        lattice_0.22-6             
##  [77] bit_4.5.0                   annotate_1.85.0            
##  [79] tidyselect_1.2.1            locfit_1.5-9.10            
##  [81] maketools_1.3.1             Biostrings_2.75.1          
##  [83] SummarizedExperiment_1.37.0 svglite_2.1.3              
##  [85] RhpcBLASctl_0.23-42         xfun_0.49                  
##  [87] statmod_1.5.0               matrixStats_1.4.1          
##  [89] KEGGgraph_1.67.0            stringi_1.8.4              
##  [91] UCSC.utils_1.3.0            yaml_2.3.10                
##  [93] boot_1.3-31                 evaluate_1.0.1             
##  [95] codetools_0.2-20            tibble_3.2.1               
##  [97] Rgraphviz_2.51.0            graph_1.85.0               
##  [99] cli_3.6.3                   RcppParallel_5.1.9         
## [101] systemfonts_1.1.0           xtable_1.8-4               
## [103] Rdpack_2.6.2                munsell_0.5.1              
## [105] jquerylib_0.1.4             Rcpp_1.0.13-1              
## [107] GenomeInfoDb_1.43.2         EnvStats_3.0.0             
## [109] dbplyr_2.5.0                png_0.1-8                  
## [111] Rfast_2.1.0                 XML_3.99-0.17              
## [113] parallel_4.4.2              blob_1.2.4                 
## [115] prettyunits_1.2.0           bitops_1.0-9               
## [117] lme4_1.1-35.5               viridisLite_0.4.2          
## [119] mvtnorm_1.3-2               GSEABase_1.69.0            
## [121] lmerTest_3.1-3              scales_1.3.0               
## [123] purrr_1.0.2                 crayon_1.5.3               
## [125] fANCOVA_0.6-1               rlang_1.1.4                
## [127] EnrichmentBrowser_2.37.0    KEGGREST_1.47.0