rGREAT has integrated Gene Ontology gene sets for all supported organisms and MSigDB gene sets for human. It is very easy to apply GREAT analysis on other geneset databases such as KEGG. THe basical use has been explained in the section “Manually set gene sets” in the vignette “Analyze with local GREAT. In this vignette, we will just show you several examples.

KEGG pathways

KEGG pathway database is widely used for gene set enrichment analysis. To apply GREAT anlaysis with KEGG pathways, we need to construct the corresponding gene sets.

KEGG provides its data via a REST API (https://rest.kegg.jp/). There are several commands that can be used to retrieve specific types of data. Here we use the package KEGGREST to obtain data directly from KEGG. To get a list of genes involved in pathways, we use the “link” command which is implemented in the function keggLink().

library(KEGGREST)
pathway2gene = keggLink("pathway", "hsa")
head(pathway2gene)
##       hsa:10327         hsa:124         hsa:125         hsa:126         hsa:127 
## "path:hsa00010" "path:hsa00010" "path:hsa00010" "path:hsa00010" "path:hsa00010" 
##         hsa:128 
## "path:hsa00010"

The returned object pathway2gene is a named vector, where the names are gene Entrez IDs (with an additional "hsa:" prefix) and values are pathway IDs (with an additional "path:" prefix). You can try to execute keggLink("hsa","pathway") to compare the results. The named vectors are not common for downstream gene set analysis. Let’s convert it to a list of genes, also remove the prefix.

kegg_pathways = split(gsub("hsa:", "", names(pathway2gene)),
                      gsub("path:", "", pathway2gene))

Now simply send kegg_pathways to great() to perform GREAT analysis.

library(rGREAT)
gr = randomRegions(genome = "hg19")
great(gr, kegg_pathways, "hg19")
## 933 regions are associated to 1377 genes' extended TSSs.
##   TSS source: TxDb.Hsapiens.UCSC.hg19.knownGene
##   Genome: hg19
##   OrgDb: org.Hs.eg.db
##   Gene sets: self-provided
##   Background: whole genome excluding gaps
## Mode: Basal plus extension
##   Proximal: 5000 bp upstream, 1000 bp downstream,
##   plus Distal: up to 1000000 bp

Here we only include the KEGG pathway IDs. The full name of pathways can be obtained by the following command:

pn = keggList("pathway/hsa")
head(pn)
##                                                 hsa01100 
##              "Metabolic pathways - Homo sapiens (human)" 
##                                                 hsa01200 
##               "Carbon metabolism - Homo sapiens (human)" 
##                                                 hsa01210 
## "2-Oxocarboxylic acid metabolism - Homo sapiens (human)" 
##                                                 hsa01212 
##           "Fatty acid metabolism - Homo sapiens (human)" 
##                                                 hsa01230 
##     "Biosynthesis of amino acids - Homo sapiens (human)" 
##                                                 hsa01232 
##           "Nucleotide metabolism - Homo sapiens (human)"

Please go the the documentation of KEGGREST or the main website of KEGG API (https://rest.kegg.jp/) to find out commands for retrieving various datasets there.

To make it easier to use, there is already a helper function getKEGGPathways() function which directly downloads data from kEGG and format it as a list or a data frame.

lt = getKEGGPathways("hsa")
lt[1:2]
## $`hsa00010: Glycolysis / Gluconeogenesis`
##  [1] "10327"  "124"    "125"    "126"    "127"    "128"    "130"    "130589"
##  [9] "131"    "160287" "1737"   "1738"   "2023"   "2026"   "2027"   "217"   
## [17] "218"    "219"    "2203"   "221"    "222"    "223"    "224"    "226"   
## [25] "229"    "230"    "2538"   "2597"   "26330"  "2645"   "2821"   "3098"  
## [33] "3099"   "3101"   "387712" "3939"   "3945"   "3948"   "441531" "501"   
## [41] "5105"   "5106"   "5160"   "5161"   "5162"   "5211"   "5213"   "5214"  
## [49] "5223"   "5224"   "5230"   "5232"   "5236"   "5313"   "5315"   "55276" 
## [57] "55902"  "57818"  "669"    "7167"   "80201"  "83440"  "84532"  "8789"  
## [65] "92483"  "92579"  "9562"  
## 
## $`hsa00020: Citrate cycle (TCA cycle)`
##  [1] "1431"  "1737"  "1738"  "1743"  "2271"  "3417"  "3418"  "3419"  "3420" 
## [10] "3421"  "4190"  "4191"  "47"    "48"    "4967"  "50"    "5091"  "5105" 
## [19] "5106"  "5160"  "5161"  "5162"  "55753" "6389"  "6390"  "6391"  "6392" 
## [28] "8801"  "8802"  "8803"

Please note, KEGG pathways are only free for academic users, https://www.pathway.jp/en/licensing.html.

Reactome pathways

Reactome is another popular pathway database for gene set enrichment analysis. In Bioconductor, there is a package reactome.db that contains genes associated to every pathway in Reactome.

To get the Reactome pathway gene sets, simply use the object reactomePATHID2EXTID.

library(reactome.db)
gs = as.list(reactomePATHID2EXTID)
great(gr, gs, "hg19")
## 933 regions are associated to 1377 genes' extended TSSs.
##   TSS source: TxDb.Hsapiens.UCSC.hg19.knownGene
##   Genome: hg19
##   OrgDb: org.Hs.eg.db
##   Gene sets: self-provided
##   Background: whole genome excluding gaps
## Mode: Basal plus extension
##   Proximal: 5000 bp upstream, 1000 bp downstream,
##   plus Distal: up to 1000000 bp

The full pathway names are in the object reactomePATHID2NAME. You can convert the object to a normal list by as.list(reactomePATHID2NAME).

UniProt keywords gene sets

UniProt database provides a list of controlled vocabulary represented as keywords for genes or proteins (https://www.uniprot.org/keywords/). This is useful for summarizing gene functions in a compact way. The UniProtKeywords package contains gene sets associated to keywords.

UniProtKeywords support several organisms. Here we use human as an example. In the function load_keyword_genesets(), you need to specify the taxon ID for the organism.

Specific gene sets in .gmt format

Please refer to the section “Manually set gene sets” in the vignette “Analyze with local GREAT. There introduces a function read_gmt() which can import a .gmt file into a list of genes.

The tool Enrichr provides a great resource of gene sets in .gmt format. See https://maayanlab.cloud/Enrichr/#libraries.

Session info

## R version 4.3.1 (2023-06-16)
## Platform: x86_64-apple-darwin20 (64-bit)
## Running under: macOS Ventura 13.2.1
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
## 
## locale:
## [1] C/UTF-8/C/C/C/C
## 
## time zone: Europe/Berlin
## tzcode source: internal
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] reactome.db_1.84.0   AnnotationDbi_1.62.2 Biobase_2.60.0      
##  [4] rGREAT_2.5.4         GenomicRanges_1.52.1 GenomeInfoDb_1.36.4 
##  [7] IRanges_2.36.0       S4Vectors_0.40.2     BiocGenerics_0.48.1 
## [10] KEGGREST_1.40.1      knitr_1.44          
## 
## loaded via a namespace (and not attached):
##   [1] DBI_1.1.3                               
##   [2] bitops_1.0-7                            
##   [3] biomaRt_2.56.1                          
##   [4] rlang_1.1.2                             
##   [5] magrittr_2.0.3                          
##   [6] GetoptLong_1.0.5                        
##   [7] matrixStats_1.2.0                       
##   [8] compiler_4.3.1                          
##   [9] RSQLite_2.3.1                           
##  [10] GenomicFeatures_1.52.2                  
##  [11] png_0.1-8                               
##  [12] systemfonts_1.0.5                       
##  [13] vctrs_0.6.4                             
##  [14] stringr_1.5.0                           
##  [15] pkgconfig_2.0.3                         
##  [16] shape_1.4.6                             
##  [17] crayon_1.5.2                            
##  [18] fastmap_1.1.1                           
##  [19] ellipsis_0.3.2                          
##  [20] dbplyr_2.3.4                            
##  [21] XVector_0.40.0                          
##  [22] utf8_1.2.3                              
##  [23] promises_1.2.1                          
##  [24] Rsamtools_2.16.0                        
##  [25] rmarkdown_2.25                          
##  [26] ragg_1.2.6                              
##  [27] purrr_1.0.2                             
##  [28] bit_4.0.5                               
##  [29] xfun_0.40                               
##  [30] zlibbioc_1.46.0                         
##  [31] cachem_1.0.8                            
##  [32] jsonlite_1.8.8                          
##  [33] progress_1.2.2                          
##  [34] blob_1.2.4                              
##  [35] later_1.3.2                             
##  [36] DelayedArray_0.26.7                     
##  [37] BiocParallel_1.34.2                     
##  [38] parallel_4.3.1                          
##  [39] prettyunits_1.2.0                       
##  [40] R6_2.5.1                                
##  [41] bslib_0.6.1                             
##  [42] stringi_1.7.12                          
##  [43] RColorBrewer_1.1-3                      
##  [44] rtracklayer_1.60.1                      
##  [45] jquerylib_0.1.4                         
##  [46] Rcpp_1.0.11                             
##  [47] SummarizedExperiment_1.30.2             
##  [48] iterators_1.0.14                        
##  [49] httpuv_1.6.13                           
##  [50] Matrix_1.6-1.1                          
##  [51] tidyselect_1.2.0                        
##  [52] abind_1.4-5                             
##  [53] yaml_2.3.7                              
##  [54] doParallel_1.0.17                       
##  [55] codetools_0.2-19                        
##  [56] curl_5.1.0                              
##  [57] lattice_0.21-9                          
##  [58] tibble_3.2.1                            
##  [59] shiny_1.8.0                             
##  [60] evaluate_0.22                           
##  [61] desc_1.4.2                              
##  [62] BiocFileCache_2.8.0                     
##  [63] xml2_1.3.6                              
##  [64] circlize_0.4.15                         
##  [65] Biostrings_2.68.1                       
##  [66] pillar_1.9.0                            
##  [67] filelock_1.0.2                          
##  [68] MatrixGenerics_1.12.3                   
##  [69] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 
##  [70] DT_0.30                                 
##  [71] foreach_1.5.2                           
##  [72] generics_0.1.3                          
##  [73] rprojroot_2.0.3                         
##  [74] RCurl_1.98-1.12                         
##  [75] hms_1.1.3                               
##  [76] xtable_1.8-4                            
##  [77] glue_1.6.2                              
##  [78] tools_4.3.1                             
##  [79] BiocIO_1.10.0                           
##  [80] TxDb.Hsapiens.UCSC.hg38.knownGene_3.17.0
##  [81] GenomicAlignments_1.36.0                
##  [82] fs_1.6.3                                
##  [83] XML_3.99-0.14                           
##  [84] grid_4.3.1                              
##  [85] colorspace_2.1-0                        
##  [86] GenomeInfoDbData_1.2.10                 
##  [87] restfulr_0.0.15                         
##  [88] cli_3.6.2                               
##  [89] rappdirs_0.3.3                          
##  [90] textshaping_0.3.7                       
##  [91] fansi_1.0.5                             
##  [92] S4Arrays_1.0.6                          
##  [93] dplyr_1.1.3                             
##  [94] sass_0.4.8                              
##  [95] digest_0.6.33                           
##  [96] org.Hs.eg.db_3.17.0                     
##  [97] rjson_0.2.21                            
##  [98] htmlwidgets_1.6.2                       
##  [99] memoise_2.0.1                           
## [100] htmltools_0.5.7                         
## [101] pkgdown_2.0.7                           
## [102] lifecycle_1.0.4                         
## [103] httr_1.4.7                              
## [104] mime_0.12                               
## [105] GlobalOptions_0.1.2                     
## [106] GO.db_3.17.0                            
## [107] bit64_4.0.5