Skip to contents

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.3.0 (2023-04-21)
## Platform: x86_64-apple-darwin22.4.0 (64-bit)
## Running under: macOS 14.2.1
## 
## Matrix products: default
## BLAS:   /Users/gabrielhoffman/prog/R-4.3.0/lib/libRblas.dylib 
## LAPACK: /usr/local/Cellar/r/4.3.2/lib/R/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: America/New_York
## tzcode source: internal
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] org.Hs.eg.db_3.17.0       AnnotationDbi_1.62.1     
##  [3] IRanges_2.34.1            S4Vectors_0.38.1         
##  [5] msigdbr_7.5.1             kableExtra_1.3.4         
##  [7] tweeDEseqCountData_1.38.0 Biobase_2.60.0           
##  [9] BiocGenerics_0.46.0       variancePartition_1.32.5 
## [11] BiocParallel_1.34.2       ggplot2_3.4.4            
## [13] edgeR_3.42.4              zenith_1.5.3             
## [15] limma_3.56.2              knitr_1.43               
## 
## loaded via a namespace (and not attached):
##   [1] rstudioapi_0.15.0           jsonlite_1.8.5             
##   [3] magrittr_2.0.3              farver_2.1.1               
##   [5] nloptr_2.0.3                rmarkdown_2.22             
##   [7] fs_1.6.2                    zlibbioc_1.46.0            
##   [9] ragg_1.2.5                  vctrs_0.6.3                
##  [11] memoise_2.0.1               minqa_1.2.5                
##  [13] RCurl_1.98-1.12             webshot_0.5.4              
##  [15] htmltools_0.5.5             S4Arrays_1.2.0             
##  [17] progress_1.2.2              curl_5.0.0                 
##  [19] broom_1.0.5                 sass_0.4.6                 
##  [21] KernSmooth_2.23-21          bslib_0.4.2                
##  [23] desc_1.4.2                  plyr_1.8.8                 
##  [25] pbkrtest_0.5.2              cachem_1.0.8               
##  [27] lifecycle_1.0.3             iterators_1.0.14           
##  [29] pkgconfig_2.0.3             Matrix_1.6-5               
##  [31] R6_2.5.1                    fastmap_1.1.1              
##  [33] GenomeInfoDbData_1.2.10     rbibutils_2.2.13           
##  [35] MatrixGenerics_1.12.0       digest_0.6.33              
##  [37] numDeriv_2016.8-1.1         colorspace_2.1-0           
##  [39] rprojroot_2.0.3             textshaping_0.3.6          
##  [41] GenomicRanges_1.52.0        RSQLite_2.3.1              
##  [43] labeling_0.4.2              filelock_1.0.2             
##  [45] RcppZiggurat_0.1.6          fansi_1.0.4                
##  [47] httr_1.4.6                  abind_1.4-5                
##  [49] compiler_4.3.0              withr_2.5.0                
##  [51] bit64_4.0.5                 aod_1.3.2                  
##  [53] backports_1.4.1             DBI_1.1.3                  
##  [55] highr_0.10                  gplots_3.1.3               
##  [57] MASS_7.3-60                 DelayedArray_0.26.3        
##  [59] corpcor_1.6.10              gtools_3.9.4               
##  [61] caTools_1.18.2              tools_4.3.0                
##  [63] remaCor_0.0.18              glue_1.6.2                 
##  [65] nlme_3.1-162                grid_4.3.0                 
##  [67] reshape2_1.4.4              generics_0.1.3             
##  [69] gtable_0.3.3                tidyr_1.3.0                
##  [71] hms_1.1.3                   xml2_1.3.4                 
##  [73] utf8_1.2.3                  XVector_0.40.0             
##  [75] pillar_1.9.0                stringr_1.5.0              
##  [77] babelgene_22.9              splines_4.3.0              
##  [79] dplyr_1.1.2                 BiocFileCache_2.8.0        
##  [81] lattice_0.21-8              bit_4.0.5                  
##  [83] annotate_1.78.0             tidyselect_1.2.0           
##  [85] locfit_1.5-9.7              Biostrings_2.68.1          
##  [87] SummarizedExperiment_1.30.1 svglite_2.1.1              
##  [89] RhpcBLASctl_0.23-42         xfun_0.39                  
##  [91] matrixStats_1.0.0           KEGGgraph_1.60.0           
##  [93] stringi_1.7.12              yaml_2.3.7                 
##  [95] boot_1.3-28.1               evaluate_0.21              
##  [97] codetools_0.2-19            tibble_3.2.1               
##  [99] Rgraphviz_2.44.0            graph_1.78.0               
## [101] cli_3.6.1                   xtable_1.8-4               
## [103] systemfonts_1.0.4           Rdpack_2.4                 
## [105] munsell_0.5.0               jquerylib_0.1.4            
## [107] Rcpp_1.0.11                 GenomeInfoDb_1.36.1        
## [109] EnvStats_2.7.0              dbplyr_2.3.2               
## [111] png_0.1-8                   Rfast_2.0.7                
## [113] XML_3.99-0.14               parallel_4.3.0             
## [115] pkgdown_2.0.7               blob_1.2.4                 
## [117] prettyunits_1.1.1           bitops_1.0-7               
## [119] lme4_1.1-35.1               viridisLite_0.4.2          
## [121] mvtnorm_1.2-2               GSEABase_1.62.0            
## [123] lmerTest_3.1-3              scales_1.2.1               
## [125] purrr_1.0.2                 crayon_1.5.2               
## [127] fANCOVA_0.6-1               rlang_1.1.1                
## [129] rvest_1.0.3                 EnrichmentBrowser_2.30.1   
## [131] KEGGREST_1.40.0