1 Introduction

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.

2 Citation

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

3 Installation and quick start

Please see the Quick Start tutorial for installation instructions and quick start examples.

4 Complete pathway analysis + visualization workflow

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.

4.1 Load the gene (RNA-seq) data

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")

4.2 Gene sets from SBGNview pathway collection

4.2.1 Load gene set for mouse with ENSEMBL gene IDs

ensembl.pathway <- sbgn.gsets(id.type = "ENSEMBL",
                              species = "mmu",
                              mol.type = "gene",
                              output.pathway.name = TRUE
                              )
head(ensembl.pathway[[2]])

4.2.2 Pathway or gene set analysis using GAGE

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)

4.3 Visualize perturbations in top SBGN pathways

4.3.1 Calculate fold changes or gene perturbations

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

4.3.2 Visualize pathway perturbations by SBNGview

#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
image/svg+xml cell membrane cytosol nucleoplasm extracellular lysosomal lumen integral component of lumenal side of endoplasmic reticulum membrane endoplasmic reticulum lumen p-STAT1 dimer bound to p-IFNGR1 MHC class II alpha/ beta dimer IFNG:p-IFNGR1:p-JAK1:IFNGR2:p-JAK2 IFNG:IFNGR1:JAK1:IFNGR2:p-JAK2 IFNG:IFNGR1:p-JAK1:IFNGR2:p-JAK2 IFNG:IFNGR1:JAK1:IFNGR2:p-JAK2:SOCS- 1/-3 IFNG:IFNGR complex IFNGR1:JAK1:INFG2:JAK2 p-STAT1(Y701) bound to p-IFNGR1 STAT1 bound to p-IFNGR1 p-STAT1:p-STAT1 dimer GAF bound to GAS promoter element p-STAT1 homodimer IFNG homodimer IFNG x[24-161] IFNGR1 P@Y440 x[18-489] JAK2 P@Y1007 x[1-1132] JAK1 P@Y x[1-1154] STAT1 x[1-750] P@S727 P@Y701 IFNGR2 x[28-337] HLA II beta chain HLA II alpha chain IFNG x[24-161] IFNGR1 P@Y440 x[18-489] JAK2 P@Y1007 x[1-1132] JAK1 P@Y x[1-1154] IFNGR2 x[28-337] IFNG x[24-161] JAK1 x[1-1154] JAK2 P@Y1007 x[1-1132] IFNGR2 x[28-337] IFNGR1 x[18-489] IFNG x[24-161] JAK2 P@Y1007 x[1-1132] JAK1 P@Y x[1-1154] IFNGR2 x[28-337] IFNGR1 x[18-489] IFNG x[24-161] JAK1 x[1-1154] JAK2 P@Y1007 x[1-1132] SOCS-1 and SOCS-3 IFNGR2 x[28-337] IFNGR1 x[18-489] FCGRA IFN-gamma upregulated CAMs PTAFR x[1-342] IFNG x[24-161] JAK1 x[1-1154] JAK2 x[1-1132] IFNGR2 x[28-337] IFNGR1 x[18-489] JAK1 x[1-1154] JAK2 x[1-1132] IFNGR2 x[28-337] IFNGR1 x[18-489] IFNG x[24-161] IFNGR1 P@Y440 x[18-489] JAK2 P@Y1007 x[1-1132] JAK1 P@Y x[1-1154] STAT1 x[1-750] P@Y701 IFNGR2 x[28-337] IFNG x[24-161] IFNGR1 P@Y440 x[18-489] JAK2 P@Y1007 x[1-1132] STAT1 x[1-750] JAK1 P@Y x[1-1154] IFNGR2 x[28-337] STAT1 x[1-750] P@S727 P@Y701 INFG induced TRIMs ADP STAT1 x[1-750] CaMKII and PKC-delta ATP IRF 1-9 MT2A x[1-61] OAS proteins GBP PTPN6 x[1-595] CIITA x[1-1130] SP100 x[1-879] GAS promoter region in IFNG-regulated genes STAT1 x[1-750] P@S727 P@Y701 GAS promoter region in IFNG-regulated genes STAT1 x[1-750] P@S727 P@Y701 PML x[1-882] IFNG x[24-161] IFI30 x[58-232] Class I MHC heavy chain (MHC HC) B2M x[21-119] SBGNhub Pathway Collection 2 -2 0 Link to SBGN notation Interferon gamma signaling (reactome::R-HSA-877300) Rendered by SBGNview

