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")
#> Loading required package: ReactomeGSA
# install the ReactomeGSA.data package for the example data
if (!require(ReactomeGSA))
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: Seurat
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)
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
#> 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: 74
#> Results:
#> - Seurat:
#> 1723 pathways
#> 10728 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.10334592 0.09666255 0.14251763
#> R-HSA-109606 Intrinsic Pathway for Apoptosis 0.10525530 0.10528882 0.10817361
#> R-HSA-109703 PKB-mediated events 0.09708567 0.02866064 0.09485118
#> Cluster_12 Cluster_13 Cluster_2 Cluster_3 Cluster_4 Cluster_5
#> R-HSA-1059683 0.1071082 0.10752020 0.11754258 0.10910198 0.1104005 0.10829945
#> R-HSA-109606 0.1108030 0.12184146 0.09976769 0.10788626 0.1068078 0.09857598
#> R-HSA-109703 0.1172487 0.05920051 0.05643768 0.08710097 0.0505033 0.04704229
#> Cluster_6 Cluster_7 Cluster_8 Cluster_9
#> R-HSA-1059683 0.09547943 0.11350268 0.12997181 0.10159703
#> R-HSA-109606 0.10562406 0.11320979 0.11622302 0.11388589
#> R-HSA-109703 0.09465369 0.04818709 0.04534148 -0.01169581
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-389542 NADPH regeneration -0.4470641
#> R-HSA-350864 Regulation of thyroid hormone activity -0.4872210
#> R-HSA-8964540 Alanine metabolism -0.5063074
#> R-HSA-190374 FGFR1c and Klotho ligand binding and activation -0.3445460
#> R-HSA-140180 COX reactions -0.3475696
#> R-HSA-5263617 Metabolism of ingested MeSeO2H into MeSeH -0.1940543
#> max diff
#> R-HSA-389542 0.4200409 0.8671051
#> R-HSA-350864 0.3738369 0.8610579
#> R-HSA-8964540 0.2538387 0.7601461
#> R-HSA-190374 0.4147497 0.7592957
#> R-HSA-140180 0.3713802 0.7189498
#> R-HSA-5263617 0.4936926 0.6877470
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.0.3 (2020-10-10)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.5 LTS
#>
#> Matrix products: default
#> BLAS: /home/biocbuild/bbs-3.12-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.12-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.3.0 Seurat_3.2.2 edgeR_3.32.0
#> [4] limma_3.46.0 ReactomeGSA_1.4.0
#>
#> loaded via a namespace (and not attached):
#> [1] Rtsne_0.15 colorspace_1.4-1 deldir_0.1-29
#> [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.3
#> [13] knitr_1.30 polyclip_1.10-0 jsonlite_1.7.1
#> [16] ica_1.0-2 cluster_2.1.0 png_0.1-7
#> [19] uwot_0.1.8 shiny_1.5.0 sctransform_0.3.1
#> [22] BiocManager_1.30.10 compiler_4.0.3 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.3 rsvd_1.0.3 igraph_1.2.6
#> [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] nlme_3.1-150 lmtest_0.9-38 xfun_0.18
#> [46] stringr_1.4.0 globals_0.13.1 mime_0.9
#> [49] miniUI_0.1.1.1 lifecycle_0.2.0 irlba_2.3.3
#> [52] gtools_3.8.2 goftest_1.2-2 future_1.19.1
#> [55] MASS_7.3-53 zoo_1.8-8 scales_1.1.1
#> [58] hms_0.5.3 promises_1.1.1 spatstat.utils_1.17-0
#> [61] parallel_4.0.3 RColorBrewer_1.1-2 yaml_2.2.1
#> [64] curl_4.3 reticulate_1.18 pbapply_1.4-3
#> [67] gridExtra_2.3 ggplot2_3.3.2 rpart_4.1-15
#> [70] stringi_1.5.3 caTools_1.18.0 rlang_0.4.8
#> [73] pkgconfig_2.0.3 matrixStats_0.57.0 bitops_1.0-6
#> [76] evaluate_0.14 lattice_0.20-41 ROCR_1.0-11
#> [79] purrr_0.3.4 tensor_1.5 labeling_0.4.2
#> [82] patchwork_1.0.1 htmlwidgets_1.5.2 cowplot_1.1.0
#> [85] tidyselect_1.1.0 RcppAnnoy_0.0.16 plyr_1.8.6
#> [88] magrittr_1.5 R6_2.4.1 gplots_3.1.0
#> [91] generics_0.0.2 pillar_1.4.6 mgcv_1.8-33
#> [94] fitdistrplus_1.1-1 survival_3.2-7 abind_1.4-5
#> [97] tibble_3.0.4 future.apply_1.6.0 crayon_1.3.4
#> [100] KernSmooth_2.23-17 plotly_4.9.2.1 rmarkdown_2.5
#> [103] progress_1.2.2 locfit_1.5-9.4 grid_4.0.3
#> [106] data.table_1.13.2 digest_0.6.27 xtable_1.8-4
#> [109] tidyr_1.1.2 httpuv_1.5.4 munsell_0.5.0
#> [112] viridisLite_0.3.0