Using the ReactomeGSA package

Johannes Griss

2020-09-01

Introduction

The ReactomeGSA package is a client to the web-based Reactome Analysis System. Essentially, it performs a gene set analysis using the latest version of the Reactome pathway database as a backend.

The main advantages of using the Reactome Analysis System are:

Citation

To cite this package, use

Griss J. ReactomeGSA, https://github.com/reactome/ReactomeGSA (2019)

Installation

The ReactomeGSA package can be directly installed from Bioconductor:

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

if (!require(ReactomeGSA))
  BiocManager::install("ReactomeGSA")

For more information, see https://bioconductor.org/install/.

Getting available methods

The Reactome Analysis System will be continuously updated. Before starting your analysis it is therefore a good approach to check which methods are available.

This can simply be done by using:

library(ReactomeGSA)

available_methods <- get_reactome_methods(print_methods = FALSE, return_result = TRUE)

# only show the names of the available methods
available_methods$name
#> [1] "PADOG"  "Camera" "ssGSEA"

To get more information about a specific method, set print_details to TRUE and specify the method:

# Use this command to print the description of the specific method to the console
# get_reactome_methods(print_methods = TRUE, print_details = TRUE, method = "PADOG", return_result = FALSE)

# show the parameter names for the method
padog_params <- available_methods$parameters[available_methods$name == "PADOG"][[1]]

paste0(padog_params$name, " (", padog_params$type, ", ", padog_params$default, ")")
#>  [1] "use_interactors (bool, False)"             
#>  [2] "include_disease_pathways (bool, True)"     
#>  [3] "max_missing_values (float, 0.5)"           
#>  [4] "create_reactome_visualization (bool, True)"
#>  [5] "create_reports (bool, False)"              
#>  [6] "email (string, )"                          
#>  [7] "reactome_server (string, production)"      
#>  [8] "sample_groups (string, )"                  
#>  [9] "discrete_norm_function (string, TMM)"      
#> [10] "continuous_norm_function (string, none)"

Creating an analysis request

To start a gene set analysis, you first have to create an analysis request. This is a simple S4 class that takes care of submitting multiple datasets simultaneously to the analysis system.

When creating the request object, you already have to specify the analysis method you want to use:

# Create a new request object using 'Camera' for the gene set analysis
my_request <-ReactomeAnalysisRequest(method = "Camera")

my_request
#> ReactomeAnalysisRequestObject
#>   Method = Camera
#>   No request data stored
#> ReactomeAnalysisRequest

Setting parameters

To get a list of supported parameters for each method, use the get_reactome_methods function (see above).

Parameters are simply set using the set_parameters function:

# set the maximum number of allowed missing values to 50%
my_request <- set_parameters(request = my_request, max_missing_values = 0.5)

my_request
#> ReactomeAnalysisRequestObject
#>   Method = Camera
#>   Parameters:
#>   - max_missing_values: 0.5
#>   Datasets: none
#> ReactomeAnalysisRequest

Multiple parameters can by set simulataneously by simply adding more name-value pairs to the function call.

Adding datasets

One analysis request can contain multiple datasets. This can be used to, for example, visualize the results of an RNA-seq and Proteomics experiment (of the same / similar samples) side by side:

library(ReactomeGSA.data)
data("griss_melanoma_proteomics")

This is a limma EList object with the sample data already added

class(griss_melanoma_proteomics)
#> [1] "EList"
#> attr(,"package")
#> [1] "limma"
head(griss_melanoma_proteomics$samples)
#>                patient.id condition cell.type
#> M-D MOCK PBMCB         P3      MOCK     PBMCB
#> M-D MCM PBMCB          P3       MCM     PBMCB
#> M-K MOCK PBMCB         P4      MOCK     PBMCB
#> M-K MCM PBMCB          P4       MCM     PBMCB
#> P-A MOCK PBMCB         P1      MOCK     PBMCB
#> P-A MCM PBMCB          P1       MCM     PBMCB

The dataset can now simply be added to the request using the add_dataset function:

my_request <- add_dataset(request = my_request, 
                          expression_values = griss_melanoma_proteomics, 
                          name = "Proteomics", 
                          type = "proteomics_int",
                          comparison_factor = "condition", 
                          comparison_group_1 = "MOCK", 
                          comparison_group_2 = "MCM",
                          additional_factors = c("cell.type", "patient.id"))