Figure 4.1: SBGNview graph of the most down-regulated pathways in IFNg KO experiment

image/svg+xml nucleoplasm extracellular endoplasmic reticulum membrane cytosol integral component of lumenal side of endoplasmic reticulum membrane cell membrane mitochondrial outer membrane mitochondrial matrix RNASEL dimer ABCE1:RNASEL dimer ISGF3 bound to ISRE promotor elements ISGF3 AAF AAF p-STAT2:p-STAT1 ISGF3 IFNA/B:IFNAR2:JAK1:STAT2:IFNAR1: TYK2 IFNA/B:IFNAR2:p-JAK1:STAT2:p-IFNAR1: p-TYK2:STAT2 IFNA/B:IFNAR2:JAK1:STAT2 IFNA/B:IFNAR2:p-JAK1:STAT2:p-IFNAR1: p-TYK2:p-STAT2 IFNA/B:IFNAR2:p-JAK1:STAT2:p-IFNAR1: p-TYK2 IFNA/B:IFNAR2:p-JAK1:STAT2:IFNAR1: p-TYK2 IFNAR2:JAK1:STAT2 p-TYK2:p-IFNAR1:SOCS-1/SOCS-3:IFNA/ B:IFNAR2:p-JAK1:STAT2 IFNAR1:TYK2 IFNA/B:IFNAR2:p-JAK1:STAT2:p-IFNAR1: p-TYK2:p-STAT2:p-STAT1 RNASEL x[1-741] ABCE1 x[1-599] RNASEL x[1-741] ABCE1 x[1-599] SAMHD1 x[1-626] ISRE promoter elements in type I IFN-regulated genes p-STAT1 ISRE promoter elements in type I IFN-regulated genes IRF9 x[1-393] STAT2 P@Y690 x[1-851] PSMB8 x[73-276] p-STAT1 IRF9 x[1-393] STAT2 P@Y690 x[1-851] ISG20 x[1-181] IP6K2 x[1-426] STAT1 P@Y701 x[1-750] ADAR x[1-1226] EGR1 x[1-543] IFNA/B XAF1 x[1-301] OAS proteins STAT2 x[1-851] STAT1 x[1-750] ATP STAT1 x[1-750] P@Y701 IFI35 x[2-286] SHP1,SHP2 Mx GTPases ADP GBP2 x[1-588] IFIT2 x[1-472] STAT1 IRF 1-9 STAT2 P@Y690 x[1-851] p-STAT1 IFIT1 x[1-478] ISG15 x[2-157] IFIT3 x[1-490] RNASEL x[1-741] IRF9 x[1-393] STAT2 P@Y690 x[1-851] p-STAT1 IRF9 x[1-393] IFI27 x[34-119] IFNAR1 x[28-557] IFNA/B STAT2 x[1-851] JAK1 x[1-1154] IFNAR2 x[27-515] TYK2 x[1-1187] IFNAR1 P@Y481 x[28-557] P@Y466 TYK2 P@Y1054 x[1-1187] P@Y1055 STAT2 x[1-851] IFNA/B JAK1 P@Y x[1-1154] IFNAR2 x[27-515] IFITM3 x[1-133] IFNA/B STAT2 x[1-851] JAK1 x[1-1154] IFNAR2 x[27-515] IFNAR1 P@Y481 x[28-557] P@Y466 TYK2 P@Y1054 x[1-1187] P@Y1055 STAT2 P@Y690 x[1-851] STAT2 x[1-851] IFNA/B JAK1 P@Y x[1-1154] IFNAR2 x[27-515] IFI6 x[24-130] IFITM1 x[1-125] IFNAR1 P@Y481 x[28-557] P@Y466 TYK2 P@Y1054 x[1-1187] P@Y1055 STAT2 x[1-851] IFNA/B JAK1 P@Y x[1-1154] IFNAR2 x[27-515] IFNAR1 x[28-557] TYK2 P@Y1054 x[1-1187] P@Y1055 STAT2 x[1-851] IFNA/B JAK1 P@Y x[1-1154] IFNAR2 x[27-515] IFITM2 x[1-132] BST2 x[1-161] STAT2 x[1-851] JAK1 x[1-1154] IFNAR2 x[27-515] IFNAR1 P@Y481 x[28-557] P@Y466 TYK2 P@Y1054 x[1-1187] P@Y1055 STAT2 x[1-851] IFNA/B SOCS-1 and SOCS-3 JAK1 P@Y x[1-1154] IFNAR2 x[27-515] IFNAR1 x[28-557] TYK2 x[1-1187] IFNAR1 P@Y481 x[28-557] P@Y466 TYK2 P@Y1054 x[1-1187] P@Y1055 STAT2 P@Y690 x[1-851] STAT2 x[1-851] IFNA/B JAK1 P@Y x[1-1154] p-STAT1 IFNAR2 x[27-515] RSAD2 x[1-361] Class I MHC heavy chain (MHC HC) SBGNhub Pathway Collection 2 -2 0 Link to SBGN notation Interferon alpha_beta signaling (reactome::R-HSA-909733) Rendered by SBGNview

