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.
This vignette shows how the ReactomeGSA package can be used to perform a pathway analysis of cell clusters in single-cell RNA-sequencing data.
To cite this package, use
Griss J. ReactomeGSA, https://github.com/reactome/ReactomeGSA (2019)
The ReactomeGSA
package can be directly installed from
Bioconductor:
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
if (!require(ReactomeGSA))
BiocManager::install("ReactomeGSA")
# install the ReactomeGSA.data package for the example data
if (!require(ReactomeGSA.data))
BiocManager::install("ReactomeGSA.data")
For more information, see https://bioconductor.org/install/.
As an example we load single-cell RNA-sequencing data of B cells extracted from the dataset published by Jerby-Arnon et al. (Cell, 2018).
Note: This is not a complete Seurat object. To decrease the size, the object only contains gene expression values and cluster annotations.
library(ReactomeGSA.data)
#> Loading required package: limma
#> Loading required package: edgeR
#> Loading required package: ReactomeGSA
#> Loading required package: Seurat
#> Attaching SeuratObject
#> 'SeuratObject' was built under R 4.3.1 but the current version is
#> 4.3.2; it is recomended that you reinstall 'SeuratObject' as the ABI
#> for R may have changed
#> Seurat v4 was just loaded with SeuratObject v5; disabling v5 assays and
#> validation routines, and ensuring assays work in strict v3/v4
#> compatibility mode
data(jerby_b_cells)
jerby_b_cells
#> An object of class Seurat
#> 23686 features across 920 samples within 1 assay
#> Active assay: RNA (23686 features, 0 variable features)
#> 2 layers present: counts, data
The pathway analysis is at the very end of a scRNA-seq workflow. This means, that any Q/C was already performed, the data was normalized and cells were already clustered.
The ReactomeGSA package can now be used to get pathway-level expression values for every cell cluster. This is achieved by calculating the mean gene expression for every cluster and then submitting this data to a gene set variation analysis.
All of this is wrapped in the single analyse_sc_clusters
function.
library(ReactomeGSA)
gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = TRUE)
#> Calculating average cluster expression...
#> Converting expression data to string... (This may take a moment)
#> Conversion complete
#> Submitting request to Reactome API...
#> Compressing request data...
#> Reactome Analysis submitted succesfully
#> Queued
#> Converting dataset Seurat...
#> Mapping identifiers...
#> Performing gene set analysis using ssGSEA
#> Analysing dataset 'Seurat' using ssGSEA
#> Retrieving result...
The resulting object is a standard
ReactomeAnalysisResult
object.
gsva_result
#> ReactomeAnalysisResult object
#> Reactome Release: 86
#> Results:
#> - Seurat:
#> 1774 pathways
#> 11082 fold changes for genes
#> No Reactome visualizations available
#> ReactomeAnalysisResult
pathways
returns the pathway-level expression values per
cell cluster:
pathway_expression <- pathways(gsva_result)
# simplify the column names by removing the default dataset identifier
colnames(pathway_expression) <- gsub("\\.Seurat", "", colnames(pathway_expression))
pathway_expression[1:3,]
#> Name Cluster_1 Cluster_10 Cluster_11
#> R-HSA-1059683 Interleukin-6 signaling 0.1062531 0.09572387 0.1416536
#> R-HSA-109606 Intrinsic Pathway for Apoptosis 0.1148107 0.11105215 0.1130454
#> R-HSA-109703 PKB-mediated events 0.1274599 0.05268901 0.1066447
#> Cluster_12 Cluster_13 Cluster_2 Cluster_3 Cluster_4 Cluster_5
#> R-HSA-1059683 0.10863164 0.09946369 0.11425189 0.11135384 0.10947357 0.10288292
#> R-HSA-109606 0.11971180 0.12870089 0.10934393 0.11247242 0.11491420 0.10575040
#> R-HSA-109703 0.09571927 0.07353405 0.08340785 0.08422136 0.05578716 0.04620338
#> Cluster_6 Cluster_7 Cluster_8 Cluster_9
#> R-HSA-1059683 0.09521594 0.11889892 0.13425733 0.10089919
#> R-HSA-109606 0.11174585 0.11913743 0.12267252 0.11525456
#> R-HSA-109703 0.12363384 0.07720458 0.07844829 0.01429444
A simple approach to find the most relevant pathways is to assess the maximum difference in expression for every pathway:
# find the maximum differently expressed pathway
max_difference <- do.call(rbind, apply(pathway_expression, 1, function(row) {
values <- as.numeric(row[2:length(row)])
return(data.frame(name = row[1], min = min(values), max = max(values)))
}))
max_difference$diff <- max_difference$max - max_difference$min
# sort based on the difference
max_difference <- max_difference[order(max_difference$diff, decreasing = T), ]
head(max_difference)
#> name min
#> R-HSA-350864 Regulation of thyroid hormone activity -0.4877260
#> R-HSA-8964540 Alanine metabolism -0.5061032
#> R-HSA-190374 FGFR1c and Klotho ligand binding and activation -0.3432688
#> R-HSA-140180 COX reactions -0.3450059
#> R-HSA-9024909 BDNF activates NTRK2 (TRKB) signaling -0.3762058
#> R-HSA-5263617 Metabolism of ingested MeSeO2H into MeSeH -0.1934677
#> max diff
#> R-HSA-350864 0.3757260 0.8634520
#> R-HSA-8964540 0.2561373 0.7622405
#> R-HSA-190374 0.4160460 0.7593148
#> R-HSA-140180 0.3727088 0.7177148
#> R-HSA-9024909 0.3236430 0.6998488
#> R-HSA-5263617 0.4938968 0.6873645
The ReactomeGSA package contains two functions to visualize these pathway results. The first simply plots the expression for a selected pathway:
For a better overview, the expression of multiple pathways can be
shown as a heatmap using gplots
heatmap.2
function:
# Additional parameters are directly passed to gplots heatmap.2 function
plot_gsva_heatmap(gsva_result, max_pathways = 15, margins = c(6,20))
The plot_gsva_heatmap
function can also be used to only
display specific pahtways:
# limit to selected B cell related pathways
relevant_pathways <- c("R-HSA-983170", "R-HSA-388841", "R-HSA-2132295", "R-HSA-983705", "R-HSA-5690714")
plot_gsva_heatmap(gsva_result,
pathway_ids = relevant_pathways, # limit to these pathways
margins = c(6,30), # adapt the figure margins in heatmap.2
dendrogram = "col", # only plot column dendrogram
scale = "row", # scale for each pathway
key = FALSE, # don't display the color key
lwid=c(0.1,4)) # remove the white space on the left
This analysis shows us that cluster 8 has a marked up-regulation of B Cell receptor signalling, which is linked to a co-stimulation of the CD28 family. Additionally, there is a gradient among the cluster with respect to genes releated to antigen presentation.
Therefore, we are able to further classify the observed B cell subtypes based on their pathway activity.
The pathway-level expression analysis can also be used to run a
Principal Component Analysis on the samples. This is simplified through
the function plot_gsva_pca
:
In this analysis, cluster 11 is a clear outlier from the other B cell subtypes and therefore might be prioritised for further evaluation.
sessionInfo()
#> R version 4.3.2 (2023-10-31)
#> Platform: aarch64-apple-darwin20 (64-bit)
#> Running under: macOS Ventura 13.6.1
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.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] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] ReactomeGSA.data_1.16.1 SeuratObject_5.0.0 Seurat_4.4.0
#> [4] ReactomeGSA_1.16.1 edgeR_4.0.2 limma_3.58.1
#>
#> loaded via a namespace (and not attached):
#> [1] RColorBrewer_1.1-3 jsonlite_1.8.7 magrittr_2.0.3
#> [4] spatstat.utils_3.0-4 farver_2.1.1 rmarkdown_2.25
#> [7] vctrs_0.6.4 ROCR_1.0-11 spatstat.explore_3.2-5
#> [10] htmltools_0.5.7 progress_1.2.2 curl_5.1.0
#> [13] sass_0.4.7 sctransform_0.4.1 parallelly_1.36.0
#> [16] KernSmooth_2.23-22 bslib_0.5.1 htmlwidgets_1.6.2
#> [19] ica_1.0-3 plyr_1.8.9 plotly_4.10.3
#> [22] zoo_1.8-12 cachem_1.0.8 igraph_1.5.1
#> [25] mime_0.12 lifecycle_1.0.3 pkgconfig_2.0.3
#> [28] Matrix_1.6-1.1 R6_2.5.1 fastmap_1.1.1
#> [31] fitdistrplus_1.1-11 future_1.33.0 shiny_1.7.5.1
#> [34] digest_0.6.33 colorspace_2.1-0 patchwork_1.1.3
#> [37] tensor_1.5 irlba_2.3.5.1 labeling_0.4.3
#> [40] progressr_0.14.0 fansi_1.0.5 spatstat.sparse_3.0-3
#> [43] httr_1.4.7 polyclip_1.10-6 abind_1.4-5
#> [46] compiler_4.3.2 withr_2.5.2 highr_0.10
#> [49] gplots_3.1.3 MASS_7.3-60 gtools_3.9.4
#> [52] caTools_1.18.2 tools_4.3.2 lmtest_0.9-40
#> [55] httpuv_1.6.12 future.apply_1.11.0 goftest_1.2-3
#> [58] glue_1.6.2 nlme_3.1-163 promises_1.2.1
#> [61] grid_4.3.2 Rtsne_0.16 cluster_2.1.4
#> [64] reshape2_1.4.4 generics_0.1.3 gtable_0.3.4
#> [67] spatstat.data_3.0-3 tidyr_1.3.0 data.table_1.14.8
#> [70] hms_1.1.3 sp_2.1-1 utf8_1.2.4
#> [73] spatstat.geom_3.2-7 RcppAnnoy_0.0.21 ggrepel_0.9.4
#> [76] RANN_2.6.1 pillar_1.9.0 stringr_1.5.0
#> [79] spam_2.10-0 later_1.3.1 splines_4.3.2
#> [82] dplyr_1.1.3 lattice_0.22-5 survival_3.5-7
#> [85] deldir_1.0-9 tidyselect_1.2.0 locfit_1.5-9.8
#> [88] miniUI_0.1.1.1 pbapply_1.7-2 knitr_1.45
#> [91] gridExtra_2.3 scattermore_1.2 xfun_0.41
#> [94] statmod_1.5.0 matrixStats_1.0.0 stringi_1.7.12
#> [97] lazyeval_0.2.2 yaml_2.3.7 evaluate_0.23
#> [100] codetools_0.2-19 tibble_3.2.1 cli_3.6.1
#> [103] uwot_0.1.16 xtable_1.8-4 reticulate_1.34.0
#> [106] munsell_0.5.0 jquerylib_0.1.4 Rcpp_1.0.11
#> [109] globals_0.16.2 spatstat.random_3.2-1 png_0.1-8
#> [112] parallel_4.3.2 ellipsis_0.3.2 ggplot2_3.4.4
#> [115] prettyunits_1.2.0 dotCall64_1.1-0 bitops_1.0-7
#> [118] listenv_0.9.0 viridisLite_0.4.2 scales_1.2.1
#> [121] ggridges_0.5.4 leiden_0.4.3 purrr_1.0.2
#> [124] crayon_1.5.2 rlang_1.1.1 cowplot_1.1.1