my_request
#> ReactomeAnalysisRequestObject
#>   Method = Camera
#>   Parameters:
#>   - max_missing_values: 0.5
#>   Datasets:
#>   - Proteomics (proteomics_int)
#>     No parameters set.
#> ReactomeAnalysisRequest

Several datasets (of the same experiment) can be added to one request. This RNA-seq data is stored as an edgeR DGEList object:

data("griss_melanoma_rnaseq")

# only keep genes with >= 100 reads in total
total_reads <- rowSums(griss_melanoma_rnaseq$counts)
griss_melanoma_rnaseq <- griss_melanoma_rnaseq[total_reads >= 100, ]

# this is a edgeR DGEList object
class(griss_melanoma_rnaseq)
#> [1] "DGEList"
#> attr(,"package")
#> [1] "edgeR"
head(griss_melanoma_rnaseq$samples)
#>        group lib.size norm.factors patient cell_type treatment
#> 195-13  MOCK 29907534    1.0629977      P1      TIBC      MOCK
#> 195-14   MCM 26397322    0.9927768      P1      TIBC       MCM
#> 195-19  MOCK 18194834    1.0077827      P2     PBMCB      MOCK
#> 195-20   MCM 24282215    1.0041410      P2     PBMCB       MCM
#> 197-11  MOCK 22628117    0.9522869      P1     PBMCB      MOCK
#> 197-12   MCM 23319849    1.0115732      P1     PBMCB       MCM

Again, the dataset can simply be added using add_dataset. Here, we added an additional parameter to the add_dataset call. Such additional parameters are treated as additional dataset-level parameters.

# add the dataset
my_request <- add_dataset(request = my_request, 
                          expression_values = griss_melanoma_rnaseq, 
                          name = "RNA-seq", 
                          type = "rnaseq_counts",
                          comparison_factor = "treatment", 
                          comparison_group_1 = "MOCK", 
                          comparison_group_2 = "MCM",
                          additional_factors = c("cell_type", "patient"),
                          # This adds the dataset-level parameter 'discrete_norm_function' to the request
                          discrete_norm_function = "TMM")
#> Converting expression data to string... (This may take a moment)
#> Conversion complete
my_request
#> ReactomeAnalysisRequestObject
#>   Method = Camera
#>   Parameters:
#>   - max_missing_values: 0.5
#>   Datasets:
#>   - Proteomics (proteomics_int)
#>     No parameters set.
#>   - RNA-seq (rnaseq_counts)
#>     discrete_norm_function: TMM
#> ReactomeAnalysisRequest

Sample annotations

Datasets can be passed as limma EList, edgeR DGEList, any implementation of the Bioconductor ExpressionSet, or simply a data.frame.

For the first three, sample annotations are simply read from the respective slot. When supplying the expression values as a data.frame, the sample_data parameter has to be set using a data.frame where each row represents one sample and each column one proptery. If the the sample_data option is set while providing the expression data as an EList, DGEList, or ExpressionSet, the data in sample_data will be used instead of the sample annotations in the expression data object.

Name

Each dataset has to have a name. This can be anything but has to be unique within one analysis request.

Type

The ReactomeAnalysisSystem supports different types of ’omics data. To get a list of supported types, use the get_reactome_data_types function:

Defining the experimental design

Defining the experimental design for a ReactomeAnalysisRequest is very simple. Basically, it only takes three parameters:

The value set in comparison_factor must match a column name in the sample data (either the slot in an Elist, DGEList, or ExpressionSet object or in the sample_data parameter).

Additionally, it is possible to define blocking factors. These are supported by all methods that rely on linear models in the backend. Some methods though might simply ignore this parameter. For more information on whether a method supports blocking factors, please use get_reactome_methods.

Blocking factors can simply be set additional_factors to a vector of names. These should again reference properties (or columns) in the sample data.

Submitting the request

Once the ReactomeAnalysisRequest is created, the complete analysis can be run using perform_reactome_analysis:

result <- perform_reactome_analysis(request = my_request, compress = F)
#> Submitting request to Reactome API...
#> Reactome Analysis submitted succesfully
#> Converting dataset RNA-seq...
#> Mapping identifiers...
#> Performing gene set analysis using Camera
#> Analysing dataset 'RNA-seq' using Camera
#> Creating REACTOME visualization
#> Retrieving result...

Investigating the result