Figure 4.2: SBGNview graph of the second most down-regulated pathways in IFNg KO experiment

4.4 SBGNview with SummarizedExperiment object

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
image/svg+xml cell membrane cytosol nucleoplasm extracellular lysosomal lumen integral component of lumenal side of endoplasmic reticulum membrane endoplasmic reticulum lumen p-STAT1 dimer bound to p-IFNGR1 MHC class II alpha/ beta dimer IFNG:p-IFNGR1:p-JAK1:IFNGR2:p-JAK2 IFNG:IFNGR1:JAK1:IFNGR2:p-JAK2 IFNG:IFNGR1:p-JAK1:IFNGR2:p-JAK2 IFNG:IFNGR1:JAK1:IFNGR2:p-JAK2:SOCS- 1/-3 IFNG:IFNGR complex IFNGR1:JAK1:INFG2:JAK2 p-STAT1(Y701) bound to p-IFNGR1 STAT1 bound to p-IFNGR1 p-STAT1:p-STAT1 dimer GAF bound to GAS promoter element p-STAT1 homodimer IFNG homodimer IFNG x[24-161] IFNGR1 P@Y440 x[18-489] JAK2 P@Y1007 x[1-1132] JAK1 P@Y x[1-1154] STAT1 x[1-750] P@S727 P@Y701 IFNGR2 x[28-337] HLA II beta chain HLA II alpha chain IFNG x[24-161] IFNGR1 P@Y440 x[18-489] JAK2 P@Y1007 x[1-1132] JAK1 P@Y x[1-1154] IFNGR2 x[28-337] IFNG x[24-161] JAK1 x[1-1154] JAK2 P@Y1007 x[1-1132] IFNGR2 x[28-337] IFNGR1 x[18-489] IFNG x[24-161] JAK2 P@Y1007 x[1-1132] JAK1 P@Y x[1-1154] IFNGR2 x[28-337] IFNGR1 x[18-489] IFNG x[24-161] JAK1 x[1-1154] JAK2 P@Y1007 x[1-1132] SOCS-1 and SOCS-3 IFNGR2 x[28-337] IFNGR1 x[18-489] FCGRA IFN-gamma upregulated CAMs PTAFR x[1-342] IFNG x[24-161] JAK1 x[1-1154] JAK2 x[1-1132] IFNGR2 x[28-337] IFNGR1 x[18-489] JAK1 x[1-1154] JAK2 x[1-1132] IFNGR2 x[28-337] IFNGR1 x[18-489] IFNG x[24-161] IFNGR1 P@Y440 x[18-489] JAK2 P@Y1007 x[1-1132] JAK1 P@Y x[1-1154] STAT1 x[1-750] P@Y701 IFNGR2 x[28-337] IFNG x[24-161] IFNGR1 P@Y440 x[18-489] JAK2 P@Y1007 x[1-1132] STAT1 x[1-750] JAK1 P@Y x[1-1154] IFNGR2 x[28-337] STAT1 x[1-750] P@S727 P@Y701 INFG induced TRIMs ADP STAT1 x[1-750] CaMKII and PKC-delta ATP IRF 1-9 MT2A x[1-61] OAS proteins GBP PTPN6 x[1-595] CIITA x[1-1130] SP100 x[1-879] GAS promoter region in IFNG-regulated genes STAT1 x[1-750] P@S727 P@Y701 GAS promoter region in IFNG-regulated genes STAT1 x[1-750] P@S727 P@Y701 PML x[1-882] IFNG x[24-161] IFI30 x[58-232] Class I MHC heavy chain (MHC HC) B2M x[21-119] SBGNhub Pathway Collection 1 -1 0 Link to SBGN notation Interferon gamma signaling (reactome::R-HSA-877300) Rendered by SBGNview

