SBGNview has collected pathway data and gene sets from the following databases: Reactome, PANTHER Pathway, SMPDB, MetaCyc and MetaCrop. These gene sets can be used for pathway enrichment analysis.
In this vignette, we will show you a complete pathway analysis workflow based on GAGE + SBGNview. Similar workflows have been documented in the gage package using GAGE + Pathview.
Please cite the following papers when using the open-source SBGNview package. This will help the project and our team:
Luo W, Brouwer C. Pathview: an R/Biocondutor package for pathway-based data integration and visualization. Bioinformatics, 2013, 29(14):1830-1831, doi: 10.1093/bioinformatics/btt285
Please also cite the GAGE paper when using the gage package:
Luo W, Friedman M, etc. GAGE: generally applicable gene set enrichment for pathway analysis. BMC Bioinformatics, 2009, 10, pp. 161, doi: 10.1186/1471-2105-10-161
Please see the Quick Start tutorial for installation instructions and quick start examples.
In this example, we analyze a RNA-Seq dataset of IFNg KO mice vs wild type mice. It contains normalized RNA-seq gene expression data described in Greer, Renee L., Xiaoxi Dong, et al, 2016.
The RNA abundance data was quantile normalized and log2 transformed, stored in a “SummarizedExperiment” object. SBGNview input user data (gene.data or cpd.data) can be either a numeric matrix or a vector, like those in pathview. In addition, it can be a “SummarizedExperiment” object, which is commonly used in BioConductor packages.
library(SBGNview)
library(SummarizedExperiment)
data("IFNg", "pathways.info")
count.data <- assays(IFNg)$counts
head(count.data)
wt.cols <- which(IFNg$group == "wt")
ko.cols <- which(IFNg$group == "ko")
ensembl.pathway <- sbgn.gsets(id.type = "ENSEMBL",
species = "mmu",
mol.type = "gene",
output.pathway.name = TRUE
)
head(ensembl.pathway[[2]])
if(!requireNamespace("gage", quietly = TRUE)) {
BiocManager::install("gage", update = FALSE)
}
library(gage)
degs <- gage(exprs = count.data,
gsets = ensembl.pathway,
ref = wt.cols,
samp = ko.cols,
compare = "paired" #"as.group"
)
head(degs$greater)[,3:5]
head(degs$less)[,3:5]
down.pathways <- row.names(degs$less)[1:10]
head(down.pathways)
The abundance values were log2 transformed. Here we calculate the fold change of IFNg KO group v.s. WT group.
ensembl.koVsWt <- count.data[,ko.cols]-count.data[,wt.cols]
head(ensembl.koVsWt)
#alternatively, we can also calculate mean fold changes per gene, which corresponds to gage analysis above with compare="as.group"
mean.wt <- apply(count.data[,wt.cols] ,1 ,"mean")
head(mean.wt)
mean.ko <- apply(count.data[,ko.cols],1,"mean")
head(mean.ko)
# The abundance values were on log scale. Hence fold change is their difference.
ensembl.koVsWt.m <- mean.ko - mean.wt
#load the SBGNview pathway collection, which may takes a few seconds.
data(sbgn.xmls)
down.pathways <- sapply(strsplit(down.pathways,"::"), "[", 1)
head(down.pathways)
sbgnview.obj <- SBGNview(
gene.data = ensembl.koVsWt,
gene.id.type = "ENSEMBL",
input.sbgn = down.pathways[1:2],#can be more than 2 pathways
output.file = "ifn.sbgnview.less",
show.pathway.name = TRUE,
max.gene.value = 2,
min.gene.value = -2,
mid.gene.value = 0,
node.sum = "mean",
output.format = c("png"),
font.size = 2.3,
org = "mmu",
text.length.factor.complex = 3,
if.scale.compartment.font.size = TRUE,
node.width.adjust.factor.compartment = 0.04
)
sbgnview.obj
Figure 4.1: SBGNview graph of the most down-regulated pathways in IFNg KO experiment
Figure 4.2: SBGNview graph of the second most down-regulated pathways in IFNg KO experiment
The ‘cancer.ds’ is a microarray dataset from a breast cancer study. The dataset was adopted from gage package and processed into a SummarizedExperiment object. It is used to demo SBGNview’s visualization ability.
data("cancer.ds")
sbgnview.obj <- SBGNview(
gene.data = cancer.ds,
gene.id.type = "ENTREZID",
input.sbgn = "R-HSA-877300",
output.file = "demo.SummarizedExperiment",
show.pathway.name = TRUE,
max.gene.value = 1,
min.gene.value = -1,
mid.gene.value = 0,
node.sum = "mean",
output.format = c("png"),
font.size = 2.3,
org = "hsa",
text.length.factor.complex = 3,
if.scale.compartment.font.size = TRUE,
node.width.adjust.factor.compartment = 0.04
)
sbgnview.obj
Figure 4.3: SBGNview of a cancer dataset gse16873
sessionInfo()
## R Under development (unstable) (2024-11-20 r87352)
## Platform: x86_64-apple-darwin20
## Running under: macOS Monterey 12.7.6
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.5-x86_64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
##
## locale:
## [1] C/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] gage_2.57.0 SummarizedExperiment_1.37.0
## [3] Biobase_2.67.0 GenomicRanges_1.59.1
## [5] GenomeInfoDb_1.43.1 IRanges_2.41.1
## [7] S4Vectors_0.45.2 BiocGenerics_0.53.3
## [9] generics_0.1.3 MatrixGenerics_1.19.0
## [11] matrixStats_1.4.1 SBGNview_1.21.0
## [13] SBGNview.data_1.21.0 pathview_1.47.0
## [15] knitr_1.49
##
## loaded via a namespace (and not attached):
## [1] KEGGREST_1.47.0 xfun_0.49 bslib_0.8.0
## [4] lattice_0.22-6 vctrs_0.6.5 tools_4.5.0
## [7] Rdpack_2.6.2 bitops_1.0-9 AnnotationDbi_1.69.0
## [10] RSQLite_2.3.8 blob_1.2.4 pkgconfig_2.0.3
## [13] Matrix_1.7-1 graph_1.85.0 lifecycle_1.0.4
## [16] GenomeInfoDbData_1.2.13 compiler_4.5.0 Biostrings_2.75.1
## [19] htmltools_0.5.8.1 sass_0.4.9 RCurl_1.98-1.16
## [22] yaml_2.3.10 GO.db_3.20.0 crayon_1.5.3
## [25] jquerylib_0.1.4 cachem_1.1.0 DelayedArray_0.33.2
## [28] org.Hs.eg.db_3.20.0 abind_1.4-8 digest_0.6.37
## [31] bookdown_0.41 rsvg_2.6.1 fastmap_1.2.0
## [34] grid_4.5.0 cli_3.6.3 SparseArray_1.7.2
## [37] magrittr_2.0.3 S4Arrays_1.7.1 XML_3.99-0.17
## [40] UCSC.utils_1.3.0 bit64_4.5.2 rmarkdown_2.29
## [43] XVector_0.47.0 httr_1.4.7 igraph_2.1.1
## [46] bit_4.5.0 png_0.1-8 memoise_2.0.1
## [49] evaluate_1.0.1 rbibutils_2.3 rlang_1.1.4
## [52] DBI_1.2.3 Rgraphviz_2.51.0 xml2_1.3.6
## [55] KEGGgraph_1.67.0 jsonlite_1.8.9 R6_2.5.1
## [58] zlibbioc_1.53.0