The result object is a ReactomeAnalysisResult S4 class with several helper functions to access the data.

To retrieve the names of all available results (generally one per dataset), use the names function:

names(result)
#> [1] "Proteomics" "RNA-seq"

For every dataset, different result types may be available. These can be shown using the result_types function:

result_types(result)
#> [1] "pathways"     "fold_changes"

The Camera analysis method returns two types of results, pathway-level data and gene- / protein-level fold changes.

A specific result can be retrieved using the get_result method:

# retrieve the fold-change data for the proteomics dataset
proteomics_fc <- get_result(result, type = "fold_changes", name = "Proteomics")
head(proteomics_fc)
#>   Identifier      logFC   AveExpr         t      P.Value    adj.P.Val         B
#> 1     Q14526  0.4937650 -3.346909 14.517427 1.518276e-10 8.080266e-07 13.984585
#> 2     Q6VY07  0.2981411 -3.330347 13.556574 4.146707e-10 1.103439e-06 13.124798
#> 3     P07093  1.7950301 -3.648968 12.284773 1.727960e-09 3.065401e-06 11.870386
#> 4     P10124  1.0758634 -3.436961 10.323685 2.015451e-08 2.681558e-05  9.633389
#> 5     P55210  0.5018522 -3.347932  9.510895 6.205398e-08 6.605025e-05  8.581836
#> 6     O43683 -0.4754083 -3.345551 -9.362407 7.678324e-08 6.810673e-05  8.381021

Additionally, it is possible to directly merge the pathway level data for all result sets using the pathways function:

combined_pathways <- pathways(result)

head(combined_pathways)
#>                                                                                                                              Name
#> R-HSA-163200  Respiratory electron transport, ATP synthesis by chemiosmotic coupling, and heat production by uncoupling proteins.
#> R-HSA-1428517                                                      The citric acid (TCA) cycle and respiratory electron transport
#> R-HSA-611105                                                                                       Respiratory electron transport
#> R-HSA-6799198                                                                                                Complex I biogenesis
#> R-HSA-72649                                                                              Translation initiation complex formation
#> R-HSA-72662                Activation of the mRNA upon binding of the cap-binding complex and eIFs, and subsequent binding to 43S
#>               Direction.Proteomics FDR.Proteomics PValue.Proteomics
#> R-HSA-163200                    Up   2.496049e-14      1.239349e-17
#> R-HSA-1428517                   Up   2.980319e-14      2.959602e-17
#> R-HSA-611105                    Up   7.492758e-14      1.116101e-16
#> R-HSA-6799198                   Up   1.510110e-11      2.999225e-14
#> R-HSA-72649                   Down   2.773542e-08      6.885655e-11
#> R-HSA-72662                   Down   5.557057e-08      1.655528e-10
#>               NGenes.Proteomics av_foldchange.Proteomics sig.Proteomics
#> R-HSA-163200                104               0.13854724           TRUE
#> R-HSA-1428517               144               0.12644683           TRUE
#> R-HSA-611105                 90               0.13912641           TRUE
#> R-HSA-6799198                53               0.14768317           TRUE
#> R-HSA-72649                  57              -0.09502561           TRUE
#> R-HSA-72662                  58              -0.09089517           TRUE
#>               Direction.RNA-seq  FDR.RNA-seq PValue.RNA-seq NGenes.RNA-seq
#> R-HSA-163200               Down 9.439653e-06   2.764051e-07            120
#> R-HSA-1428517              Down 2.162479e-05   7.675171e-07            164
#> R-HSA-611105               Down 1.230029e-04   5.948234e-06             99
#> R-HSA-6799198              Down 2.110482e-03   1.563667e-04             55
#> R-HSA-72649                Down 1.155978e-01   2.451452e-02             58
#> R-HSA-72662                Down 1.480908e-01   3.501880e-02             59
#>               av_foldchange.RNA-seq sig.RNA-seq
#> R-HSA-163200            -0.19716165        TRUE
#> R-HSA-1428517           -0.17568360        TRUE
#> R-HSA-611105            -0.18792846        TRUE
#> R-HSA-6799198           -0.18182027        TRUE
#> R-HSA-72649             -0.10402739       FALSE
#> R-HSA-72662             -0.07799017       FALSE

Visualising results

The ReactomeGSA package includes several basic plotting functions to visualise the pathway results. For comparative gene set analysis like the one presented here, two functions are available: plot_correlations and plot_volcano.