Figure 4.3: SBGNview of a cancer dataset gse16873

5 Session Info

sessionInfo()
## R version 4.5.0 RC (2025-04-04 r88126)
## Platform: aarch64-apple-darwin20
## Running under: macOS Ventura 13.7.1
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
## 
## 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.58.0                 SummarizedExperiment_1.38.0
##  [3] Biobase_2.68.0              GenomicRanges_1.60.0       
##  [5] GenomeInfoDb_1.44.0         IRanges_2.42.0             
##  [7] S4Vectors_0.46.0            BiocGenerics_0.54.0        
##  [9] generics_0.1.3              MatrixGenerics_1.20.0      
## [11] matrixStats_1.5.0           SBGNview_1.22.0            
## [13] SBGNview.data_1.21.0        pathview_1.48.0            
## [15] knitr_1.50                 
## 
## loaded via a namespace (and not attached):
##  [1] KEGGREST_1.48.0         xfun_0.52               bslib_0.9.0            
##  [4] lattice_0.22-7          vctrs_0.6.5             tools_4.5.0            
##  [7] Rdpack_2.6.4            bitops_1.0-9            AnnotationDbi_1.70.0   
## [10] RSQLite_2.3.9           blob_1.2.4              pkgconfig_2.0.3        
## [13] Matrix_1.7-3            graph_1.86.0            lifecycle_1.0.4        
## [16] GenomeInfoDbData_1.2.14 compiler_4.5.0          Biostrings_2.76.0      
## [19] htmltools_0.5.8.1       sass_0.4.10             RCurl_1.98-1.17        
## [22] yaml_2.3.10             crayon_1.5.3            jquerylib_0.1.4        
## [25] GO.db_3.21.0            cachem_1.1.0            DelayedArray_0.34.0    
## [28] org.Hs.eg.db_3.21.0     abind_1.4-8             digest_0.6.37          
## [31] bookdown_0.43           rsvg_2.6.2              fastmap_1.2.0          
## [34] grid_4.5.0              cli_3.6.4               SparseArray_1.8.0      
## [37] magrittr_2.0.3          S4Arrays_1.8.0          XML_3.99-0.18          
## [40] UCSC.utils_1.4.0        bit64_4.6.0-1           rmarkdown_2.29         
## [43] XVector_0.48.0          httr_1.4.7              igraph_2.1.4           
## [46] bit_4.6.0               png_0.1-8               memoise_2.0.1          
## [49] evaluate_1.0.3          rbibutils_2.3           rlang_1.1.6            
## [52] DBI_1.2.3               Rgraphviz_2.52.0        xml2_1.3.8             
## [55] KEGGgraph_1.68.0        jsonlite_2.0.0          R6_2.6.1