plot_correlations can be used to quickly assess how similar two datasets are on the pathway level:

plot_correlations(result)
#> Comparing 1 vs 2
#> [[1]]
#> Warning: Removed 246 rows containing missing values (geom_point).

Individual datasets can further be visualised using volcano plots of the pathway data:

plot_volcano(result, 2)

Session Info

sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.11-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.11-bioc/R/lib/libRlapack.so
#> 
#> 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       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ReactomeGSA.data_1.2.0 Seurat_3.2.0           edgeR_3.30.3          
#> [4] limma_3.44.3           ReactomeGSA_1.2.4     
#> 
#> loaded via a namespace (and not attached):
#>   [1] Rtsne_0.15            colorspace_1.4-1      deldir_0.1-28        
#>   [4] ellipsis_0.3.1        ggridges_0.5.2        spatstat.data_1.4-3  
#>   [7] farver_2.0.3          leiden_0.3.3          listenv_0.8.0        
#>  [10] ggrepel_0.8.2         codetools_0.2-16      splines_4.0.2        
#>  [13] knitr_1.29            polyclip_1.10-0       jsonlite_1.7.0       
#>  [16] ica_1.0-2             cluster_2.1.0         png_0.1-7            
#>  [19] uwot_0.1.8            shiny_1.5.0           sctransform_0.2.1    
#>  [22] BiocManager_1.30.10   compiler_4.0.2        httr_1.4.2           
#>  [25] Matrix_1.2-18         fastmap_1.0.1         lazyeval_0.2.2       
#>  [28] later_1.1.0.1         prettyunits_1.1.1     htmltools_0.5.0      
#>  [31] tools_4.0.2           rsvd_1.0.3            igraph_1.2.5         
#>  [34] gtable_0.3.0          glue_1.4.2            RANN_2.6.1           
#>  [37] reshape2_1.4.4        dplyr_1.0.2           rappdirs_0.3.1       
#>  [40] Rcpp_1.0.5            spatstat_1.64-1       vctrs_0.3.4          
#>  [43] gdata_2.18.0          ape_5.4-1             nlme_3.1-149         
#>  [46] lmtest_0.9-37         xfun_0.16             stringr_1.4.0        
#>  [49] globals_0.12.5        mime_0.9              miniUI_0.1.1.1       
#>  [52] lifecycle_0.2.0       irlba_2.3.3           gtools_3.8.2         
#>  [55] goftest_1.2-2         future_1.18.0         MASS_7.3-52          
#>  [58] zoo_1.8-8             scales_1.1.1          hms_0.5.3            
#>  [61] promises_1.1.1        spatstat.utils_1.17-0 parallel_4.0.2       
#>  [64] RColorBrewer_1.1-2    yaml_2.2.1            curl_4.3             
#>  [67] reticulate_1.16       pbapply_1.4-3         gridExtra_2.3        
#>  [70] ggplot2_3.3.2         rpart_4.1-15          stringi_1.4.6        
#>  [73] caTools_1.18.0        rlang_0.4.7           pkgconfig_2.0.3      
#>  [76] bitops_1.0-6          evaluate_0.14         lattice_0.20-41      
#>  [79] ROCR_1.0-11           purrr_0.3.4           tensor_1.5           
#>  [82] labeling_0.3          patchwork_1.0.1       htmlwidgets_1.5.1    
#>  [85] cowplot_1.0.0         tidyselect_1.1.0      RcppAnnoy_0.0.16     
#>  [88] plyr_1.8.6            magrittr_1.5          R6_2.4.1             
#>  [91] gplots_3.0.4          generics_0.0.2        pillar_1.4.6         
#>  [94] mgcv_1.8-33           fitdistrplus_1.1-1    survival_3.2-3       
#>  [97] abind_1.4-5           tibble_3.0.3          future.apply_1.6.0   
#> [100] crayon_1.3.4          KernSmooth_2.23-17    plotly_4.9.2.1       
#> [103] rmarkdown_2.3         progress_1.2.2        locfit_1.5-9.4       
#> [106] grid_4.0.2            data.table_1.13.0     digest_0.6.25        
#> [109] xtable_1.8-4          tidyr_1.1.2           httpuv_1.5.4         
#> [112] munsell_0.5.0         viridisLite_0.3.0