├── .gitignore ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── NEWS ├── R ├── analyse_sc_clusters.R ├── analysis_request.R ├── analysis_result.R ├── generate_metadata.R ├── generate_pseudo_bulk_data.R ├── get_methods.R ├── get_result.R ├── gsva_plotting_functions.R ├── on_load.R ├── perform_analysis.R ├── plotting_functions.R ├── public_data.R ├── send_request.R └── utils.R ├── README.md ├── inst └── CITATION ├── man ├── ReactomeAnalysisRequest.Rd ├── ReactomeAnalysisResult-class.Rd ├── add_dataset-ReactomeAnalysisRequest-DGEList-method.Rd ├── add_dataset-ReactomeAnalysisRequest-EList-method.Rd ├── add_dataset-ReactomeAnalysisRequest-ExpressionSet-method.Rd ├── add_dataset-ReactomeAnalysisRequest-data.frame-method.Rd ├── add_dataset-ReactomeAnalysisRequest-matrix-method.Rd ├── add_dataset.Rd ├── analyse_sc_clusters-Seurat-method.Rd ├── analyse_sc_clusters-SingleCellExperiment-method.Rd ├── analyse_sc_clusters.Rd ├── break_names.Rd ├── checkRequestValidity.Rd ├── check_reactome_url.Rd ├── convert_reactome_result.Rd ├── data_frame_as_string.Rd ├── fetch_public_data.Rd ├── find_public_datasets.Rd ├── generate_metadata-data.frame-method.Rd ├── generate_metadata.Rd ├── generate_pseudo_bulk_data-Seurat-method.Rd ├── generate_pseudo_bulk_data-SingleCellExperiment-method.Rd ├── generate_pseudo_bulk_data.Rd ├── get_dataset_loading_status.Rd ├── get_fc_for_dataset.Rd ├── get_is_sig_dataset.Rd ├── get_public_species.Rd ├── get_reactome_analysis_result.Rd ├── get_reactome_analysis_status.Rd ├── get_reactome_data_types.Rd ├── get_reactome_methods.Rd ├── get_result-ReactomeAnalysisResult-method.Rd ├── get_result.Rd ├── is_gsva_result.Rd ├── load_public_dataset.Rd ├── names-ReactomeAnalysisResult-method.Rd ├── open_reactome-ReactomeAnalysisResult-method.Rd ├── open_reactome.Rd ├── pathways-ReactomeAnalysisResult-method.Rd ├── pathways.Rd ├── perform_reactome_analysis.Rd ├── plot_correlations-ReactomeAnalysisResult-method.Rd ├── plot_correlations.Rd ├── plot_gsva_heatmap-ReactomeAnalysisResult-method.Rd ├── plot_gsva_heatmap.Rd ├── plot_gsva_pathway-ReactomeAnalysisResult-method.Rd ├── plot_gsva_pathway.Rd ├── plot_gsva_pca-ReactomeAnalysisResult-method.Rd ├── plot_gsva_pca.Rd ├── plot_heatmap-ReactomeAnalysisResult-method.Rd ├── plot_heatmap.Rd ├── plot_volcano-ReactomeAnalysisResult-method.Rd ├── plot_volcano.Rd ├── print-ReactomeAnalysisRequest-method.Rd ├── print-ReactomeAnalysisResult-method.Rd ├── reactome_links-ReactomeAnalysisResult-method.Rd ├── reactome_links.Rd ├── remove_dataset-ReactomeAnalysisRequest-method.Rd ├── remove_dataset.Rd ├── result_types-ReactomeAnalysisResult-method.Rd ├── result_types.Rd ├── set_method-ReactomeAnalysisRequest-method.Rd ├── set_method.Rd ├── set_parameters-ReactomeAnalysisRequest-method.Rd ├── set_parameters.Rd ├── show-ReactomeAnalysisRequest-method.Rd ├── show-ReactomeAnalysisResult-method.Rd ├── split_clustering.Rd ├── split_random_sce.Rd ├── split_subclustering_sce.Rd ├── split_variable.Rd ├── split_variable_random.Rd ├── split_variable_sce.Rd ├── start_reactome_analysis.Rd └── wait_for_loading_dataset.Rd ├── tests ├── testthat.R └── testthat │ └── test_analysis_request.R └── vignettes ├── analysing-scRNAseq.Rmd ├── reanalysing-public-data.Rmd └── using-reactomegsa.Rmd /.gitignore: -------------------------------------------------------------------------------- 1 | inst/doc 2 | .Rproj.user 3 | .Rhistory 4 | .RData 5 | .Ruserdata 6 | ..Rcheck 7 | .Rbuildignore 8 | *.Rproj 9 | .vscode 10 | R/local_test.R 11 | vignettes/*.html 12 | vignettes/*.R 13 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Package 2 | Title: Client for the Reactome Analysis Service for comparative multi-omics gene set analysis 3 | Version: 1.21.2 4 | Authors@R: person("Johannes", "Griss", email = "johannes.griss@meduniwien.ac.at", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2206-9511")) 5 | Description: The ReactomeGSA packages uses Reactome's online analysis service to perform a multi-omics 6 | gene set analysis. The main advantage of this package is, that the retrieved results can be 7 | visualized using REACTOME's powerful webapplication. 8 | Since Reactome's analysis service also uses R to perfrom the actual gene set 9 | analysis you will get similar results when using the same packages (such as limma and edgeR) locally. 10 | Therefore, if you only require a gene set analysis, different packages are more suited. 11 | License: MIT + file LICENSE 12 | URL: https://github.com/reactome/ReactomeGSA 13 | BugReports: https://github.com/reactome/ReactomeGSA/issues 14 | Imports: 15 | Biobase, 16 | BiocSingular, 17 | dplyr, 18 | ggplot2, 19 | gplots, 20 | httr, 21 | igraph, 22 | jsonlite, 23 | methods, 24 | progress, 25 | RColorBrewer, 26 | SummarizedExperiment, 27 | tidyr 28 | Suggests: 29 | devtools, 30 | knitr, 31 | ReactomeGSA.data, 32 | rmarkdown, 33 | scater, 34 | scran, 35 | scRNAseq, 36 | scuttle, 37 | Seurat (>= 3.0), 38 | SingleCellExperiment, 39 | testthat 40 | VignetteBuilder: 41 | knitr 42 | biocViews: GeneSetEnrichment, Proteomics, Transcriptomics, SystemsBiology, 43 | GeneExpression, Reactome 44 | Encoding: UTF-8 45 | LazyData: false 46 | RoxygenNote: 7.3.2 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2019 2 | COPYRIGHT HOLDER: Johannes Griss 3 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(ReactomeAnalysisRequest) 4 | export(ReactomeAnalysisResult) 5 | export(add_dataset) 6 | export(analyse_sc_clusters) 7 | export(find_public_datasets) 8 | export(generate_metadata) 9 | export(generate_pseudo_bulk_data) 10 | export(get_public_species) 11 | export(get_reactome_analysis_result) 12 | export(get_reactome_analysis_status) 13 | export(get_reactome_data_types) 14 | export(get_reactome_methods) 15 | export(get_result) 16 | export(load_public_dataset) 17 | export(open_reactome) 18 | export(pathways) 19 | export(perform_reactome_analysis) 20 | export(plot_correlations) 21 | export(plot_gsva_heatmap) 22 | export(plot_gsva_pathway) 23 | export(plot_gsva_pca) 24 | export(plot_heatmap) 25 | export(plot_volcano) 26 | export(reactome_links) 27 | export(remove_dataset) 28 | export(result_types) 29 | export(set_method) 30 | export(set_parameters) 31 | export(start_reactome_analysis) 32 | exportClasses(ReactomeAnalysisResult) 33 | exportMethods(generate_metadata) 34 | exportMethods(generate_pseudo_bulk_data) 35 | exportMethods(names) 36 | exportMethods(print) 37 | exportMethods(show) 38 | import(httr) 39 | import(methods) 40 | importClassesFrom(Biobase,AnnotatedDataFrame) 41 | importClassesFrom(Biobase,ExpressionSet) 42 | importClassesFrom(Biobase,MIAME) 43 | importFrom(dplyr,any_of) 44 | importFrom(dplyr,select) 45 | importFrom(ggplot2,aes) 46 | importFrom(ggplot2,geom_hline) 47 | importFrom(ggplot2,geom_point) 48 | importFrom(ggplot2,ggplot) 49 | importFrom(ggplot2,labs) 50 | importFrom(gplots,heatmap.2) 51 | importFrom(methods,is) 52 | importFrom(tidyr,pivot_longer) 53 | importFrom(utils,URLencode) 54 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Changes in version 1.21.1 (2024-11-07) 2 | + Added new functions to perform quantitative comparative pathway analyses for scRNA-seq data. 3 | 4 | Changes in version 1.17.3 (2024-02-01) 5 | + Fixed a bug in vignette showcasing the reanalysis of public data. 6 | 7 | Changes in version 1.17.2 (2023-11-28) 8 | + Added a set of new functions to support ReactomeGSA's features to load public datasets. 9 | + Added a new vignette to showcase how public datasets can easily be loaded using the ReactomeGSA package. 10 | 11 | Changes in version 1.17.1 12 | + Fixed vignettes 13 | 14 | Changes in version 1.13.1 (2023-04-13) 15 | + Fixed documentation mismatch in "plot_heatmap" 16 | 17 | Changes in version 1.9.1 (2021-11-05) 18 | + Adapted default FDR threshold in "plot_heatmap" to match other functions. 19 | 20 | Changes in version 1.7.5 (2021-09-28) 21 | + Fixed documentation of "plot_heatmap" 22 | 23 | Changes in version 1.7.4 (2021-09-24) 24 | + Added new plotting function "plot_heatmap" 25 | 26 | Changes in version 1.7.3 (2021-09-14) 27 | + Updated vignette to introduce the "open_reactome" command 28 | 29 | Changes in version 1.7.2 (2021-09-09) 30 | + Fixed timeout issue during large requests in perform_reactome_analysis 31 | 32 | Changes in version 1.7.1 (2021-06-09) 33 | + Fixed bug in scRNA-seq vignette. 34 | 35 | Changes in version 1.5.2 (2021-04-16) 36 | + Added check to ensure that clustering was performed in Seurat objects prior to the pathway analysis. 37 | 38 | Changes in version 1.5.1 (2021-04-01) 39 | + Fixed bug in perform_reactome_analysis: Error messages were not displayed correctly. 40 | 41 | Changes in version 1.3.7 (2020-09-29) 42 | + Fixed bug in plot_gsva_pathway 43 | 44 | Changes in version 1.3.6 (2020-09-01) 45 | + Improved analyse_sc_clusters for SingleCellExperiment objects to define cell grouping using factors and a single character string specifying the metada field. 46 | 47 | Changes in version 1.3.4 (2020-09-01) 48 | + Fixed bug in analyse_sc_clusters when processing SingleCellExperiment objects. 49 | 50 | Changes in version 1.3.3 (2020-05-26) 51 | + Updated documentation 52 | 53 | Changes in version 1.3.2 (2020-05-26) 54 | + Added workaround for SEC_E_ILLEGAL_MESSAGE error on older Windows systems. 55 | 56 | Changes in version 1.3.1 (2020-04-29) 57 | + Added option to hide non-significant pathway in plot_correlations 58 | 59 | Changes in version 1.1.4 (2020-04-20) 60 | + bioRxiv paper is out! 61 | 62 | Changes in version 1.1.3 (2020-04-11) 63 | + Added custom function to calculate average cluster expression for Seurat objects 64 | 65 | Changes in version 1.1.2 (2020-03-13) 66 | + Add support manually track the status of submitted analyses 67 | + Added additional signature to add_dataset to support expression values as matrix 68 | 69 | Changes in version 1.1.1 (2020-02-19) 70 | + Compress JSON requests using gzip to improve performance for large datasets 71 | 72 | Changes in version 0.99.8 (2019-08-13) 73 | + Removed package startup message 74 | + Changed spelling of name to ReactomeGSA 75 | + Removed all default values from the method signatures 76 | + Added constructor function for the ReactomeAnalysisRequest class. 77 | 78 | Changes in version 0.99.7 (2019-07-22) 79 | + Adapted the get_reactome_methods function to provide a more readable overview 80 | + Changed to reactome analysis service API URL to the new domain name. 81 | 82 | Changes in version 0.99.6 (2019-07-09) 83 | + Minor bugfixes in examples 84 | 85 | Changes in version 0.99.5 (2019-07-09) 86 | + Updated vignette to new API data types 87 | + Added new function remove_dataset 88 | + Fixed bugs when overwriting existing datasets in AnalysisRequests 89 | + Fixed bug that pathways function did not sort the pathway table 90 | 91 | Changes in version 0.99.0 (2019-07-01) 92 | + Submitted to Bioconductor 93 | -------------------------------------------------------------------------------- /R/analyse_sc_clusters.R: -------------------------------------------------------------------------------- 1 | 2 | # analyse_sc_clusters methods ---- 3 | 4 | 5 | #' analyse_sc_clusters 6 | #' 7 | #' Analyses cell clusters of a single-cell RNA-sequencing 8 | #' experiment to get pathway-level expressions for every 9 | #' cluster of cells. 10 | #' 11 | #' There are currently two specific implementations of 12 | #' this function, one to support \code{Seurat} objects 13 | #' and one to support Bioconductor's \code{SingleCellExperiment} 14 | #' class. 15 | #' 16 | #' @param object The object containing the single-cell RNA-sequencing data. 17 | #' @param use_interactors If set (default), protein-protein interactors from IntAct are used to 18 | #' extend Reactome pathways. 19 | #' @param include_disease_pathways If set, disease pathways are included as well. Disease pathways in 20 | #' Reactome follow a different annotation approach and can therefore 21 | #' lead to inaccurate results. 22 | #' @param create_reactome_visualization If set, the interactive visualization in Reactome's PathwayBrowser 23 | #' is created. 24 | #' @param create_reports If set, PDF and Microsoft Excel reports are created. Links to these report files 25 | #' are send to the supplied e-mail address. 26 | #' @param report_email The e-mail address to which reports should be sent to. 27 | #' @param verbose If set, additional status messages are printed. 28 | #' @param ... Parameters passed to the specific implementation. Detailed documentations 29 | #' can be found there. 30 | #' 31 | #' @return A \code{\link{ReactomeAnalysisResult}} object. 32 | #' @export 33 | #' 34 | #' @examples 35 | #' # This example shows how a Seurat object can be analysed 36 | #' # the approach is identical for SingleCellExperiment objects 37 | #' library(ReactomeGSA.data) 38 | #' data(jerby_b_cells) 39 | #' 40 | #' # perform the GSVA analysis 41 | #' gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 42 | setGeneric("analyse_sc_clusters", function(object, use_interactors = TRUE, 43 | include_disease_pathways = FALSE, 44 | create_reactome_visualization = FALSE, 45 | create_reports = FALSE, 46 | report_email = NULL, 47 | verbose = FALSE, ...) standardGeneric("analyse_sc_clusters")) 48 | 49 | #' analyse_sc_clusters - Seurat 50 | #' 51 | #' @inherit analyse_sc_clusters 52 | #' 53 | #' @param object The \code{Seurat} object containing the single cell RNA-sequencing data. 54 | #' @param assay By default, the "RNA" assay is used, which contains the original read counts. 55 | #' @param slot The slot in the Seurat object to use. Default and recommended approach is to use the raw counts. 56 | setMethod("analyse_sc_clusters", c("object" = "Seurat"), function(object, use_interactors = TRUE, 57 | include_disease_pathways = FALSE, 58 | create_reactome_visualization = FALSE, 59 | create_reports = FALSE, 60 | report_email = NULL, 61 | verbose = FALSE, 62 | assay = "RNA", 63 | slot = "counts", ...) { 64 | # make sure the assay exists 65 | if (!assay %in% Seurat::Assays(object)) { 66 | stop("Error: Assay '", assay, "' does not exist in passed Seurat object.", call. = FALSE) 67 | } 68 | 69 | # get the data 70 | raw_data <- Seurat::GetAssayData(object, assay = assay, slot = slot) 71 | 72 | # get the identis 73 | cell_ids <- as.character( Seurat::Idents(object) ) 74 | 75 | if (length(unique(cell_ids)) < 2) { 76 | stop("Only one identification found: '", cell_ids[1], 77 | "'. Please ensure that cell / cluster ids are stored as the primary identification (Ident) of your Seurat object.", 78 | " Clustering has to be performed prior to this pathway analysis.", 79 | call. = FALSE) 80 | } 81 | 82 | # get the average counts 83 | if (verbose) message("Calculating average cluster expression...") 84 | 85 | av_counts <- apply(raw_data, 1, function(row_data) { 86 | by(row_data, cell_ids, mean) 87 | }) 88 | 89 | # convert to a data.frame 90 | av_counts <- t( data.frame(av_counts) ) 91 | 92 | # create the ReactomeGSA request 93 | request <- ReactomeGSA::ReactomeAnalysisRequest(method = "ssGSEA") 94 | 95 | # set the default request parameters 96 | request <- ReactomeGSA::set_parameters(request, use_interactors = use_interactors, 97 | include_disease_pathways = include_disease_pathways, 98 | create_reactome_visualization = create_reactome_visualization, 99 | create_reports = create_reports) 100 | 101 | if (!is.null(report_email)) { 102 | request <- ReactomeGSA::set_parameters(request, email = report_email) 103 | } 104 | 105 | # create the request object 106 | cell_groups <- colnames(av_counts) 107 | 108 | request <- ReactomeGSA::add_dataset(request, expression_values = av_counts, 109 | name = "Seurat", type = "rnaseq_counts", 110 | comparison_factor = "Cluster", comparison_group_1 = unique(cell_groups)[1], comparison_group_2 = unique(cell_groups)[2], 111 | sample_data = data.frame(row.names = cell_groups, Cluster = cell_groups)) 112 | 113 | # run the analysis 114 | gsa_res <- ReactomeGSA::perform_reactome_analysis(request, verbose = verbose) 115 | 116 | return(gsa_res) 117 | }) 118 | 119 | #' analyse_sc_clusters - SingleCellExperiment 120 | #' 121 | #' @param cell_ids A factor specifying the group to which each cell belongs. For example, \code{object$cluster}. 122 | #' Alternatively, a string specifying the metada field's name may be passed. 123 | #' @inherit analyse_sc_clusters 124 | #' 125 | #' @param object The \code{SingleCellExperiment} object containing the single cell RNA-sequencing data. 126 | #' @param ... Parameters passed to scater's \code{aggregateAcrossCells} function. 127 | setMethod("analyse_sc_clusters", c("object" = "SingleCellExperiment"), function(object, use_interactors = TRUE, 128 | include_disease_pathways = FALSE, 129 | create_reactome_visualization = FALSE, 130 | create_reports = FALSE, 131 | report_email = NULL, 132 | verbose = FALSE, 133 | cell_ids, ...) { 134 | # make sure scater is available 135 | if (!requireNamespace("scater")) { 136 | stop("Error: This function requires 'scater'. Please install it using BiocManager::install(\"scater\")") 137 | } 138 | 139 | # check if cell_ids specifies a metadata field 140 | if (is.character(cell_ids) && length(cell_ids) == 1) { 141 | if (verbose) message("Using metadata field '", cell_ids, "' for cell grouping.") 142 | 143 | if (!cell_ids %in% colnames(SingleCellExperiment::colData(object))) { 144 | stop("Error: Failed to find metadata field '", cell_ids, "'", call. = FALSE) 145 | } 146 | 147 | # get the metadata 148 | cell_ids <- SingleCellExperiment::colData(object)[, cell_ids] 149 | } 150 | 151 | # create the parameters for the AverageExpression call 152 | scater_params <- list(...) 153 | scater_params[["x"]] <- object 154 | scater_params[["ids"]] = cell_ids 155 | 156 | # get the count data 157 | if (verbose) message("Calculating average expression per cluster...") 158 | agg_counts <- do.call(scater::aggregateAcrossCells, scater_params) 159 | counts <- SingleCellExperiment::counts(agg_counts) 160 | 161 | # create the ReactomeGSA request 162 | request <- ReactomeGSA::ReactomeAnalysisRequest(method = "ssGSEA") 163 | 164 | # set the default request parameters 165 | request <- ReactomeGSA::set_parameters(request, use_interactors = use_interactors, 166 | include_disease_pathways = include_disease_pathways, 167 | create_reactome_visualization = create_reactome_visualization, 168 | create_reports = create_reports) 169 | 170 | if (!is.null(report_email)) { 171 | request <- ReactomeGSA::set_parameters(request, email = report_email) 172 | } 173 | 174 | # create the request object 175 | df_counts <- data.frame(counts) 176 | cell_groups <- colnames(df_counts) 177 | 178 | request <- ReactomeGSA::add_dataset(request, expression_values = df_counts, 179 | name = "Seurat", type = "rnaseq_counts", 180 | comparison_factor = "Cluster", comparison_group_1 = unique(cell_groups)[1], comparison_group_2 = unique(cell_groups)[2], 181 | sample_data = data.frame(row.names = cell_groups, Cluster = cell_groups)) 182 | 183 | # run the analysis 184 | gsa_res <- ReactomeGSA::perform_reactome_analysis(request, verbose = verbose) 185 | 186 | return(gsa_res) 187 | }) -------------------------------------------------------------------------------- /R/generate_metadata.R: -------------------------------------------------------------------------------- 1 | #' generate_metadata 2 | #' 3 | #' The pseudobulk data is generated using the 4 | #' \code{\link{generate_pseudo_bulk_data}} function. 5 | #' 6 | #' @param pseudo_bulk_data Pseudobulk data generated from the 7 | #' \code{\link{generate_pseudo_bulk_data}} function 8 | #' @returns Metadata table for later use 9 | #' 10 | #' @examples 11 | #' # Example pseudobulk data 12 | #' pseudo_bulk_data <- data.frame( 13 | #' sample1_groupA = c(10, 20, 30), 14 | #' sample2_groupA = c(15, 25, 35), 15 | #' sample3_groupB = c(5, 10, 15) 16 | #' ) 17 | #' 18 | #' # Generate metadata from pseudobulk data 19 | #' metadata <- generate_metadata(pseudo_bulk_data) 20 | #' 21 | #' @seealso \code{\link{generate_pseudo_bulk_data}} for 22 | #' generating pseudobulk data. 23 | #' @export 24 | setGeneric("generate_metadata", function(pseudo_bulk_data) { 25 | standardGeneric("generate_metadata") 26 | }) 27 | 28 | #' Generate metadata 29 | #' 30 | #' @param pseudo_bulk_data Pseudobulk data generated from the 31 | #' \code{\link{generate_pseudo_bulk_data}} function 32 | #' 33 | #' @returns Returns metadata table for later use 34 | #' 35 | #' @export 36 | setMethod("generate_metadata", c("pseudo_bulk_data" = "data.frame"), function(pseudo_bulk_data) { 37 | cols <- colnames(pseudo_bulk_data) 38 | groups <- sapply(strsplit(cols, "_"), `[`, 1) 39 | 40 | metadata <- data.frame( 41 | Group = groups 42 | ) 43 | 44 | colnames(metadata) <- "Group" 45 | metadata$index_use <- colnames(pseudo_bulk_data) 46 | rownames(metadata) <- metadata$index_use 47 | metadata$index_use <- NULL 48 | 49 | return(metadata) 50 | }) 51 | -------------------------------------------------------------------------------- /R/get_methods.R: -------------------------------------------------------------------------------- 1 | #' get_reactome_methods 2 | #' 3 | #' Returns all available analysis methods from the Reactome analysis service. 4 | #' 5 | #' Every method has a type, a scope, and sometimes a list of allowed values. The type (string, int = integer, float) define 6 | #' the expected data type. The \strong{scope} defines at what level the parameter can be set. \emph{dataset} level parameters 7 | #' can be set at the dataset level (using the \code{\link{add_dataset}} function) or at the analysis request level (using 8 | #' \code{\link{set_parameters}}). If these parameters are set at the analysis request level, this overwrites the default 9 | #' value for all datasets. \emph{analysis} and \emph{global} level parameters must only be set at the analysis request level 10 | #' using \code{\link{set_parameters}}. The difference between these two types of parameters is that while \emph{analysis} 11 | #' parameters influence the results, \emph{global} parameters only influence the behaviour of the analysis system (for example 12 | #' whether a Reactome visualization is created). 13 | #' 14 | #' @param print_methods If set to \code{TRUE} (default) a (relatively) nice formatted version of the result is printed. 15 | #' @param print_details If set to \code{TRUE} detailed information about every method, including available parameters and 16 | #' description are displayed. This does not affect the data returned if \code{return_result} is \code{TRUE}. 17 | #' @param return_result If set to \code{TRUE}, the result is returned as a data.frame (see below) 18 | #' @param method If set to a method's id, only information for this method will be shown. This is especially useful if 19 | #' detailed information about a single method should be retrieved. This does not affect the data returned 20 | #' if \code{return_result} is \code{TRUE}. 21 | #' @param reactome_url URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 22 | #' Specific ports can be set using the standard URL specification (for example http://your.service:1234) 23 | #' @return If \code{return_result} is set to \code{TRUE}, a data.frame with one row per method. Each method has a name, description, and 24 | #' (optional) a list of parameters. Parameters again have a name, type, and description. 25 | #' @author Johannes Griss 26 | #' @export 27 | #' @importFrom methods is 28 | #' 29 | #' @family Reactome Service functions 30 | #' 31 | #' @examples 32 | #' # retrieve the available methods only in an object 33 | #' available_methods <- get_reactome_methods(print_methods = FALSE, return_result = TRUE) 34 | #' 35 | #' # print all method names 36 | #' available_methods$name 37 | #' 38 | #' # list all parameters for the first method 39 | #' first_method_parameters <- available_methods[1, "parameters"] 40 | #' first_method_parameters 41 | #' 42 | #' # simply print the available methods 43 | #' get_reactome_methods() 44 | #' 45 | #' # get the details for PADOG 46 | #' get_reactome_methods(print_details = TRUE, method = "PADOG") 47 | get_reactome_methods <- function(print_methods = TRUE, print_details = FALSE, return_result = FALSE, method = NULL, reactome_url = NULL) { 48 | reactome_url <- check_reactome_url(reactome_url) 49 | 50 | # fetch the methods 51 | available_methods <- jsonlite::fromJSON(paste0(reactome_url, "0.1/methods")) 52 | 53 | # print a nice version of the methods 54 | if (print_methods) { 55 | for (n_method in seq(to = nrow(available_methods))) { 56 | # ignore all methods that are not "method" if set 57 | if (!is.null(method) && tolower(available_methods[n_method, "name"]) != tolower(method)) { 58 | next 59 | } 60 | 61 | # show a box around the method name if details are shown 62 | if (print_details) { 63 | method_name_length = nchar(available_methods[n_method, "name"]) 64 | cat("+-", rep("-", method_name_length), "--+\n", sep = "") 65 | cat("| ", available_methods[n_method, "name"], ": |\n", sep = "") 66 | cat("+-", rep("-", method_name_length), "--+\n\n", sep = "") 67 | cat(available_methods[n_method, "description"], "\n\n") 68 | cat("Parameters:\n") 69 | if ("parameters" %in% colnames(available_methods) && is(available_methods[n_method, "parameters"], "list")) { 70 | parameter_df = available_methods[n_method, "parameters"][[1]] 71 | for (n_param in seq(to = nrow(parameter_df))) { 72 | cat("- ", parameter_df[n_param, "name"], "\n", sep = "") 73 | cat(" Type: ", parameter_df[n_param, "type"], "\n", sep = "") 74 | cat(" Default: ", parameter_df[n_param, "default"], "\n", sep = "") 75 | cat(" Scope: ", parameter_df[n_param, "scope"], "\n", sep = "") 76 | if (!is.null(parameter_df[n_param, "values"]) && parameter_df[n_param, "values"] != "NULL") { 77 | cat(" Allowed values: ", paste0(parameter_df[n_param, "values"][[1]], collapse = ", "), "\n", sep = "") 78 | } 79 | cat(" Description: ", parameter_df[n_param, "description"], "\n", sep = "") 80 | } 81 | } 82 | 83 | cat("\n") 84 | } else { 85 | # only print the method name if no details are set 86 | cat(available_methods[n_method, "name"], ": ", available_methods[n_method, "description"], "\n", sep = "") 87 | } 88 | } 89 | } 90 | 91 | if (return_result) { 92 | return(available_methods) 93 | } 94 | } 95 | 96 | #' ReactomeGSA supported data types 97 | #' 98 | #' @param print_types If set to \code{TRUE} (default) a (relatively) nice formatted version of the result is printed. 99 | #' @param return_result If set to \code{TRUE}, the result is returned as a data.frame (see below) 100 | #' @param reactome_url URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 101 | #' Specific ports can be set using the standard URL specification (for example http://your.service:1234) 102 | #' @return A \code{data.frame} containing one row per data type with its \code{id} and \code{description}. 103 | #' @author Johannes Griss 104 | #' @export 105 | #' @family Reactome Service functions 106 | #' 107 | #' @examples 108 | #' # retrieve the avialable data types 109 | #' available_types <- get_reactome_data_types(print_types = FALSE, return_result = TRUE) 110 | #' 111 | #' # print all data type ids 112 | #' available_types$id 113 | #' 114 | #' # simply print the available methods 115 | #' get_reactome_data_types() 116 | get_reactome_data_types <- function(print_types = TRUE, return_result = FALSE, reactome_url = NULL) { 117 | reactome_url <- check_reactome_url(reactome_url) 118 | 119 | # fetch the types 120 | available_types <- jsonlite::fromJSON(paste0(reactome_url, "0.1/types")) 121 | 122 | # print a nice version of the methods 123 | if (print_types) { 124 | for (n_type in seq(to = nrow(available_types))) { 125 | cat(available_types[n_type, "id"], ":\n", sep = "") 126 | cat(" ", available_types[n_type, "name"], "\n ", available_types[n_type, "description"], "\n") 127 | } 128 | } 129 | 130 | if (return_result) { 131 | return(available_types) 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /R/get_result.R: -------------------------------------------------------------------------------- 1 | #' Retrieves the status of the submitted analysis using \code{\link{start_reactome_analysis}} 2 | #' 3 | #' @param analysis_id The running analysis' id 4 | #' @param reactome_url URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 5 | #' Specific ports can be set using the standard URL specification (for example http://your.service:1234) 6 | #' 7 | #' @return A list containing the \code{id}, \code{status} (can be "running", "complete", "failed"), 8 | #' \code{description}, and \code{completed} (numeric between 0 - 1) 9 | #' 10 | #' @export 11 | get_reactome_analysis_status <- function(analysis_id, reactome_url = NULL) { 12 | reactome_url <- check_reactome_url(reactome_url) 13 | 14 | # get the status - on error return a default status 15 | status_obj <- tryCatch( 16 | jsonlite::fromJSON(paste0(reactome_url, "0.1/status/", analysis_id)), 17 | error = function(e) list(completed = 0, description = "Unknown", status = "running") 18 | ) 19 | 20 | return(status_obj) 21 | } 22 | 23 | #' Retrieves the result of the submitted analysis using \code{\link{perform_reactome_analysis}} 24 | #' 25 | #' The result is only available if \code{\link{get_reactome_analysis_status}} indicates that the 26 | #' analysis is complete. 27 | #' 28 | #' @param analysis_id The running analysis' id 29 | #' @param reactome_url URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 30 | #' Specific ports can be set using the standard URL specification (for example http://your.service:1234) 31 | #' 32 | #' @return The result object 33 | #' 34 | #' @export 35 | get_reactome_analysis_result <- function(analysis_id, reactome_url = NULL) { 36 | reactome_url <- check_reactome_url(reactome_url) 37 | 38 | # get the status 39 | result_obj <- jsonlite::fromJSON(paste0(reactome_url, "0.1/result/", analysis_id)) 40 | 41 | # create the ReactomeAnalysisResult object 42 | reactome_obj <- convert_reactome_result(result_obj) 43 | 44 | return(reactome_obj) 45 | } 46 | -------------------------------------------------------------------------------- /R/gsva_plotting_functions.R: -------------------------------------------------------------------------------- 1 | #' plot_gsva_pathway 2 | #' 3 | #' Plots the expression of a specific pathway from a ssGSEA result. 4 | #' 5 | #' @param object The \code{\link{ReactomeAnalysisResult}} object. 6 | #' @param pathway_id The pathway's id 7 | #' @param ... Additional parameters for specific implementations. 8 | #' 9 | #' @return A ggplot2 plot object 10 | #' @export 11 | #' @importFrom ggplot2 ggplot aes geom_point geom_hline labs 12 | #' @family ReactomeAnalysisResult functions 13 | #' 14 | #' @examples 15 | #' # load the scRNA-seq example data 16 | #' library(ReactomeGSA.data) 17 | #' data(jerby_b_cells) 18 | #' 19 | #' # perform the GSVA analysis 20 | #' gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 21 | #' 22 | #' # create the plot 23 | #' plot_obj <- plot_gsva_pathway(gsva_result, "R-HSA-389542") 24 | setGeneric("plot_gsva_pathway", function(object, pathway_id, ...) callGeneric("plot_gsva_pathway")) 25 | 26 | #' ReactomeAnalysisResult - plot_gsva_pathway 27 | #' 28 | #' @inherit plot_gsva_pathway 29 | setMethod("plot_gsva_pathway", c("object" = "ReactomeAnalysisResult"), function(object, pathway_id, ...) { 30 | # make sure it is a GSVA result 31 | if (!is_gsva_result(object)) { 32 | stop("ReactomeAnalysisResult object does not represent a GSVA result (choose method 'ssGSEA' during the analysis)") 33 | } 34 | 35 | gsa_pathways <- pathways(object) 36 | 37 | # get the pathway 38 | if (!pathway_id %in% rownames(gsa_pathways)) { 39 | stop("Error: Unknown pathway ", pathway_id) 40 | } 41 | 42 | pathway_name <- gsa_pathways[pathway_id, "Name"] 43 | 44 | # remove the name 45 | gsa_pathways$Name <- NULL 46 | 47 | # fix the column names 48 | colnames(gsa_pathways) <- gsub("\\.[^.]*$", "", colnames(gsa_pathways)) 49 | colnames(gsa_pathways) <- gsub("\\.", " ", colnames(gsa_pathways)) 50 | 51 | # get the data.frame for ggplot 52 | plot_data <- data.frame( 53 | cluster_id = colnames(gsa_pathways), 54 | expr = as.numeric(gsa_pathways[pathway_id, ]) 55 | ) 56 | 57 | sorted_ids <- plot_data$cluster_id[order(plot_data$expr)] 58 | plot_data$cluster_id <- factor(plot_data$cluster_id, levels = unique(sorted_ids)) 59 | 60 | plot_obj <- ggplot2::ggplot(plot_data, ggplot2::aes(x = cluster_id, y = expr)) + 61 | ggplot2::geom_bar(stat = "identity") + 62 | ggplot2::labs(x = "Cluster", y = "Pathway expression", title = paste0(pathway_name, "(", pathway_id, ")")) + 63 | ggplot2::theme_bw() + 64 | ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust = 1)) 65 | 66 | return(plot_obj) 67 | }) 68 | 69 | # plot_gsva_heatmap functions ---- 70 | 71 | #' plot_gsva_heatmap 72 | #' 73 | #' Plots pathway expression values / sample as a heatmap. Ranks pathways based on their 74 | #' expression difference. 75 | #' 76 | #' @param object The \code{\link{ReactomeAnalysisResult}} object. 77 | #' @param pathway_ids A vector of pathway ids. If set, only these pathways are included in the plot. 78 | #' @param max_pathways The maximum number of pathways to include. Only takes effect if \code{pathway_ids} 79 | #' is not set. 80 | #' @param truncate_names If set, long pathway names are truncated. 81 | #' @param ... Additional parameters passed to specific implementations. 82 | #' 83 | #' @return None 84 | #' @family ReactomeAnalysisResult functions 85 | #' @export 86 | #' 87 | #' @examples 88 | #' # load the scRNA-seq example data 89 | #' library(ReactomeGSA.data) 90 | #' data(jerby_b_cells) 91 | #' 92 | #' # perform the GSVA analysis 93 | #' gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 94 | #' 95 | #' # plot the heatmap 96 | #' relevant_pathways <- c("R-HSA-983170", "R-HSA-388841", "R-HSA-2132295", 97 | #' "R-HSA-983705", "R-HSA-5690714") 98 | #' plot_gsva_heatmap(gsva_result, 99 | #' pathway_ids = relevant_pathways, # limit to these pathways 100 | #' margins = c(6,30), # adapt the figure margins in heatmap.2 101 | #' dendrogram = "col", # only plot column dendrogram 102 | #' scale = "row", # scale for each pathway 103 | #' key = FALSE, # don't display the color key 104 | #' lwid=c(0.1,4)) # remove the white space on the left 105 | setGeneric("plot_gsva_heatmap", function(object, pathway_ids = NULL, max_pathways = 20, truncate_names = TRUE, ...) callGeneric("plot_gsva_heatmap")) 106 | 107 | #' plot_gsva_heatmap - ReactomeAnalysisResult function 108 | #' 109 | #' @param ... Additional parameters passed to the heatmap.2 function. 110 | #' 111 | #' @importFrom gplots heatmap.2 112 | #' @inherit plot_gsva_heatmap 113 | setMethod("plot_gsva_heatmap", c("object" = "ReactomeAnalysisResult"), function(object, pathway_ids = NULL, max_pathways = 20, truncate_names = TRUE, ...) { 114 | # make sure it is a GSVA result 115 | if (!is_gsva_result(object)) { 116 | stop("ReactomeAnalysisResult object does not represent a GSVA result (choose method 'ssGSEA' during the analysis)") 117 | } 118 | 119 | gsa_pathways <- pathways(object) 120 | 121 | # sort the pathways based on their difference 122 | max_difference <- do.call(rbind, apply(gsa_pathways, 1, function(row) { 123 | values <- as.numeric(row[2:length(row)]) 124 | return(data.frame(name = row[1], min = min(values), max = max(values))) 125 | })) 126 | 127 | max_difference$diff <- max_difference$max - max_difference$min 128 | 129 | gsa_pathways <- gsa_pathways[order(max_difference$diff, decreasing = T), ] 130 | 131 | # get the pathways to plot 132 | if (!is.null(pathway_ids)) { 133 | # make sure all pathways exist 134 | if (!all(pathway_ids %in% rownames(gsa_pathways))) { 135 | warning("Warning: No results for the following pathways: ", paste(pathway_ids[!pathway_ids %in% rownames(gsa_pathways)], collapse = ", ", sep = ", ")) 136 | 137 | pathway_ids <- pathway_ids[pathway_ids %in% rownames(gsa_pathways)] 138 | } 139 | } else { 140 | # use the top different pathways 141 | if (nrow(gsa_pathways) > max_pathways) { 142 | pathway_ids <- rownames(gsa_pathways)[1:max_pathways] 143 | } else { 144 | pathway_ids <- rownames(gsa_pathways) 145 | } 146 | } 147 | 148 | # get the expression values as a matrix 149 | expression_matrix <- as.matrix(gsa_pathways[pathway_ids, 2:ncol(gsa_pathways)]) 150 | 151 | # remove the redundant dataset name 152 | if (length(names(object)) == 1) { 153 | colnames(expression_matrix) <- gsub("\\.[^\\.]*$", "", colnames(expression_matrix)) 154 | } 155 | 156 | # use pathway names 157 | rownames(expression_matrix) <- gsa_pathways[rownames(expression_matrix), "Name"] 158 | 159 | # shorten the names 160 | if (truncate_names) { 161 | is_long <- nchar(rownames(expression_matrix)) > 40 162 | rownames(expression_matrix)[is_long] <- paste0(substr(rownames(expression_matrix)[is_long], 1, 32), "...") 163 | } 164 | 165 | # merge default with user parameters 166 | heatmap_params <- list( 167 | x = expression_matrix, 168 | margins = c(6, 15), 169 | density.info = "none", 170 | trace = "none", 171 | col = RColorBrewer::brewer.pal(9, "RdYlBu")) 172 | 173 | user_params <- list(...) 174 | for (param_name in names(user_params)) { 175 | if (nchar(param_name) > 0) { 176 | heatmap_params[[param_name]] <- user_params[[param_name]] 177 | } 178 | } 179 | 180 | # create the heatmap 181 | do.call(gplots::heatmap.2, heatmap_params) 182 | }) 183 | 184 | # plot_gsva_pca ---- 185 | 186 | #' plot_gsva_pca 187 | #' 188 | #' Runs a Principal Component analysis (using \code{prcomp}) on the samples 189 | #' based on the pathway analysis results. 190 | #' 191 | #' @param object A \code{\link{ReactomeAnalysisResult}} object containing a ssGSEA result 192 | #' @param pathway_ids A character vector of pathway ids. If set, only these pathways will be 193 | #' used for the PCA analysis. 194 | #' @param ... Additional paramters passed to specific implementations. 195 | #' 196 | #' @return A ggplot2 object representing the plot. 197 | #' @export 198 | #' 199 | #' @examples 200 | #' # load the scRNA-seq example data 201 | #' library(ReactomeGSA.data) 202 | #' data(jerby_b_cells) 203 | #' 204 | #' # perform the GSVA analysis 205 | #' gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 206 | setGeneric("plot_gsva_pca", function(object, pathway_ids = NULL, ...) callGeneric("plot_gsva_pca")) 207 | 208 | #' plot_gsva_pca - ReactomeAnalysisResult 209 | #' 210 | #' @param ... Additional parameters are passed to \code{prcomp} 211 | #' 212 | #' @inherit plot_gsva_pca 213 | setMethod("plot_gsva_pca", c("object" = "ReactomeAnalysisResult"), function(object, pathway_ids = NULL, ...) { 214 | if (!is_gsva_result(object)) { 215 | stop("ReactomeAnalysisResult object does not represent a GSVA result (choose method 'ssGSEA' during the analysis)") 216 | } 217 | 218 | gsa_pathways <- pathways(object) 219 | 220 | # get the pathways to plot 221 | if (!is.null(pathway_ids)) { 222 | # make sure all pathways exist 223 | if (!all(pathway_ids %in% rownames(gsa_pathways))) { 224 | warning("Warning: No results for the following pathways: ", paste(pathway_ids[!pathway_ids %in% rownames(gsa_pathways)], collapse = ", ", sep = ", ")) 225 | 226 | pathway_ids <- pathway_ids[pathway_ids %in% rownames(gsa_pathways)] 227 | } 228 | } else { 229 | pathway_ids <- rownames(gsa_pathways) 230 | } 231 | 232 | # get the expression values as a matrix 233 | expression_matrix <- as.matrix(gsa_pathways[pathway_ids, 2:ncol(gsa_pathways)]) 234 | 235 | # remove the redundant dataset name 236 | if (length(names(gsva_result)) == 1) { 237 | colnames(expression_matrix) <- gsub("\\.[^\\.]*$", "", colnames(expression_matrix)) 238 | } 239 | 240 | # perform the PCA 241 | prcomp_params <- list(x = expression_matrix) 242 | 243 | user_params = list(...) 244 | for (param_name in names(user_params)) { 245 | if (nchar(param_name) > 0 ) { 246 | prcomp_params[[param_name]] <- user_params[[param_name]] 247 | } 248 | } 249 | 250 | pca_fit <- do.call(stats::prcomp, prcomp_params) 251 | pca_summary <- summary(pca_fit) 252 | 253 | # create the data for ggplot 254 | plot_data <- data.frame(pca_fit$rotation) 255 | plot_data$sample <- rownames(pca_fit$rotation) 256 | 257 | # get the proportion of variance 258 | prop_var_x <- round(pca_summary$importance["Proportion of Variance", "PC1"] * 100, 1) 259 | prop_var_y <- round(pca_summary$importance["Proportion of Variance", "PC2"] * 100, 1) 260 | 261 | plot_obj <- ggplot2::ggplot(plot_data, ggplot2::aes(x = PC1, y = PC2, color = sample)) + 262 | ggplot2::geom_point(size = 3) + 263 | ggplot2::labs(x = paste0("PC1 (", prop_var_x, "% var. expl.)"), y = paste0("PC2 (", prop_var_y, "% var. expl.)")) + 264 | ggplot2::theme_bw() 265 | 266 | return(plot_obj) 267 | }) 268 | 269 | #' is_gsva_result 270 | #' 271 | #' @param object A \code{\link{ReactomeAnalysisResult}} object 272 | #' 273 | #' @return Boolean indicating whether the object is a GSVA result. 274 | #' 275 | is_gsva_result <- function(object) { 276 | # must contain the "pathways" result 277 | if (!"pathways" %in% ReactomeGSA::result_types(object)) { 278 | return(FALSE) 279 | } 280 | 281 | # must not contain the FDR column 282 | for (dataset in names(object)) { 283 | if ("FDR" %in% colnames(ReactomeGSA::get_result(object, "pathways", dataset))) { 284 | return(FALSE) 285 | } 286 | } 287 | 288 | return(TRUE) 289 | } -------------------------------------------------------------------------------- /R/on_load.R: -------------------------------------------------------------------------------- 1 | .onLoad <- function(libname, pkgname) { 2 | op <- options() 3 | op.reactome_gsa <- list( 4 | reactome_gsa.url = "https://gsa.reactome.org/" 5 | ) 6 | toset <- !(names(op.reactome_gsa) %in% names(op)) 7 | if(any(toset)) options(op.reactome_gsa[toset]) 8 | 9 | invisible() 10 | } 11 | 12 | .onAttach <- function(libname, pkgname) { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /R/perform_analysis.R: -------------------------------------------------------------------------------- 1 | #' Perform a Reactome Analaysis 2 | #' 3 | #' This function wraps all steps required to perform 4 | #' an Analysis using the Reactome Analysis Service. It submits 5 | #' the passed \code{\link{ReactomeAnalysisRequest}} object to the 6 | #' Reactome Analysis Service API, checks the submitted analysis' 7 | #' status and returns the result once the analysis is complete. 8 | #' 9 | #' @param request \code{\link{ReactomeAnalysisRequest}} to submit. 10 | #' @param verbose logical. If \code{FALSE} status messages are not printed to the console. 11 | #' @param compress logical. If \code{TRUE} (default) the request data is compressed before submitting it to the ReactomeGSA API. 12 | #' This is the generally recommended way and should only be disabled for debugging purposes. 13 | #' @param reactome_url URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 14 | #' Specific ports can be set using the standard URL specification (for example http://your.service:1234) 15 | #' 16 | #' @return The analysis' result 17 | #' @export 18 | #' 19 | #' @examples 20 | #' # create a request using Camera as an analysis 21 | #' library(ReactomeGSA.data) 22 | #' data(griss_melanoma_proteomics) 23 | #' 24 | #' my_request <- ReactomeAnalysisRequest(method = "Camera") 25 | #' 26 | #' # set maximum missing values to 0.5 and do not create any reactome visualizations 27 | #' my_request <- set_parameters(request = my_request, 28 | #' max_missing_values = 0.5, 29 | #' create_reactome_visualization = FALSE) 30 | #' 31 | #' # add the dataset 32 | #' my_request <- add_dataset(request = my_request, 33 | #' expression_values = griss_melanoma_proteomics, 34 | #' name = "Proteomics", 35 | #' type = "proteomics_int", 36 | #' comparison_factor = "condition", 37 | #' comparison_group_1 = "MOCK", 38 | #' comparison_group_2 = "MCM", 39 | #' additional_factors = c("cell.type", "patient.id")) 40 | #' 41 | #' # perform the analysis 42 | #' my_result <- perform_reactome_analysis(request = my_request, verbose = FALSE) 43 | perform_reactome_analysis <- function(request, verbose = TRUE, compress = TRUE, reactome_url = NULL) { 44 | if (!methods::is(request, "ReactomeAnalysisRequest")) { 45 | stop("Error: request must be a 'ReactomeAnalysisRequest' object.") 46 | } 47 | 48 | # submit the request 49 | if (verbose) message("Submitting request to Reactome API...") 50 | analysis_id <- start_reactome_analysis(request = request, compress = compress, reactome_url = reactome_url) 51 | 52 | # get the status 53 | completed <- get_reactome_analysis_status(analysis_id, reactome_url) 54 | 55 | # create a progress bar 56 | if (verbose) { 57 | pb <- progress::progress_bar$new(total = 100, format = "Running analysis [:bar:]", show_after = 0) 58 | 59 | pb$message(completed[["description"]]) 60 | 61 | if (is.numeric(completed[["completed"]])) 62 | pb$update(as.numeric(completed[["completed"]])) 63 | 64 | last_message <- completed[["description"]] 65 | } 66 | 67 | # loop until the analysis is done 68 | 69 | # this only tracks whether the progress bar reached completion as any update afterwards 70 | # causes an error 71 | is_done <- FALSE 72 | error_count <- 0 73 | 74 | while (completed[["status"]] == "running") { 75 | Sys.sleep(1) 76 | 77 | completed <- tryCatch({ 78 | get_reactome_analysis_status(analysis_id, reactome_url) 79 | }, 80 | error=function(cond) { 81 | # simply ignore this the first 10 times 82 | if (error_count < 10) { 83 | error_count <- error_count + 1 84 | return(completed) 85 | } 86 | 87 | # fail if the error count is too high 88 | stop("Error: Failed to connect to ReactomeGSA. Please contact support if this error persists at help@reactome.org", call. = FALSE) 89 | }) 90 | 91 | if (verbose) { 92 | current_message <- completed[["description"]] 93 | 94 | # only update the message if it's different and the process is still running 95 | if (current_message != last_message && completed[["status"]] == "running" && !is_done) { 96 | pb$message(current_message) 97 | last_message <- current_message 98 | } 99 | 100 | # only update the progress if it didn't reach "1" before, otherwise this throws an error 101 | if (!is_done) { 102 | rel_completed <- as.numeric(completed[["completed"]]) 103 | 104 | pb$update(rel_completed) 105 | 106 | # prevent future progress bar updates 107 | if (rel_completed == 1) { 108 | is_done <- TRUE 109 | } 110 | } 111 | } 112 | } 113 | 114 | # test if the analysis failed 115 | if (completed[["status"]] == "failed") { 116 | if (verbose) warning("Reactome Analysis failed: ", completed[["description"]]) 117 | return(NULL) 118 | } 119 | 120 | # retrieve the result 121 | if (verbose) message("Retrieving result...") 122 | result <- get_reactome_analysis_result(analysis_id = analysis_id) 123 | 124 | return(result) 125 | } 126 | -------------------------------------------------------------------------------- /R/plotting_functions.R: -------------------------------------------------------------------------------- 1 | #' plot_volcano 2 | #' 3 | #' Creates a volcano plot for the pathway analysis result. Every point represents one 4 | #' pathway, the x-axis the log fold-change and the y-axis the adjusted p-value (-log10). 5 | #' 6 | #' This function is only available for GSA-based analysis results. 7 | #' 8 | #' @param x ReactomeAnalysisResult. The analysis result to plot the volcano plot for. 9 | #' @param ... Additional parameters for specific implementations. 10 | #' 11 | #' @return A ggplot2 plot object representing the volcano plot. 12 | #' @export 13 | #' @importFrom ggplot2 ggplot aes geom_point geom_hline labs 14 | #' 15 | #' @family ReactomeAnalysisResult functions 16 | #' 17 | #' @examples 18 | #' # load an example result 19 | #' library(ReactomeGSA.data) 20 | #' data(griss_melanoma_result) 21 | #' 22 | #' # create the volcano plot for the first dataset 23 | #' plot_obj <- plot_volcano(griss_melanoma_result) 24 | #' 25 | #' # display the plot using `print(plot_obj)` 26 | setGeneric("plot_volcano", function(x, ...) standardGeneric("plot_volcano")) 27 | 28 | #' ReactomeAnalysisResult - plot_volcano 29 | #' 30 | #' @param dataset The name or index of the dataset to plot (first one by default). 31 | #' 32 | #' @inherit plot_volcano 33 | setMethod("plot_volcano", c("x" = "ReactomeAnalysisResult"), function(x, dataset = 1, ...) { 34 | # convert numeric dataset indices to the name 35 | if (is.numeric(dataset)) { 36 | if (dataset > length(names(x@results))) { 37 | stop("Error: Dataset index ", dataset, " is out of bounds. Result object only contains ", length(names(x)), " datasets.") 38 | } 39 | 40 | if (dataset < 1) { 41 | stop("Error: Index must be 1-based") 42 | } 43 | 44 | dataset <- names(x)[dataset] 45 | } 46 | 47 | # make sure the dataset exists 48 | if (!dataset %in% names(x@results)) { 49 | stop("Error: Failed to find dataset '", dataset, "' in ReactomeAnalysisResult") 50 | } 51 | 52 | # make sure the pathways result exists 53 | if (!"pathways" %in% names(x@results[[dataset]])) { 54 | stop("Error: No pathway results available for dataset '", dataset, "'") 55 | } 56 | 57 | # make sure it's a GSA result 58 | if (!"av_foldchange" %in% colnames(x@results[[dataset]][["pathways"]])) { 59 | stop("Error: plot_volcano is only available for GSA-based results") 60 | } 61 | 62 | plot_obj <- ggplot2::ggplot(x@results[[dataset]][["pathways"]], ggplot2::aes(x = av_foldchange, y = -log10(FDR))) + 63 | ggplot2::geom_point() + 64 | ggplot2::geom_hline(yintercept = -log10(0.05), color = "#CC333F", linetype = 2) + 65 | ggplot2::geom_hline(yintercept = -log10(0.01), color = "#00A0B0", linetype = 2) + 66 | ggplot2::labs(x = "average log2 fold-change", y = "adjusted p-value (-log10)", title = dataset) 67 | 68 | return(plot_obj) 69 | }) 70 | 71 | # plot_correlations -------------------------------------------------------- 72 | 73 | #' plot_correlations 74 | #' 75 | #' Plots correlations of the average fold-changes of all pathways between 76 | #' the different datasets. This function is only available to GSA based 77 | #' results (not GSVA ones). 78 | #' 79 | #' @param x ReactomeAnalysisResult. The result object to use as input 80 | #' @param hide_non_sig If set, non-significant pathways are not shown. 81 | #' @return A list of ggplot2 plot objects representing one plot per combination 82 | #' @export 83 | #' 84 | #' @family ReactomeAnalysisResult functions 85 | #' 86 | #' @examples 87 | #' # load an example result 88 | #' library(ReactomeGSA.data) 89 | #' data(griss_melanoma_result) 90 | #' 91 | #' # create the correlation plots 92 | #' plot_objs <- plot_correlations(griss_melanoma_result) 93 | #' 94 | #' # only one plot created for this result as it contains two datasets 95 | #' length(plot_objs) 96 | #' 97 | #' # show the plot using `print(plot_objs[[1]])` 98 | setGeneric("plot_correlations", function(x, hide_non_sig = FALSE) standardGeneric("plot_correlations")) 99 | 100 | 101 | #' plot_correlations - ReactomeAnalysisResult 102 | #' @inherit plot_correlations 103 | setMethod("plot_correlations", c("x" = "ReactomeAnalysisResult"), function(x, hide_non_sig = FALSE) { 104 | n_datasets <- length(names(x)) 105 | 106 | # only works if the number of datasets > 1 107 | if (n_datasets < 2) { 108 | stop("Error: ReactomeAnalysisResult contains less than 2 datasets.") 109 | } 110 | 111 | pathway_result <- pathways(x) 112 | 113 | # only works if it's a GSA-based result 114 | if (length(grep("av_foldchange\\.", colnames(pathway_result))) < 1) { 115 | stop("Error: plot_correlations only applicable to GSA-based results") 116 | } 117 | 118 | plot_list <- list() 119 | 120 | for (dataset_index_1 in seq(to = n_datasets)) { 121 | for (dataset_index_2 in seq(from = dataset_index_1+1, to = n_datasets)) { 122 | # ignore any impossible combinations 123 | if (dataset_index_2 > n_datasets || dataset_index_1 == dataset_index_2) { 124 | next 125 | } 126 | 127 | message("Comparing ", dataset_index_1, " vs ", dataset_index_2) 128 | 129 | # get the dataset's name 130 | dataset_1 <- names(x)[dataset_index_1] 131 | dataset_2 <- names(x)[dataset_index_2] 132 | 133 | # get the fold-changes for all pathways 134 | fc_1 <- get_fc_for_dataset(dataset_1, pathway_result) 135 | fc_2 <- get_fc_for_dataset(dataset_2, pathway_result) 136 | 137 | # test whether they are significant 138 | is_sig_1 <- get_is_sig_dataset(dataset_1, pathway_result) 139 | is_sig_2 <- get_is_sig_dataset(dataset_2, pathway_result) 140 | 141 | # only plot shared pathways 142 | shared_p <- names(fc_1)[names(fc_1) %in% names(fc_2)] 143 | 144 | # save as a data.frame for ggplot2 145 | plot_data <- data.frame( 146 | fc_1 = fc_1[shared_p], 147 | fc_2 = fc_2[shared_p], 148 | sig_1 = is_sig_1[shared_p], 149 | sig_2 = is_sig_2[shared_p], 150 | comparison = paste0(dataset_1, " vs. ", dataset_2) 151 | ) 152 | 153 | # add significance labels and alpha values 154 | plot_data$combined_sig <- apply(plot_data, 1, function(y) max(c(y["sig_1"], y["sig_2"]))) 155 | plot_data$combined_sig <- factor(plot_data$combined_sig, levels = c(3, 2, 1), labels = c("non-sig.", "p <= 0.05", "p <= 0.01")) 156 | plot_data$alpha <- 0.05 157 | plot_data$alpha[plot_data$combined_sig != "non-sig."] <- 1 158 | point_colours <- c("#CCCCCC", "#CC333F", "#00A0B0") 159 | 160 | # remove non-significant if set 161 | if (hide_non_sig) { 162 | plot_data <- plot_data[plot_data$combined_sig != "non-sig.", ] 163 | point_colours <- c("#CC333F", "#00A0B0") 164 | } 165 | 166 | # create the plot obj 167 | plot_obj <- ggplot2::ggplot(plot_data, ggplot2::aes(x = fc_1, y = fc_2, color = combined_sig)) + 168 | ggplot2::geom_point(ggplot2::aes(alpha = alpha)) + 169 | ggplot2::scale_color_manual(values = point_colours) + 170 | ggplot2::geom_hline(yintercept = 0, color = "#666666", linetype = 2) + 171 | ggplot2::geom_vline(xintercept = 0, color = "#666666", linetype = 2) + 172 | ggplot2::labs(x = paste0("Av. foldchange ", dataset_1), y = paste0("Av. foldchange ", dataset_2), color = "Lowest significance", 173 | title = paste0(dataset_1, " vs. ", dataset_2)) + 174 | ggplot2::guides(alpha = "none") 175 | 176 | plot_list[[length(plot_list) + 1]] <- plot_obj 177 | } 178 | } 179 | 180 | return(plot_list) 181 | }) 182 | 183 | 184 | #' get_fc_for_dataset 185 | #' 186 | #' Retrieve the fold-changes for all pathways of the defined dataset 187 | #' 188 | #' @param dataset Name of the dataset to retrieve the fold changes for. 189 | #' @param pathway_result The data.frame created by the \code{pathways} function. 190 | #' 191 | #' @return A vector of fold-changes 192 | get_fc_for_dataset <- function(dataset, pathway_result) { 193 | fc_values <- as.numeric(pathway_result[, paste0("av_foldchange.", dataset)]) 194 | names(fc_values) <- rownames(pathway_result) 195 | 196 | return(fc_values) 197 | } 198 | 199 | #' get_is_sig_dataset 200 | #' 201 | #' Determines how significant a pathway is across the datasets. Returns the 202 | #' lowest significance. 203 | #' 204 | #' @param dataset Name of the dataset 205 | #' @param pathway_result data.frame created by the \code{pathways} function 206 | #' 207 | #' @return A vector with 3=non-significant, 2=p<=0.05, 1=p<0.01 208 | get_is_sig_dataset <- function(dataset, pathway_result) { 209 | fdr_values <- as.numeric(pathway_result[, paste0("FDR.", dataset)]) 210 | 211 | is_sig <- rep(3, length(fdr_values)) 212 | 213 | is_sig[fdr_values <= 0.05] <- 2 214 | is_sig[fdr_values <= 0.01] <- 1 215 | 216 | names(is_sig) <- rownames(pathway_result) 217 | 218 | return(is_sig) 219 | } 220 | 221 | # plot_heatmap -------------------------------------------------------- 222 | 223 | #' plot_heatmap 224 | #' 225 | #' Creates a heatmap to show which pathways are up- and down-regulated 226 | #' in different datasets 227 | #' 228 | #' @param x ReactomeAnalysisResult. The result object to use as input 229 | #' 230 | #' @param fdr numeric. The minimum FDR to consider a pathways as significantly 231 | #' regulated. (Default 0.01) 232 | #' @param max_pathways numeric. The maximum number of pathways to plot. Pathways 233 | #' are sorted based on in how many datasets they are significantly regulated. 234 | #' This has no effect if \code{return_data} is set to \code{TRUE}. 235 | #' @param break_long_names logical. If set, long pathway names are broken into 236 | #' two lines. 237 | #' @param return_data logical. If set, only the plotting data, but not the plot 238 | #' object itself is returned. This can be used to create customized plots 239 | #' that use the same data structure. 240 | #' 241 | #' @return A ggplot2 plot object representing the heatmap of pathways 242 | #' 243 | #' @family ReactomeAnalysisResult functions 244 | #' @export 245 | #' 246 | #' @examples 247 | #' # load an example result 248 | #' library(ReactomeGSA.data) 249 | #' data(griss_melanoma_result) 250 | #' 251 | #' # create the heatmap plot 252 | #' plot_obj <- plot_heatmap(griss_melanoma_result) 253 | #' 254 | #' # show the plot 255 | #' print(plot_obj) 256 | setGeneric("plot_heatmap", function(x, fdr = 0.01, max_pathways = 30, break_long_names = TRUE, return_data = FALSE) standardGeneric("plot_heatmap")) 257 | 258 | #' plot_heatmap - ReactomeAnalysisResult 259 | #' 260 | #' @importFrom ggplot2 ggplot aes geom_point geom_hline labs 261 | #' @importFrom dplyr select any_of 262 | #' @importFrom tidyr pivot_longer 263 | #' @inherit plot_heatmap 264 | setMethod("plot_heatmap", c("x" = "ReactomeAnalysisResult"), function(x, fdr = 0.01, max_pathways = 30, break_long_names = TRUE, return_data = FALSE) { 265 | # get all pathways from the object 266 | all_pathways <- ReactomeGSA::pathways(x) 267 | 268 | # create the plot data 269 | all_pathways[["n_sig"]] <- 0 270 | 271 | for (dataset_name in names(x)) { 272 | pathway_fdr <- all_pathways[[paste0("FDR.", dataset_name)]] 273 | direction <- all_pathways[[paste0("Direction.", dataset_name)]] 274 | 275 | all_pathways[[dataset_name]] <- paste0(ifelse(pathway_fdr <= fdr, "sig", "non-sig"), " ", direction) 276 | 277 | all_pathways[["n_sig"]] <- all_pathways[["n_sig"]] + as.numeric(pathway_fdr <= fdr) 278 | } 279 | 280 | # filter the pathways if set 281 | if (!return_data) { 282 | all_pathways <- dplyr::arrange(all_pathways, desc(n_sig)) 283 | all_pathways <- dplyr::slice_head(all_pathways, n = max_pathways) 284 | } 285 | 286 | # limit the data 287 | plot_data <- dplyr::select(all_pathways, "Name" | "n_sig" | dplyr::any_of(names(x))) 288 | plot_data <- tidyr::pivot_longer(plot_data, !c("Name", "n_sig"), names_to = "dataset", values_to = "direction") 289 | plot_data <- dplyr::mutate(plot_data, direction = factor(direction, levels = c("sig Down", "non-sig Down", "non-sig Up", "sig Up"))) 290 | 291 | # short the names if set 292 | if (break_long_names) { 293 | plot_data$Name <- break_names(plot_data$Name) 294 | } 295 | 296 | # return the data if set 297 | if (return_data) { 298 | return(plot_data) 299 | } 300 | 301 | # create the plot 302 | plot_obj <- ggplot2::ggplot(plot_data, ggplot2::aes(x = dataset, y = Name, fill = direction)) + 303 | ggplot2::geom_tile() + 304 | ggplot2::scale_fill_brewer(palette = "RdYlBu") + 305 | ggplot2::labs(x = "Dataset", fill = "Direction") 306 | 307 | return(plot_obj) 308 | }) 309 | 310 | #' break_names 311 | #' 312 | #' Introduce a line break in the middle of a long name. 313 | #' 314 | #' @param the_names A vector of names 315 | #' @param long_name_limit The limit to define a long name (defautl 46 chars.) 316 | #' 317 | #' @return The list of adapted names 318 | break_names <- function(the_names, long_name_limit = 46) { 319 | # add a line break to very long names 320 | is_long_name <- nchar(the_names) > long_name_limit 321 | 322 | for (name_index in which(is_long_name)) { 323 | the_name <- the_names[name_index] 324 | 325 | # get the words 326 | words <- strsplit(the_name, " ")[[1]] 327 | 328 | # merge the first half of the words 329 | middle <- ceiling(length(words) / 2) 330 | 331 | first_line <- paste0(words[1:middle], collapse = " ") 332 | second_line <- paste0(words[(middle+1):length(words)], collapse = " ") 333 | new_name <- paste0(c(first_line, second_line), collapse = "\n") 334 | 335 | # update the name 336 | the_names[name_index] <- new_name 337 | } 338 | 339 | return(the_names) 340 | } -------------------------------------------------------------------------------- /R/send_request.R: -------------------------------------------------------------------------------- 1 | #' Start Reactome Analysis 2 | #' 3 | #' Submits a \code{\link{ReactomeAnalysisRequest}} to the Reactome Analysis Service API and 4 | #' returns the analysis id of the submitted job. 5 | #' 6 | #' This function should only be used for very large requests that likely take a long time to complete. 7 | #' By default, users should use the \code{\link{perform_reactome_analysis}} function to run an analysis. 8 | #' 9 | #' @param request \code{\link{ReactomeAnalysisRequest}} object to submit. 10 | #' @param compress If set (default) the JSON request data is compressed using gzip. 11 | #' @param reactome_url URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 12 | #' Specific ports can be set using the standard URL specification (for example http://your.service:1234) 13 | #' 14 | #' @export 15 | #' 16 | #' @return character The analysis job's id. 17 | #' 18 | #' #' @examples 19 | #' # create a request using Camera as an analysis 20 | #' library(ReactomeGSA.data) 21 | #' data(griss_melanoma_proteomics) 22 | #' 23 | #' my_request <- ReactomeAnalysisRequest(method = "Camera") 24 | #' 25 | #' # set maximum missing values to 0.5 and do not create any reactome visualizations 26 | #' my_request <- set_parameters(request = my_request, 27 | #' max_missing_values = 0.5, 28 | #' create_reactome_visualization = FALSE) 29 | #' 30 | #' # add the dataset 31 | #' my_request <- add_dataset(request = my_request, 32 | #' expression_values = griss_melanoma_proteomics, 33 | #' name = "Proteomics", 34 | #' type = "proteomics_int", 35 | #' comparison_factor = "condition", 36 | #' comparison_group_1 = "MOCK", 37 | #' comparison_group_2 = "MCM", 38 | #' additional_factors = c("cell.type", "patient.id")) 39 | #' # start the analysis 40 | #' analysis_id <- start_reactome_analysis(my_request) 41 | start_reactome_analysis <- function(request, compress = TRUE, reactome_url = NULL) { 42 | 43 | if (!methods::is(request, "ReactomeAnalysisRequest")) { 44 | stop("'request' must be a ReactomeAnalysisRequest object") 45 | } 46 | 47 | # make sure the URL is OK 48 | reactome_url <- check_reactome_url(reactome_url = reactome_url) 49 | 50 | # create the json request 51 | json_request <- toJSON(request) 52 | 53 | # compress the JSON string 54 | if (compress) { 55 | message("Compressing request data...") 56 | json_request_compress <- memCompress(from = json_request, type = "gzip") 57 | 58 | # send the request 59 | request <- httr::POST(paste0(reactome_url, "0.1/analysis"), body = json_request_compress, 60 | httr::content_type("application/gzip"), httr::add_headers("Content-Encoding" = "gzip")) 61 | } else { 62 | request <- httr::POST(paste0(reactome_url, "0.1/analysis"), body = json_request, 63 | httr::content_type("application/json")) 64 | } 65 | 66 | # test if the request worked 67 | if (httr::status_code(request) != 200) { 68 | return_content <- httr::content(request, "text") 69 | 70 | if (substr(return_content, 1, 1) == "{") { 71 | error_obj <- jsonlite::fromJSON(return_content) 72 | stop("Request failed (", error_obj[["status"]], " - ", error_obj[["title"]], "): ", error_obj[["detail"]]) 73 | } else { 74 | stop("Failed to submit analysis request: ", return_content) 75 | } 76 | } 77 | 78 | analysis_id = httr::content(request, "text") 79 | 80 | message("Reactome Analysis submitted succesfully") 81 | 82 | # return the analysis_id 83 | return(analysis_id) 84 | } 85 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | #' check_reactome_url 2 | #' 3 | #' Makes sure the passed URL is valid. If not URL is passed, the one 4 | #' stored in the options is retrieved 5 | #' 6 | #' @param reactome_url character The URL to test. If \code{NULL} the URL 7 | #' is retrieved from the options. 8 | #' @return character The potentially cleaned / retrieved URL with a trailing "/" 9 | check_reactome_url <- function(reactome_url) { 10 | if (is.null(reactome_url)) { 11 | reactome_url <- getOption("reactome_gsa.url") 12 | } 13 | 14 | if (substr(reactome_url, 1, 4) != "http") { 15 | stop("Error: Invalid URL passed. The URL must start with 'http'", call. = FALSE) 16 | } 17 | 18 | # make sure the url contains a trailing '/' 19 | if (substr(reactome_url, nchar(reactome_url), nchar(reactome_url)) != "/") { 20 | reactome_url <- paste0(reactome_url, "/") 21 | } 22 | 23 | # Fixes SEC_E_ILLEGAL_MESSAGE error on Windows 2012 24 | # This error seems to relate to a problem with Windows' certificate 25 | # management and the way sonlite::fromJSON acccess the server 26 | if (substr(reactome_url, 1, 8) == "https://") { 27 | reactome_url <- tryCatch( 28 | error = function(cnd) { 29 | # check if it is really the SEC_E_ILLEGAL_MESSAGE error 30 | if (grepl("SEC_E_ILLEGAL_MESSAGE", cnd[[1]])) { 31 | # simply revert to http 32 | warning("Failed to process certificate. This is generally caused by a problem with Windows and R. Reverting to non-encrypted connection to the ReactomeGSA system.") 33 | 34 | # get the non https url 35 | return(gsub("https://", "http://", reactome_url)[[1]]) 36 | } 37 | 38 | # create a nice error if the hostname is unknown 39 | if (grepl("Could not resolve host", cnd[[1]])) { 40 | stop("Faild to resolve ", reactome_url, ". Please ensure that the ReactomeGSA URL set under 'options(\"reactome_gsa.url\")' is correct. To change this URL use options(reactome_gsa.url = \"http://gsa.reactome.org\")", call. = FALSE) 41 | } 42 | 43 | # simply fail if there's another issue 44 | stop(paste0("Failed to connect to ReactomeGSA at '", reactome_url, ": ", cnd[[1]], ". Try reverting the ReactomeGSA url to http://gsa.reactome.org using options(reactome_gsa.url = \"http://gsa.reactome.org\")."), call. = FALSE) 45 | }, 46 | { 47 | # a dummy request 48 | available_methods <- jsonlite::fromJSON(paste0(reactome_url, "0.1/methods")) 49 | 50 | # return the default URL 51 | return(reactome_url) 52 | } 53 | ) 54 | } 55 | 56 | return(reactome_url) 57 | } 58 | 59 | #' Converts a data.frame to a string representation 60 | #' 61 | #' A data.frame is converted into a single string using 62 | #' `\\t` (the characters, not tab) as field delimiter and 63 | #' `\\n` (the characters, not newline) as line delimiter 64 | #' 65 | #' @param data The data.frame to convert 66 | #' 67 | #' @return A string representing the passed data.frame 68 | data_frame_as_string <- function(data) { 69 | if (!methods::is(data, "data.frame")) { 70 | stop("Error: Only data.frame objects can be converted to string representation") 71 | } 72 | 73 | if (nrow(data) > 10000) { 74 | message("Converting expression data to string... (This may take a moment)") 75 | } 76 | 77 | text.connection <- textConnection(NULL, "w") 78 | utils::write.table(data, text.connection, sep = "\t", quote = FALSE, row.names = TRUE, col.names = NA) 79 | text.result <- textConnectionValue(text.connection) 80 | close(text.connection) 81 | 82 | text.result <- paste0(text.result, collapse = "\n") 83 | 84 | if (nrow(data) > 10000) { 85 | message("Conversion complete") 86 | } 87 | 88 | return(text.result) 89 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReactomeGSA 2 | 3 | The `ReactomeGSA` package is an R client to the `Reactome Analysis System`. This new analysis system supports **multi-species, multi-omics, comparative pathway analyses**. 4 | 5 | ## Getting Help 6 | 7 | * For any questions surrounding the use of ReactomeGSA, please simply post it in our [Q&A Section](https://github.com/reactome/ReactomeGSA/discussions) 8 | * Should you find a bug in our tool(s) we'd be very grateful if you could report it by posting a [new GitHub Issue](https://github.com/reactome/ReactomeGSA/issues/new) 9 | * If you encounter any other issues, don't hesitate to contact us at help [at] reactome [dot] org 10 | 11 | ## Documnetation 12 | 13 | The complete usage of the package is described in the [main vignette](https://bioconductor.org/packages/release/bioc/vignettes/ReactomeGSA/inst/doc/using-reactomegsa.html). 14 | 15 | If you are interested in processing single-cell RNA-seq data using ReactomeGSA, checkout [this vignette](https://bioconductor.org/packages/release/bioc/vignettes/ReactomeGSA/inst/doc/using-reactomegsa.html) 16 | 17 | ## Installation 18 | 19 | ### Bioconductor 20 | 21 | The `ReactomeGSA` package is part of Bioconductor since version 3.10. You can find detailed information on the latest stable version on [ReactomeGSA's Bioconductor page](https://doi.org/doi:10.18129/B9.bioc.ReactomeGSA). 22 | 23 | To install the latest version from Bioconductor use 24 | 25 | ```r 26 | if (!requireNamespace("BiocManager", quietly = TRUE)) 27 | install.packages("BiocManager") 28 | 29 | BiocManager::install("ReactomeGSA") 30 | ``` 31 | 32 | ### Latest Version 33 | 34 | Bioconductor is updated every 6 months. You can still get the latest version of the ReactomeGSA package directly from GitHub: 35 | 36 | ```r 37 | # install devtools if needed 38 | if (!require(devtools)) { 39 | install.packages("devtools") 40 | } 41 | 42 | # install the ReactomeGSA package 43 | if (!require(ReactomeGSA)) { 44 | install_github("reactome/ReactomeGSA") 45 | } 46 | ``` 47 | 48 | ## Citation 49 | 50 | If you used ReactomeGSA in your research, we would be grateful if you could cite the following manuscript: 51 | 52 | Griss *et al.*, ReactomeGSA - Efficient Multi-Omics Comparative Pathway Analysis (2020), MCP 19 (12) P2115-2125, DOI: [10.1074/mcp.TIR120.002155](https://doi.org/10.1074/mcp.TIR120.002155) 53 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite the ReactomeGSA in publications use:") 2 | 3 | citEntry(entry="article", 4 | title = "ReactomeGSA: new features to simplify public data reuse", 5 | author = personList( 6 | person(given="Alexander", family="Grentner"), 7 | person(given="Eliot", family="Ragueneau"), 8 | person(given="Chuqiao", family="Gong"), 9 | person(given="Adrian", family="Prinz"), 10 | person(given="Sabina", family="Gansberger"), 11 | person(given="Inigo", family="Oyarzun"), 12 | person(given="Henning", family="Hermjakob"), 13 | person(given="Johannes", family="Griss")), 14 | journal = "Bioinformatics", 15 | year = "2024", 16 | doi = "10.1093/bioinformatics/btae338", 17 | url = "https://www.ncbi.nlm.nih.gov/pmc/articles/pmid/38806182/", 18 | textVersion = "A Grentner, E Ragueneau, C Gong, A Prinz, S Gansberger, I Oyarzun, H Hermjakob, J Griss (2024) ReactomeGSA: new features to simplify public data reuse. Bioinformatics 40(6):btae338. doi: 10.1093/bioinformatics/btae338" 19 | ) 20 | 21 | citEntry(entry="article", 22 | title = "ReactomeGSA - Efficient Multi-Omics Comparative Pathway Analysis", 23 | author = personList( 24 | person(given="Johannes", family="Griss"), 25 | person(given="Guilherme", family="Viteri"), 26 | person(given="Konstantinos", family="Sidiropoulos"), 27 | person(given="Vy", family="Nguyen"), 28 | person(given="Antonio", family="Fabregat"), 29 | person(given="Henning", family="Hermjakob")), 30 | journal = "Mol Cell Proteomics", 31 | year = "2020", 32 | doi = "10.1074/mcp.TIR120.002155", 33 | url = "https://www.ncbi.nlm.nih.gov/pmc/articles/pmid/32907876/", 34 | textVersion = "J Griss, G Viteri, K Sidiropoulos, V Nguyen, A Fabregat, and H Hermjakob (2020) ReactomeGSA - Efficient Multi-Omics Comparative Pathway Analysis. Mol Cell Proteomics 19(12):2115-2125. doi: 10.1074/mcp.TIR120.002155" 35 | ) -------------------------------------------------------------------------------- /man/ReactomeAnalysisRequest.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{ReactomeAnalysisRequest} 4 | \alias{ReactomeAnalysisRequest} 5 | \title{ReactomeAnalysisRequest class} 6 | \usage{ 7 | ReactomeAnalysisRequest(method) 8 | 9 | ReactomeAnalysisRequest(method) 10 | } 11 | \arguments{ 12 | \item{method}{character. Name of the method to use.} 13 | } 14 | \value{ 15 | A ReactomeAnalysisRequest object. 16 | } 17 | \description{ 18 | This class is used to collect all information required to submit an 19 | analysis request to the Reactome Analysis System. 20 | } 21 | \section{Slots}{ 22 | 23 | \describe{ 24 | \item{\code{method}}{character. Name of the method to use} 25 | 26 | \item{\code{request_object}}{list. This slot should not be set manually. It stores the internal 27 | request representation and should be modified using the classes' functions. 28 | To add parameters, use \code{\link{set_parameters,ReactomeAnalysisRequest-method}}} 29 | }} 30 | 31 | \examples{ 32 | library(ReactomeGSA.data) 33 | library(methods) 34 | 35 | # create the request method and specify its method 36 | request <- ReactomeAnalysisRequest(method = "Camera") 37 | 38 | # add a dataset to the request 39 | data(griss_melanoma_proteomics) 40 | 41 | request <- add_dataset(request = request, 42 | expression_values = griss_melanoma_proteomics, 43 | name = "Proteomics", 44 | type = "proteomics_int", 45 | comparison_factor = "condition", 46 | comparison_group_1 = "MOCK", 47 | comparison_group_2 = "MCM", 48 | additional_factors = c("cell.type", "patient.id")) 49 | 50 | # to launch the actual analysis use the perform_reactome_analysis function 51 | } 52 | -------------------------------------------------------------------------------- /man/ReactomeAnalysisResult-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \docType{class} 4 | \name{ReactomeAnalysisResult-class} 5 | \alias{ReactomeAnalysisResult-class} 6 | \alias{ReactomeAnalysisResult} 7 | \title{ReactomeAnalysisResult class} 8 | \value{ 9 | A ReactomeAnalysisResult object. 10 | } 11 | \description{ 12 | A ReactomeAnalysisResult object contains the pathway analysis results of all 13 | submitted datasets at once. 14 | } 15 | \details{ 16 | This class represents a result retrieved from the Reactome Analysis Service. It is returned 17 | by \code{\link{get_reactome_analysis_result}} and its wrapper \code{\link{perform_reactome_analysis}}. 18 | Generally, object of this class should not be created manually. 19 | } 20 | \section{Slots}{ 21 | 22 | \describe{ 23 | \item{\code{reactome_release}}{The Reactome version used to create this result.} 24 | 25 | \item{\code{mappings}}{Stores the mapping results that were generated for this analysis.} 26 | 27 | \item{\code{results}}{A named list containing the actual analysis results for every dataset 28 | and possibly combined results as well.} 29 | 30 | \item{\code{reactome_links}}{Links pointing to reactome results as a list.} 31 | }} 32 | 33 | \section{Methods}{ 34 | 35 | 36 | \bold{\code{\link{names}}}: 37 | Retrieves the names of all datasets in the result object 38 | 39 | \bold{\code{\link{result_types}}}: 40 | Retrieves the available result types 41 | 42 | \bold{\code{\link{pathways}}}: 43 | Merges the pathway results of all analysed datasets. 44 | 45 | \bold{\code{\link{get_result}}}: 46 | Retrieve a specific result as data.frame 47 | 48 | \bold{\code{\link{reactome_links}}}: 49 | Displays / retrieves the URLs to the available visualizations in Reactome's pathway browser. 50 | 51 | \bold{\code{\link{open_reactome}}}: 52 | Opens the specified Reactome visualization in the system's default browser. 53 | } 54 | 55 | \examples{ 56 | # load an example result object 57 | library(ReactomeGSA.data) 58 | data(griss_melanoma_result) 59 | 60 | # retrieve the names of all datasets in the result 61 | names(griss_melanoma_result) 62 | 63 | # get the combined pathway result 64 | pathway_result <- pathways(griss_melanoma_result) 65 | 66 | # check which result types are available 67 | result_types(griss_melanoma_result) 68 | 69 | # get the fold changes for the first dataset 70 | first_dataset_name <- names(griss_melanoma_result)[1] 71 | 72 | first_fc <- get_result(griss_melanoma_result, "fold_changes", first_dataset_name) 73 | } 74 | -------------------------------------------------------------------------------- /man/add_dataset-ReactomeAnalysisRequest-DGEList-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{add_dataset,ReactomeAnalysisRequest,DGEList-method} 4 | \alias{add_dataset,ReactomeAnalysisRequest,DGEList-method} 5 | \title{add_dataset - DGEList} 6 | \usage{ 7 | \S4method{add_dataset}{ReactomeAnalysisRequest,DGEList}( 8 | request, 9 | expression_values, 10 | name, 11 | type, 12 | comparison_factor, 13 | comparison_group_1, 14 | comparison_group_2, 15 | sample_data = NULL, 16 | additional_factors = NULL, 17 | overwrite = FALSE, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{request}{ReactomeAnalysisRequest.} 23 | 24 | \item{expression_values}{DGEList Here, the sample_data is automaticall extracted from the \code{expression_values} object unless \code{sample_data} 25 | is specified as well.} 26 | 27 | \item{name}{character. Name of the dataset. This must be unique within one request.} 28 | 29 | \item{type}{character. The type of the dataset. Get available types using \code{\link{get_reactome_data_types}}} 30 | 31 | \item{comparison_factor}{character. The name of the sample property to use for the main comparison. The sample properties 32 | are either retrieved from \code{expression_values} or from \code{sample_data}.} 33 | 34 | \item{comparison_group_1}{character. Name of the first group within \code{comparison_factor} to use for the comparison.} 35 | 36 | \item{comparison_group_2}{character. Name of the second group within \code{comparison_factor} to use for the comparison.} 37 | 38 | \item{sample_data}{data.frame (optional) data.frame containing the sample metadata of the \code{expression_values}. Depending 39 | on the object type of \code{expression_values}, this information can also be extracted from there.} 40 | 41 | \item{additional_factors}{vector. Vector of additional sample properties that are used as blocking factors 42 | (if supported by the chosen analysis method) in the gene set analysis.} 43 | 44 | \item{overwrite}{boolean. If set to \code{TRUE}, datasets with the same name will be overwritten} 45 | 46 | \item{...}{Additional parameters passed to downstream functions. See the respective documentation of 47 | whether any additional parameters are supported.} 48 | } 49 | \value{ 50 | The \code{\link{ReactomeAnalysisRequest}} object with the added dataset 51 | } 52 | \description{ 53 | Adds a dataset to the analysis request 54 | } 55 | \examples{ 56 | # create a request using Camera as an analysis 57 | library(ReactomeGSA.data) 58 | data(griss_melanoma_proteomics) 59 | library(methods) 60 | 61 | my_request <- ReactomeAnalysisRequest(method = "Camera") 62 | 63 | # since the expression_values object is a limma EList object, the sample_data is 64 | # retrieved from there 65 | 66 | # add the dataset 67 | my_request <- add_dataset(request = my_request, 68 | expression_values = griss_melanoma_proteomics, 69 | name = "Proteomics", 70 | type = "proteomics_int", 71 | comparison_factor = "condition", 72 | comparison_group_1 = "MOCK", 73 | comparison_group_2 = "MCM", 74 | additional_factors = c("cell.type", "patient.id")) 75 | } 76 | \seealso{ 77 | Other add_dataset methods: 78 | \code{\link{add_dataset}()}, 79 | \code{\link{add_dataset,ReactomeAnalysisRequest,EList-method}}, 80 | \code{\link{add_dataset,ReactomeAnalysisRequest,ExpressionSet-method}}, 81 | \code{\link{add_dataset,ReactomeAnalysisRequest,data.frame-method}}, 82 | \code{\link{add_dataset,ReactomeAnalysisRequest,matrix-method}} 83 | } 84 | \concept{add_dataset methods} 85 | -------------------------------------------------------------------------------- /man/add_dataset-ReactomeAnalysisRequest-EList-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{add_dataset,ReactomeAnalysisRequest,EList-method} 4 | \alias{add_dataset,ReactomeAnalysisRequest,EList-method} 5 | \title{add_dataset - EList} 6 | \usage{ 7 | \S4method{add_dataset}{ReactomeAnalysisRequest,EList}( 8 | request, 9 | expression_values, 10 | name, 11 | type, 12 | comparison_factor, 13 | comparison_group_1, 14 | comparison_group_2, 15 | sample_data = NULL, 16 | additional_factors = NULL, 17 | overwrite = FALSE, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{request}{ReactomeAnalysisRequest.} 23 | 24 | \item{expression_values}{EList. Here, the sample_data is automaticall extracted from the \code{expression_values} object unless \code{sample_data} 25 | is specified as well.} 26 | 27 | \item{name}{character. Name of the dataset. This must be unique within one request.} 28 | 29 | \item{type}{character. The type of the dataset. Get available types using \code{\link{get_reactome_data_types}}} 30 | 31 | \item{comparison_factor}{character. The name of the sample property to use for the main comparison. The sample properties 32 | are either retrieved from \code{expression_values} or from \code{sample_data}.} 33 | 34 | \item{comparison_group_1}{character. Name of the first group within \code{comparison_factor} to use for the comparison.} 35 | 36 | \item{comparison_group_2}{character. Name of the second group within \code{comparison_factor} to use for the comparison.} 37 | 38 | \item{sample_data}{data.frame (optional) data.frame containing the sample metadata of the \code{expression_values}. Depending 39 | on the object type of \code{expression_values}, this information can also be extracted from there.} 40 | 41 | \item{additional_factors}{vector. Vector of additional sample properties that are used as blocking factors 42 | (if supported by the chosen analysis method) in the gene set analysis.} 43 | 44 | \item{overwrite}{boolean. If set to \code{TRUE}, datasets with the same name will be overwritten} 45 | 46 | \item{...}{Additional parameters passed to downstream functions. See the respective documentation of 47 | whether any additional parameters are supported.} 48 | } 49 | \value{ 50 | The \code{\link{ReactomeAnalysisRequest}} object with the added dataset 51 | } 52 | \description{ 53 | Adds a dataset to the analysis request 54 | } 55 | \examples{ 56 | # create a request using Camera as an analysis 57 | library(ReactomeGSA.data) 58 | data(griss_melanoma_proteomics) 59 | library(methods) 60 | 61 | my_request <- ReactomeAnalysisRequest(method = "Camera") 62 | 63 | # since the expression_values object is a limma EList object, the sample_data is 64 | # retrieved from there 65 | 66 | # add the dataset 67 | my_request <- add_dataset(request = my_request, 68 | expression_values = griss_melanoma_proteomics, 69 | name = "Proteomics", 70 | type = "proteomics_int", 71 | comparison_factor = "condition", 72 | comparison_group_1 = "MOCK", 73 | comparison_group_2 = "MCM", 74 | additional_factors = c("cell.type", "patient.id")) 75 | } 76 | \seealso{ 77 | Other add_dataset methods: 78 | \code{\link{add_dataset}()}, 79 | \code{\link{add_dataset,ReactomeAnalysisRequest,DGEList-method}}, 80 | \code{\link{add_dataset,ReactomeAnalysisRequest,ExpressionSet-method}}, 81 | \code{\link{add_dataset,ReactomeAnalysisRequest,data.frame-method}}, 82 | \code{\link{add_dataset,ReactomeAnalysisRequest,matrix-method}} 83 | } 84 | \concept{add_dataset methods} 85 | -------------------------------------------------------------------------------- /man/add_dataset-ReactomeAnalysisRequest-ExpressionSet-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{add_dataset,ReactomeAnalysisRequest,ExpressionSet-method} 4 | \alias{add_dataset,ReactomeAnalysisRequest,ExpressionSet-method} 5 | \title{add_dataset - ExpressionSet} 6 | \usage{ 7 | \S4method{add_dataset}{ReactomeAnalysisRequest,ExpressionSet}( 8 | request, 9 | expression_values, 10 | name, 11 | type, 12 | comparison_factor, 13 | comparison_group_1, 14 | comparison_group_2, 15 | sample_data = NULL, 16 | additional_factors = NULL, 17 | overwrite = FALSE, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{request}{ReactomeAnalysisRequest.} 23 | 24 | \item{expression_values}{ExpressionSet. Here, the sample_data is automaticall extracted from the \code{expression_values} object unless \code{sample_data} 25 | is specified as well.} 26 | 27 | \item{name}{character. Name of the dataset. This must be unique within one request.} 28 | 29 | \item{type}{character. The type of the dataset. Get available types using \code{\link{get_reactome_data_types}}} 30 | 31 | \item{comparison_factor}{character. The name of the sample property to use for the main comparison. The sample properties 32 | are either retrieved from \code{expression_values} or from \code{sample_data}.} 33 | 34 | \item{comparison_group_1}{character. Name of the first group within \code{comparison_factor} to use for the comparison.} 35 | 36 | \item{comparison_group_2}{character. Name of the second group within \code{comparison_factor} to use for the comparison.} 37 | 38 | \item{sample_data}{data.frame (optional) data.frame containing the sample metadata of the \code{expression_values}. Depending 39 | on the object type of \code{expression_values}, this information can also be extracted from there.} 40 | 41 | \item{additional_factors}{vector. Vector of additional sample properties that are used as blocking factors 42 | (if supported by the chosen analysis method) in the gene set analysis.} 43 | 44 | \item{overwrite}{boolean. If set to \code{TRUE}, datasets with the same name will be overwritten} 45 | 46 | \item{...}{Additional parameters passed to downstream functions. See the respective documentation of 47 | whether any additional parameters are supported.} 48 | } 49 | \value{ 50 | The \code{\link{ReactomeAnalysisRequest}} object with the added dataset 51 | } 52 | \description{ 53 | Adds a dataset to the analysis request 54 | } 55 | \examples{ 56 | # create a request using Camera as an analysis 57 | library(ReactomeGSA.data) 58 | data(griss_melanoma_proteomics) 59 | library(methods) 60 | 61 | my_request <- ReactomeAnalysisRequest(method = "Camera") 62 | 63 | # since the expression_values object is a limma EList object, the sample_data is 64 | # retrieved from there 65 | 66 | # add the dataset 67 | my_request <- add_dataset(request = my_request, 68 | expression_values = griss_melanoma_proteomics, 69 | name = "Proteomics", 70 | type = "proteomics_int", 71 | comparison_factor = "condition", 72 | comparison_group_1 = "MOCK", 73 | comparison_group_2 = "MCM", 74 | additional_factors = c("cell.type", "patient.id")) 75 | } 76 | \seealso{ 77 | Other add_dataset methods: 78 | \code{\link{add_dataset}()}, 79 | \code{\link{add_dataset,ReactomeAnalysisRequest,DGEList-method}}, 80 | \code{\link{add_dataset,ReactomeAnalysisRequest,EList-method}}, 81 | \code{\link{add_dataset,ReactomeAnalysisRequest,data.frame-method}}, 82 | \code{\link{add_dataset,ReactomeAnalysisRequest,matrix-method}} 83 | } 84 | \concept{add_dataset methods} 85 | -------------------------------------------------------------------------------- /man/add_dataset-ReactomeAnalysisRequest-data.frame-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{add_dataset,ReactomeAnalysisRequest,data.frame-method} 4 | \alias{add_dataset,ReactomeAnalysisRequest,data.frame-method} 5 | \title{add_dataset - data.frame} 6 | \usage{ 7 | \S4method{add_dataset}{ReactomeAnalysisRequest,data.frame}( 8 | request, 9 | expression_values, 10 | name, 11 | type, 12 | comparison_factor, 13 | comparison_group_1, 14 | comparison_group_2, 15 | sample_data = NULL, 16 | additional_factors = NULL, 17 | overwrite = FALSE, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{request}{ReactomeAnalysisRequest.} 23 | 24 | \item{expression_values}{data.frame. In this case, the \code{sample_data} must be set.} 25 | 26 | \item{name}{character. Name of the dataset. This must be unique within one request.} 27 | 28 | \item{type}{character. The type of the dataset. Get available types using \code{\link{get_reactome_data_types}}} 29 | 30 | \item{comparison_factor}{character. The name of the sample property to use for the main comparison. The sample properties 31 | are either retrieved from \code{expression_values} or from \code{sample_data}.} 32 | 33 | \item{comparison_group_1}{character. Name of the first group within \code{comparison_factor} to use for the comparison.} 34 | 35 | \item{comparison_group_2}{character. Name of the second group within \code{comparison_factor} to use for the comparison.} 36 | 37 | \item{sample_data}{data.frame (optional) data.frame containing the sample metadata of the \code{expression_values}. Depending 38 | on the object type of \code{expression_values}, this information can also be extracted from there.} 39 | 40 | \item{additional_factors}{vector. Vector of additional sample properties that are used as blocking factors 41 | (if supported by the chosen analysis method) in the gene set analysis.} 42 | 43 | \item{overwrite}{boolean. If set to \code{TRUE}, datasets with the same name will be overwritten} 44 | 45 | \item{...}{Additional parameters passed to downstream functions. See the respective documentation of 46 | whether any additional parameters are supported.} 47 | } 48 | \value{ 49 | The \code{\link{ReactomeAnalysisRequest}} object with the added dataset 50 | } 51 | \description{ 52 | Adds a dataset to the analysis request 53 | } 54 | \examples{ 55 | # create a request using Camera as an analysis 56 | library(ReactomeGSA.data) 57 | data(griss_melanoma_proteomics) 58 | library(methods) 59 | 60 | my_request <- ReactomeAnalysisRequest(method = "Camera") 61 | 62 | # since the expression_values object is a limma EList object, the sample_data is 63 | # retrieved from there 64 | 65 | # add the dataset 66 | my_request <- add_dataset(request = my_request, 67 | expression_values = griss_melanoma_proteomics, 68 | name = "Proteomics", 69 | type = "proteomics_int", 70 | comparison_factor = "condition", 71 | comparison_group_1 = "MOCK", 72 | comparison_group_2 = "MCM", 73 | additional_factors = c("cell.type", "patient.id")) 74 | } 75 | \seealso{ 76 | Other add_dataset methods: 77 | \code{\link{add_dataset}()}, 78 | \code{\link{add_dataset,ReactomeAnalysisRequest,DGEList-method}}, 79 | \code{\link{add_dataset,ReactomeAnalysisRequest,EList-method}}, 80 | \code{\link{add_dataset,ReactomeAnalysisRequest,ExpressionSet-method}}, 81 | \code{\link{add_dataset,ReactomeAnalysisRequest,matrix-method}} 82 | } 83 | \concept{add_dataset methods} 84 | -------------------------------------------------------------------------------- /man/add_dataset-ReactomeAnalysisRequest-matrix-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{add_dataset,ReactomeAnalysisRequest,matrix-method} 4 | \alias{add_dataset,ReactomeAnalysisRequest,matrix-method} 5 | \title{add_dataset - matrix} 6 | \usage{ 7 | \S4method{add_dataset}{ReactomeAnalysisRequest,matrix}( 8 | request, 9 | expression_values, 10 | name, 11 | type, 12 | comparison_factor, 13 | comparison_group_1, 14 | comparison_group_2, 15 | sample_data = NULL, 16 | additional_factors = NULL, 17 | overwrite = FALSE, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{request}{ReactomeAnalysisRequest.} 23 | 24 | \item{expression_values}{matrix. In this case, the \code{sample_data} must be set.} 25 | 26 | \item{name}{character. Name of the dataset. This must be unique within one request.} 27 | 28 | \item{type}{character. The type of the dataset. Get available types using \code{\link{get_reactome_data_types}}} 29 | 30 | \item{comparison_factor}{character. The name of the sample property to use for the main comparison. The sample properties 31 | are either retrieved from \code{expression_values} or from \code{sample_data}.} 32 | 33 | \item{comparison_group_1}{character. Name of the first group within \code{comparison_factor} to use for the comparison.} 34 | 35 | \item{comparison_group_2}{character. Name of the second group within \code{comparison_factor} to use for the comparison.} 36 | 37 | \item{sample_data}{data.frame (optional) data.frame containing the sample metadata of the \code{expression_values}. Depending 38 | on the object type of \code{expression_values}, this information can also be extracted from there.} 39 | 40 | \item{additional_factors}{vector. Vector of additional sample properties that are used as blocking factors 41 | (if supported by the chosen analysis method) in the gene set analysis.} 42 | 43 | \item{overwrite}{boolean. If set to \code{TRUE}, datasets with the same name will be overwritten} 44 | 45 | \item{...}{Additional parameters passed to downstream functions. See the respective documentation of 46 | whether any additional parameters are supported.} 47 | } 48 | \value{ 49 | The \code{\link{ReactomeAnalysisRequest}} object with the added dataset 50 | } 51 | \description{ 52 | Adds a dataset to the analysis request 53 | } 54 | \examples{ 55 | # create a request using Camera as an analysis 56 | library(ReactomeGSA.data) 57 | data(griss_melanoma_proteomics) 58 | library(methods) 59 | 60 | my_request <- ReactomeAnalysisRequest(method = "Camera") 61 | 62 | # since the expression_values object is a limma EList object, the sample_data is 63 | # retrieved from there 64 | 65 | # add the dataset 66 | my_request <- add_dataset(request = my_request, 67 | expression_values = griss_melanoma_proteomics, 68 | name = "Proteomics", 69 | type = "proteomics_int", 70 | comparison_factor = "condition", 71 | comparison_group_1 = "MOCK", 72 | comparison_group_2 = "MCM", 73 | additional_factors = c("cell.type", "patient.id")) 74 | } 75 | \seealso{ 76 | Other add_dataset methods: 77 | \code{\link{add_dataset}()}, 78 | \code{\link{add_dataset,ReactomeAnalysisRequest,DGEList-method}}, 79 | \code{\link{add_dataset,ReactomeAnalysisRequest,EList-method}}, 80 | \code{\link{add_dataset,ReactomeAnalysisRequest,ExpressionSet-method}}, 81 | \code{\link{add_dataset,ReactomeAnalysisRequest,data.frame-method}} 82 | } 83 | \concept{add_dataset methods} 84 | -------------------------------------------------------------------------------- /man/add_dataset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{add_dataset} 4 | \alias{add_dataset} 5 | \title{add_dataset} 6 | \usage{ 7 | add_dataset( 8 | request, 9 | expression_values, 10 | name, 11 | type, 12 | comparison_factor, 13 | comparison_group_1, 14 | comparison_group_2, 15 | sample_data = NULL, 16 | additional_factors = NULL, 17 | overwrite = FALSE, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{request}{The request to add the dataset to. Commonly a \code{\link{ReactomeAnalysisRequest}} object.} 23 | 24 | \item{expression_values}{Object containing the expression values of the dataset to add (multiple types supported).} 25 | 26 | \item{name}{character. Name of the dataset. This must be unique within one request.} 27 | 28 | \item{type}{character. The type of the dataset. Get available types using \code{\link{get_reactome_data_types}}} 29 | 30 | \item{comparison_factor}{character. The name of the sample property to use for the main comparison. The sample properties 31 | are either retrieved from \code{expression_values} or from \code{sample_data}.} 32 | 33 | \item{comparison_group_1}{character. Name of the first group within \code{comparison_factor} to use for the comparison.} 34 | 35 | \item{comparison_group_2}{character. Name of the second group within \code{comparison_factor} to use for the comparison.} 36 | 37 | \item{sample_data}{data.frame (optional) data.frame containing the sample metadata of the \code{expression_values}. Depending 38 | on the object type of \code{expression_values}, this information can also be extracted from there.} 39 | 40 | \item{additional_factors}{vector. Vector of additional sample properties that are used as blocking factors 41 | (if supported by the chosen analysis method) in the gene set analysis.} 42 | 43 | \item{overwrite}{boolean. If set to \code{TRUE}, datasets with the same name will be overwritten} 44 | 45 | \item{...}{Additional parameters passed to downstream functions. See the respective documentation of 46 | whether any additional parameters are supported.} 47 | } 48 | \value{ 49 | The \code{\link{ReactomeAnalysisRequest}} object with the added dataset 50 | } 51 | \description{ 52 | Adds a dataset to the analysis request 53 | } 54 | \examples{ 55 | # create a request using Camera as an analysis 56 | library(ReactomeGSA.data) 57 | data(griss_melanoma_proteomics) 58 | library(methods) 59 | 60 | my_request <- ReactomeAnalysisRequest(method = "Camera") 61 | 62 | # since the expression_values object is a limma EList object, the sample_data is 63 | # retrieved from there 64 | 65 | # add the dataset 66 | my_request <- add_dataset(request = my_request, 67 | expression_values = griss_melanoma_proteomics, 68 | name = "Proteomics", 69 | type = "proteomics_int", 70 | comparison_factor = "condition", 71 | comparison_group_1 = "MOCK", 72 | comparison_group_2 = "MCM", 73 | additional_factors = c("cell.type", "patient.id")) 74 | } 75 | \seealso{ 76 | Other add_dataset methods: 77 | \code{\link{add_dataset,ReactomeAnalysisRequest,DGEList-method}}, 78 | \code{\link{add_dataset,ReactomeAnalysisRequest,EList-method}}, 79 | \code{\link{add_dataset,ReactomeAnalysisRequest,ExpressionSet-method}}, 80 | \code{\link{add_dataset,ReactomeAnalysisRequest,data.frame-method}}, 81 | \code{\link{add_dataset,ReactomeAnalysisRequest,matrix-method}} 82 | } 83 | \concept{add_dataset methods} 84 | -------------------------------------------------------------------------------- /man/analyse_sc_clusters-Seurat-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analyse_sc_clusters.R 3 | \name{analyse_sc_clusters,Seurat-method} 4 | \alias{analyse_sc_clusters,Seurat-method} 5 | \title{analyse_sc_clusters - Seurat} 6 | \usage{ 7 | \S4method{analyse_sc_clusters}{Seurat}( 8 | object, 9 | use_interactors = TRUE, 10 | include_disease_pathways = FALSE, 11 | create_reactome_visualization = FALSE, 12 | create_reports = FALSE, 13 | report_email = NULL, 14 | verbose = FALSE, 15 | assay = "RNA", 16 | slot = "counts", 17 | ... 18 | ) 19 | } 20 | \arguments{ 21 | \item{object}{The \code{Seurat} object containing the single cell RNA-sequencing data.} 22 | 23 | \item{use_interactors}{If set (default), protein-protein interactors from IntAct are used to 24 | extend Reactome pathways.} 25 | 26 | \item{include_disease_pathways}{If set, disease pathways are included as well. Disease pathways in 27 | Reactome follow a different annotation approach and can therefore 28 | lead to inaccurate results.} 29 | 30 | \item{create_reactome_visualization}{If set, the interactive visualization in Reactome's PathwayBrowser 31 | is created.} 32 | 33 | \item{create_reports}{If set, PDF and Microsoft Excel reports are created. Links to these report files 34 | are send to the supplied e-mail address.} 35 | 36 | \item{report_email}{The e-mail address to which reports should be sent to.} 37 | 38 | \item{verbose}{If set, additional status messages are printed.} 39 | 40 | \item{assay}{By default, the "RNA" assay is used, which contains the original read counts.} 41 | 42 | \item{slot}{The slot in the Seurat object to use. Default and recommended approach is to use the raw counts.} 43 | 44 | \item{...}{Parameters passed to the specific implementation. Detailed documentations 45 | can be found there.} 46 | } 47 | \value{ 48 | A \code{\link{ReactomeAnalysisResult}} object. 49 | } 50 | \description{ 51 | Analyses cell clusters of a single-cell RNA-sequencing 52 | experiment to get pathway-level expressions for every 53 | cluster of cells. 54 | } 55 | \details{ 56 | There are currently two specific implementations of 57 | this function, one to support \code{Seurat} objects 58 | and one to support Bioconductor's \code{SingleCellExperiment} 59 | class. 60 | } 61 | \examples{ 62 | # This example shows how a Seurat object can be analysed 63 | # the approach is identical for SingleCellExperiment objects 64 | library(ReactomeGSA.data) 65 | data(jerby_b_cells) 66 | 67 | # perform the GSVA analysis 68 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 69 | } 70 | -------------------------------------------------------------------------------- /man/analyse_sc_clusters-SingleCellExperiment-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analyse_sc_clusters.R 3 | \name{analyse_sc_clusters,SingleCellExperiment-method} 4 | \alias{analyse_sc_clusters,SingleCellExperiment-method} 5 | \title{analyse_sc_clusters - SingleCellExperiment} 6 | \usage{ 7 | \S4method{analyse_sc_clusters}{SingleCellExperiment}( 8 | object, 9 | use_interactors = TRUE, 10 | include_disease_pathways = FALSE, 11 | create_reactome_visualization = FALSE, 12 | create_reports = FALSE, 13 | report_email = NULL, 14 | verbose = FALSE, 15 | cell_ids, 16 | ... 17 | ) 18 | } 19 | \arguments{ 20 | \item{object}{The \code{SingleCellExperiment} object containing the single cell RNA-sequencing data.} 21 | 22 | \item{use_interactors}{If set (default), protein-protein interactors from IntAct are used to 23 | extend Reactome pathways.} 24 | 25 | \item{include_disease_pathways}{If set, disease pathways are included as well. Disease pathways in 26 | Reactome follow a different annotation approach and can therefore 27 | lead to inaccurate results.} 28 | 29 | \item{create_reactome_visualization}{If set, the interactive visualization in Reactome's PathwayBrowser 30 | is created.} 31 | 32 | \item{create_reports}{If set, PDF and Microsoft Excel reports are created. Links to these report files 33 | are send to the supplied e-mail address.} 34 | 35 | \item{report_email}{The e-mail address to which reports should be sent to.} 36 | 37 | \item{verbose}{If set, additional status messages are printed.} 38 | 39 | \item{cell_ids}{A factor specifying the group to which each cell belongs. For example, \code{object$cluster}. 40 | Alternatively, a string specifying the metada field's name may be passed.} 41 | 42 | \item{...}{Parameters passed to scater's \code{aggregateAcrossCells} function.} 43 | } 44 | \value{ 45 | A \code{\link{ReactomeAnalysisResult}} object. 46 | } 47 | \description{ 48 | Analyses cell clusters of a single-cell RNA-sequencing 49 | experiment to get pathway-level expressions for every 50 | cluster of cells. 51 | } 52 | \details{ 53 | There are currently two specific implementations of 54 | this function, one to support \code{Seurat} objects 55 | and one to support Bioconductor's \code{SingleCellExperiment} 56 | class. 57 | } 58 | \examples{ 59 | # This example shows how a Seurat object can be analysed 60 | # the approach is identical for SingleCellExperiment objects 61 | library(ReactomeGSA.data) 62 | data(jerby_b_cells) 63 | 64 | # perform the GSVA analysis 65 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 66 | } 67 | -------------------------------------------------------------------------------- /man/analyse_sc_clusters.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analyse_sc_clusters.R 3 | \name{analyse_sc_clusters} 4 | \alias{analyse_sc_clusters} 5 | \title{analyse_sc_clusters} 6 | \usage{ 7 | analyse_sc_clusters( 8 | object, 9 | use_interactors = TRUE, 10 | include_disease_pathways = FALSE, 11 | create_reactome_visualization = FALSE, 12 | create_reports = FALSE, 13 | report_email = NULL, 14 | verbose = FALSE, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{object}{The object containing the single-cell RNA-sequencing data.} 20 | 21 | \item{use_interactors}{If set (default), protein-protein interactors from IntAct are used to 22 | extend Reactome pathways.} 23 | 24 | \item{include_disease_pathways}{If set, disease pathways are included as well. Disease pathways in 25 | Reactome follow a different annotation approach and can therefore 26 | lead to inaccurate results.} 27 | 28 | \item{create_reactome_visualization}{If set, the interactive visualization in Reactome's PathwayBrowser 29 | is created.} 30 | 31 | \item{create_reports}{If set, PDF and Microsoft Excel reports are created. Links to these report files 32 | are send to the supplied e-mail address.} 33 | 34 | \item{report_email}{The e-mail address to which reports should be sent to.} 35 | 36 | \item{verbose}{If set, additional status messages are printed.} 37 | 38 | \item{...}{Parameters passed to the specific implementation. Detailed documentations 39 | can be found there.} 40 | } 41 | \value{ 42 | A \code{\link{ReactomeAnalysisResult}} object. 43 | } 44 | \description{ 45 | Analyses cell clusters of a single-cell RNA-sequencing 46 | experiment to get pathway-level expressions for every 47 | cluster of cells. 48 | } 49 | \details{ 50 | There are currently two specific implementations of 51 | this function, one to support \code{Seurat} objects 52 | and one to support Bioconductor's \code{SingleCellExperiment} 53 | class. 54 | } 55 | \examples{ 56 | # This example shows how a Seurat object can be analysed 57 | # the approach is identical for SingleCellExperiment objects 58 | library(ReactomeGSA.data) 59 | data(jerby_b_cells) 60 | 61 | # perform the GSVA analysis 62 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 63 | } 64 | -------------------------------------------------------------------------------- /man/break_names.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting_functions.R 3 | \name{break_names} 4 | \alias{break_names} 5 | \title{break_names} 6 | \usage{ 7 | break_names(the_names, long_name_limit = 46) 8 | } 9 | \arguments{ 10 | \item{the_names}{A vector of names} 11 | 12 | \item{long_name_limit}{The limit to define a long name (defautl 46 chars.)} 13 | } 14 | \value{ 15 | The list of adapted names 16 | } 17 | \description{ 18 | Introduce a line break in the middle of a long name. 19 | } 20 | -------------------------------------------------------------------------------- /man/checkRequestValidity.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{checkRequestValidity} 4 | \alias{checkRequestValidity} 5 | \title{Check's if a ReactomeAnalysisRequest object is valid} 6 | \usage{ 7 | checkRequestValidity(object) 8 | } 9 | \arguments{ 10 | \item{object}{The request object to check.} 11 | } 12 | \value{ 13 | TRUE if the object is valid or a string with the reason why it is not 14 | } 15 | \description{ 16 | Check's if a ReactomeAnalysisRequest object is valid 17 | } 18 | -------------------------------------------------------------------------------- /man/check_reactome_url.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{check_reactome_url} 4 | \alias{check_reactome_url} 5 | \title{check_reactome_url} 6 | \usage{ 7 | check_reactome_url(reactome_url) 8 | } 9 | \arguments{ 10 | \item{reactome_url}{character The URL to test. If \code{NULL} the URL 11 | is retrieved from the options.} 12 | } 13 | \value{ 14 | character The potentially cleaned / retrieved URL with a trailing "/" 15 | } 16 | \description{ 17 | Makes sure the passed URL is valid. If not URL is passed, the one 18 | stored in the options is retrieved 19 | } 20 | -------------------------------------------------------------------------------- /man/convert_reactome_result.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{convert_reactome_result} 4 | \alias{convert_reactome_result} 5 | \title{Convert the Reactome JSON result to a ReactomeAnalysisResult object} 6 | \usage{ 7 | convert_reactome_result(reactome_result) 8 | } 9 | \arguments{ 10 | \item{reactome_result}{The JSON result already converted to R objects (name list)} 11 | } 12 | \value{ 13 | A \code{\link{ReactomeAnalysisResult}} object 14 | } 15 | \description{ 16 | Convert the Reactome JSON result to a ReactomeAnalysisResult object 17 | } 18 | -------------------------------------------------------------------------------- /man/data_frame_as_string.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{data_frame_as_string} 4 | \alias{data_frame_as_string} 5 | \title{Converts a data.frame to a string representation} 6 | \usage{ 7 | data_frame_as_string(data) 8 | } 9 | \arguments{ 10 | \item{data}{The data.frame to convert} 11 | } 12 | \value{ 13 | A string representing the passed data.frame 14 | } 15 | \description{ 16 | A data.frame is converted into a single string using 17 | `\\t` (the characters, not tab) as field delimiter and 18 | `\\n` (the characters, not newline) as line delimiter 19 | } 20 | -------------------------------------------------------------------------------- /man/fetch_public_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/public_data.R 3 | \name{fetch_public_data} 4 | \alias{fetch_public_data} 5 | \title{fetch_public_data} 6 | \usage{ 7 | fetch_public_data(dataset_entry, reactome_url) 8 | } 9 | \arguments{ 10 | \item{dataset_entry}{The entry of the respective dataset as returned by 11 | the \code{\link{find_public_datasets}} function.} 12 | 13 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 14 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 15 | } 16 | \value{ 17 | The loaded data as an ExpressionSet object. 18 | } 19 | \description{ 20 | Loads an already available public dataset from ReactomeGSA 21 | and returns it as a Biobase::ExpressionSet object. 22 | } 23 | -------------------------------------------------------------------------------- /man/find_public_datasets.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/public_data.R 3 | \name{find_public_datasets} 4 | \alias{find_public_datasets} 5 | \title{find_public_datasets} 6 | \usage{ 7 | find_public_datasets( 8 | search_term, 9 | species = "Homo sapiens", 10 | reactome_url = NULL 11 | ) 12 | } 13 | \arguments{ 14 | \item{search_term}{The search terms as a single string. Multiple words 15 | (seperated by a space) are combined by an "AND".} 16 | 17 | \item{species}{Limit the search to selected species. The complete list of available species can be 18 | retrieved through \code{\link{get_public_species}}. By default, entries as limited to 19 | human datasets.} 20 | 21 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 22 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 23 | } 24 | \value{ 25 | A data.frame containing a list of datasets found through the search. 26 | } 27 | \description{ 28 | Search for a public dataset in the resources supported 29 | by ReactomeGSA as external data sources. 30 | } 31 | \examples{ 32 | # search for any public dataset relating to BRAF in melanoma 33 | melanoma_datasets <- find_public_datasets("melanoma braf") 34 | 35 | # it is also possible to limit this to another species than human 36 | melanoma_mouse <- find_public_datasets("melanoma", species = "Mus musculus") 37 | 38 | # the list of available species can be retrieved using get_public_species 39 | all_species <- get_public_species() 40 | 41 | # datasets can then be loaded using the load_public_dataset function 42 | } 43 | -------------------------------------------------------------------------------- /man/generate_metadata-data.frame-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_metadata.R 3 | \name{generate_metadata,data.frame-method} 4 | \alias{generate_metadata,data.frame-method} 5 | \title{Generate metadata} 6 | \usage{ 7 | \S4method{generate_metadata}{data.frame}(pseudo_bulk_data) 8 | } 9 | \arguments{ 10 | \item{pseudo_bulk_data}{Pseudobulk data generated from the 11 | \code{\link{generate_pseudo_bulk_data}} function} 12 | } 13 | \value{ 14 | Returns metadata table for later use 15 | } 16 | \description{ 17 | Generate metadata 18 | } 19 | -------------------------------------------------------------------------------- /man/generate_metadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_metadata.R 3 | \name{generate_metadata} 4 | \alias{generate_metadata} 5 | \title{generate_metadata} 6 | \usage{ 7 | generate_metadata(pseudo_bulk_data) 8 | } 9 | \arguments{ 10 | \item{pseudo_bulk_data}{Pseudobulk data generated from the 11 | \code{\link{generate_pseudo_bulk_data}} function} 12 | } 13 | \value{ 14 | Metadata table for later use 15 | } 16 | \description{ 17 | The pseudobulk data is generated using the 18 | \code{\link{generate_pseudo_bulk_data}} function. 19 | } 20 | \examples{ 21 | # Example pseudobulk data 22 | pseudo_bulk_data <- data.frame( 23 | sample1_groupA = c(10, 20, 30), 24 | sample2_groupA = c(15, 25, 35), 25 | sample3_groupB = c(5, 10, 15) 26 | ) 27 | 28 | # Generate metadata from pseudobulk data 29 | metadata <- generate_metadata(pseudo_bulk_data) 30 | 31 | } 32 | \seealso{ 33 | \code{\link{generate_pseudo_bulk_data}} for 34 | generating pseudobulk data. 35 | } 36 | -------------------------------------------------------------------------------- /man/generate_pseudo_bulk_data-Seurat-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_pseudo_bulk_data.R 3 | \name{generate_pseudo_bulk_data,Seurat-method} 4 | \alias{generate_pseudo_bulk_data,Seurat-method} 5 | \title{generate_pseudo_bulk_data - Seurat} 6 | \usage{ 7 | \S4method{generate_pseudo_bulk_data}{Seurat}( 8 | object, 9 | group_by = NULL, 10 | split_by = "random", 11 | k_variable = 4 12 | ) 13 | } 14 | \arguments{ 15 | \item{object}{The object to analyse.} 16 | 17 | \item{group_by}{entry in metadata table, based on these cluster annotation pseudo bulk is performed} 18 | 19 | \item{split_by}{variable -> split by a variable within the metadata; k must be a string 20 | random -> splits based on a random number; k must be a number 21 | Louvain, Louvain_multilevel, SLM, Leiden -> subclusters k must be a list with [resolution, cluster_1, cluster_2]} 22 | 23 | \item{k_variable}{variable dependent on the split_by} 24 | } 25 | \value{ 26 | returns pseudo bulk generated data 27 | } 28 | \description{ 29 | Generate Pseudo Bulk Data for Seurat Objects 30 | } 31 | -------------------------------------------------------------------------------- /man/generate_pseudo_bulk_data-SingleCellExperiment-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_pseudo_bulk_data.R 3 | \name{generate_pseudo_bulk_data,SingleCellExperiment-method} 4 | \alias{generate_pseudo_bulk_data,SingleCellExperiment-method} 5 | \title{generate_pseudo_bulk_data - SingleCellExperiment} 6 | \usage{ 7 | \S4method{generate_pseudo_bulk_data}{SingleCellExperiment}( 8 | object, 9 | group_by = NULL, 10 | split_by = "random", 11 | k_variable = 4 12 | ) 13 | } 14 | \arguments{ 15 | \item{object}{The SingleCellExperiment object to analyse.} 16 | 17 | \item{group_by}{entry in metadata table, based on these cluster annotation pseudo bulk is performed} 18 | 19 | \item{split_by}{variable -> split by a variable within the metadata; k must be a string 20 | random -> splits based on a random number; k must be a number 21 | subclustering [resolution, cluster_1, cluster_2]} 22 | 23 | \item{k_variable}{variable dependent on the split_by} 24 | } 25 | \value{ 26 | returns pseudo bulk generated data 27 | } 28 | \description{ 29 | generate_pseudo_bulk_data - SingleCellExperiment 30 | } 31 | -------------------------------------------------------------------------------- /man/generate_pseudo_bulk_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_pseudo_bulk_data.R 3 | \name{generate_pseudo_bulk_data} 4 | \alias{generate_pseudo_bulk_data} 5 | \title{generate_pseudo_bulk_data} 6 | \usage{ 7 | generate_pseudo_bulk_data( 8 | object, 9 | group_by = NULL, 10 | split_by = "random", 11 | k_variable = 4 12 | ) 13 | } 14 | \arguments{ 15 | \item{object}{The Seurat or SingleCellExperiment object to analyse.} 16 | 17 | \item{group_by}{entry in metadata table, based on these cluster annotation pseudo bulk is performed} 18 | 19 | \item{split_by}{variable -> split by a variable within the metadata; k must be a string 20 | random -> splits based on a random number; k must be a number 21 | Louvain, Louvain_multilevel, SLM, Leiden -> subclusters k must be a list with [resolution, cluster_1, cluster_2]} 22 | 23 | \item{k_variable}{variable dependent on the split_by} 24 | } 25 | \value{ 26 | returns pseudo bulk generated data 27 | } 28 | \description{ 29 | generate_pseudo_bulk_data 30 | } 31 | \examples{ 32 | 33 | #using SCE object 34 | library("scRNAseq") 35 | SCE_OBJECT <- ZeiselBrainData() 36 | # generating pseudo bulk data using the SCE object above, 37 | # and clustering level level1class from the metadata 38 | 39 | # generate pseudo bulk data based on random subsampling 40 | SCE_RESULT_RANDOM <- generate_pseudo_bulk_data(SCE_OBJECT, 41 | group_by = "level1class", 42 | split_by = "random", 43 | k_variable = 5) 44 | 45 | # generate pseudo bulk data based on variable within the metadata 46 | SCE_RESULT_VARIABLE <- generate_pseudo_bulk_data(SCE_OBJECT, "level1class","variable","tissue") 47 | 48 | } 49 | -------------------------------------------------------------------------------- /man/get_dataset_loading_status.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/public_data.R 3 | \name{get_dataset_loading_status} 4 | \alias{get_dataset_loading_status} 5 | \title{Retrieves the status of the submitted dataset loading request} 6 | \usage{ 7 | get_dataset_loading_status(loading_id, reactome_url = NULL) 8 | } 9 | \arguments{ 10 | \item{loading_id}{The dataset loading process' id} 11 | 12 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 13 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 14 | } 15 | \value{ 16 | A list containing the \code{id}, \code{status} (can be "running", "complete", "failed"), 17 | \code{description}, and \code{completed} (numeric between 0 - 1) 18 | } 19 | \description{ 20 | Retrieves the status of the submitted dataset loading request 21 | } 22 | -------------------------------------------------------------------------------- /man/get_fc_for_dataset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting_functions.R 3 | \name{get_fc_for_dataset} 4 | \alias{get_fc_for_dataset} 5 | \title{get_fc_for_dataset} 6 | \usage{ 7 | get_fc_for_dataset(dataset, pathway_result) 8 | } 9 | \arguments{ 10 | \item{dataset}{Name of the dataset to retrieve the fold changes for.} 11 | 12 | \item{pathway_result}{The data.frame created by the \code{pathways} function.} 13 | } 14 | \value{ 15 | A vector of fold-changes 16 | } 17 | \description{ 18 | Retrieve the fold-changes for all pathways of the defined dataset 19 | } 20 | -------------------------------------------------------------------------------- /man/get_is_sig_dataset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting_functions.R 3 | \name{get_is_sig_dataset} 4 | \alias{get_is_sig_dataset} 5 | \title{get_is_sig_dataset} 6 | \usage{ 7 | get_is_sig_dataset(dataset, pathway_result) 8 | } 9 | \arguments{ 10 | \item{dataset}{Name of the dataset} 11 | 12 | \item{pathway_result}{data.frame created by the \code{pathways} function} 13 | } 14 | \value{ 15 | A vector with 3=non-significant, 2=p<=0.05, 1=p<0.01 16 | } 17 | \description{ 18 | Determines how significant a pathway is across the datasets. Returns the 19 | lowest significance. 20 | } 21 | -------------------------------------------------------------------------------- /man/get_public_species.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/public_data.R 3 | \name{get_public_species} 4 | \alias{get_public_species} 5 | \title{get_public_species} 6 | \usage{ 7 | get_public_species(reactome_url = NULL) 8 | } 9 | \arguments{ 10 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 11 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 12 | } 13 | \value{ 14 | A vector of species strings. 15 | } 16 | \description{ 17 | Return the list of found species labels in the 18 | supported public data resources 19 | } 20 | \examples{ 21 | 22 | # get the available species 23 | available_species <- get_public_species() 24 | 25 | # inspect the first 1 - 3 entries 26 | available_species[1:3] 27 | } 28 | -------------------------------------------------------------------------------- /man/get_reactome_analysis_result.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_result.R 3 | \name{get_reactome_analysis_result} 4 | \alias{get_reactome_analysis_result} 5 | \title{Retrieves the result of the submitted analysis using \code{\link{perform_reactome_analysis}}} 6 | \usage{ 7 | get_reactome_analysis_result(analysis_id, reactome_url = NULL) 8 | } 9 | \arguments{ 10 | \item{analysis_id}{The running analysis' id} 11 | 12 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 13 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 14 | } 15 | \value{ 16 | The result object 17 | } 18 | \description{ 19 | The result is only available if \code{\link{get_reactome_analysis_status}} indicates that the 20 | analysis is complete. 21 | } 22 | -------------------------------------------------------------------------------- /man/get_reactome_analysis_status.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_result.R 3 | \name{get_reactome_analysis_status} 4 | \alias{get_reactome_analysis_status} 5 | \title{Retrieves the status of the submitted analysis using \code{\link{start_reactome_analysis}}} 6 | \usage{ 7 | get_reactome_analysis_status(analysis_id, reactome_url = NULL) 8 | } 9 | \arguments{ 10 | \item{analysis_id}{The running analysis' id} 11 | 12 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 13 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 14 | } 15 | \value{ 16 | A list containing the \code{id}, \code{status} (can be "running", "complete", "failed"), 17 | \code{description}, and \code{completed} (numeric between 0 - 1) 18 | } 19 | \description{ 20 | Retrieves the status of the submitted analysis using \code{\link{start_reactome_analysis}} 21 | } 22 | -------------------------------------------------------------------------------- /man/get_reactome_data_types.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_methods.R 3 | \name{get_reactome_data_types} 4 | \alias{get_reactome_data_types} 5 | \title{ReactomeGSA supported data types} 6 | \usage{ 7 | get_reactome_data_types( 8 | print_types = TRUE, 9 | return_result = FALSE, 10 | reactome_url = NULL 11 | ) 12 | } 13 | \arguments{ 14 | \item{print_types}{If set to \code{TRUE} (default) a (relatively) nice formatted version of the result is printed.} 15 | 16 | \item{return_result}{If set to \code{TRUE}, the result is returned as a data.frame (see below)} 17 | 18 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 19 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 20 | } 21 | \value{ 22 | A \code{data.frame} containing one row per data type with its \code{id} and \code{description}. 23 | } 24 | \description{ 25 | ReactomeGSA supported data types 26 | } 27 | \examples{ 28 | # retrieve the avialable data types 29 | available_types <- get_reactome_data_types(print_types = FALSE, return_result = TRUE) 30 | 31 | # print all data type ids 32 | available_types$id 33 | 34 | # simply print the available methods 35 | get_reactome_data_types() 36 | } 37 | \seealso{ 38 | Other Reactome Service functions: 39 | \code{\link{get_reactome_methods}()} 40 | } 41 | \author{ 42 | Johannes Griss 43 | } 44 | \concept{Reactome Service functions} 45 | -------------------------------------------------------------------------------- /man/get_reactome_methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_methods.R 3 | \name{get_reactome_methods} 4 | \alias{get_reactome_methods} 5 | \title{get_reactome_methods} 6 | \usage{ 7 | get_reactome_methods( 8 | print_methods = TRUE, 9 | print_details = FALSE, 10 | return_result = FALSE, 11 | method = NULL, 12 | reactome_url = NULL 13 | ) 14 | } 15 | \arguments{ 16 | \item{print_methods}{If set to \code{TRUE} (default) a (relatively) nice formatted version of the result is printed.} 17 | 18 | \item{print_details}{If set to \code{TRUE} detailed information about every method, including available parameters and 19 | description are displayed. This does not affect the data returned if \code{return_result} is \code{TRUE}.} 20 | 21 | \item{return_result}{If set to \code{TRUE}, the result is returned as a data.frame (see below)} 22 | 23 | \item{method}{If set to a method's id, only information for this method will be shown. This is especially useful if 24 | detailed information about a single method should be retrieved. This does not affect the data returned 25 | if \code{return_result} is \code{TRUE}.} 26 | 27 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 28 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 29 | } 30 | \value{ 31 | If \code{return_result} is set to \code{TRUE}, a data.frame with one row per method. Each method has a name, description, and 32 | (optional) a list of parameters. Parameters again have a name, type, and description. 33 | } 34 | \description{ 35 | Returns all available analysis methods from the Reactome analysis service. 36 | } 37 | \details{ 38 | Every method has a type, a scope, and sometimes a list of allowed values. The type (string, int = integer, float) define 39 | the expected data type. The \strong{scope} defines at what level the parameter can be set. \emph{dataset} level parameters 40 | can be set at the dataset level (using the \code{\link{add_dataset}} function) or at the analysis request level (using 41 | \code{\link{set_parameters}}). If these parameters are set at the analysis request level, this overwrites the default 42 | value for all datasets. \emph{analysis} and \emph{global} level parameters must only be set at the analysis request level 43 | using \code{\link{set_parameters}}. The difference between these two types of parameters is that while \emph{analysis} 44 | parameters influence the results, \emph{global} parameters only influence the behaviour of the analysis system (for example 45 | whether a Reactome visualization is created). 46 | } 47 | \examples{ 48 | # retrieve the available methods only in an object 49 | available_methods <- get_reactome_methods(print_methods = FALSE, return_result = TRUE) 50 | 51 | # print all method names 52 | available_methods$name 53 | 54 | # list all parameters for the first method 55 | first_method_parameters <- available_methods[1, "parameters"] 56 | first_method_parameters 57 | 58 | # simply print the available methods 59 | get_reactome_methods() 60 | 61 | # get the details for PADOG 62 | get_reactome_methods(print_details = TRUE, method = "PADOG") 63 | } 64 | \seealso{ 65 | Other Reactome Service functions: 66 | \code{\link{get_reactome_data_types}()} 67 | } 68 | \author{ 69 | Johannes Griss 70 | } 71 | \concept{Reactome Service functions} 72 | -------------------------------------------------------------------------------- /man/get_result-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{get_result,ReactomeAnalysisResult-method} 4 | \alias{get_result,ReactomeAnalysisResult-method} 5 | \title{ReactomeAnalysisResult - get_result} 6 | \usage{ 7 | \S4method{get_result}{ReactomeAnalysisResult}(x, type, name) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | 12 | \item{type}{the type of result. Use \code{\link{result_types}} 13 | to retrieve all available types.} 14 | 15 | \item{name}{the name of the result. Use \code{\link{names}} 16 | to retrieve all available results.} 17 | } 18 | \value{ 19 | A \code{data.frame} containing the respective result. 20 | } 21 | \description{ 22 | Retrieves a result from a \code{\link{ReactomeAnalysisResult}} object. 23 | } 24 | \examples{ 25 | # load an example result object 26 | library(ReactomeGSA.data) 27 | data(griss_melanoma_result) 28 | 29 | # get the available result types 30 | result_types(griss_melanoma_result) 31 | 32 | # get the dataset names 33 | names(griss_melanoma_result) 34 | 35 | # get the fold_changes for the first dataset 36 | prot_fc <- get_result(griss_melanoma_result, type = "fold_changes", name = "proteomics") 37 | 38 | head(prot_fc) 39 | } 40 | \seealso{ 41 | Other ReactomeAnalysisResult functions: 42 | \code{\link{names,ReactomeAnalysisResult-method}}, 43 | \code{\link{open_reactome}()}, 44 | \code{\link{pathways}()}, 45 | \code{\link{plot_correlations}()}, 46 | \code{\link{plot_gsva_heatmap}()}, 47 | \code{\link{plot_gsva_pathway}()}, 48 | \code{\link{plot_heatmap}()}, 49 | \code{\link{plot_volcano}()}, 50 | \code{\link{reactome_links}()}, 51 | \code{\link{result_types}()} 52 | } 53 | -------------------------------------------------------------------------------- /man/get_result.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{get_result} 4 | \alias{get_result} 5 | \title{get_result} 6 | \usage{ 7 | get_result(x, type, name) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | 12 | \item{type}{the type of result. Use \code{\link{result_types}} 13 | to retrieve all available types.} 14 | 15 | \item{name}{the name of the result. Use \code{\link{names}} 16 | to retrieve all available results.} 17 | } 18 | \value{ 19 | A \code{data.frame} containing the respective result. 20 | } 21 | \description{ 22 | Retrieves a result from a \code{\link{ReactomeAnalysisResult}} object. 23 | } 24 | \examples{ 25 | # load an example result object 26 | library(ReactomeGSA.data) 27 | data(griss_melanoma_result) 28 | 29 | # get the available result types 30 | result_types(griss_melanoma_result) 31 | 32 | # get the dataset names 33 | names(griss_melanoma_result) 34 | 35 | # get the fold_changes for the first dataset 36 | prot_fc <- get_result(griss_melanoma_result, type = "fold_changes", name = "proteomics") 37 | 38 | head(prot_fc) 39 | } 40 | \seealso{ 41 | Other ReactomeAnalysisResult functions: 42 | \code{\link{names,ReactomeAnalysisResult-method}}, 43 | \code{\link{open_reactome}()}, 44 | \code{\link{pathways}()}, 45 | \code{\link{plot_correlations}()}, 46 | \code{\link{plot_gsva_heatmap}()}, 47 | \code{\link{plot_gsva_pathway}()}, 48 | \code{\link{plot_heatmap}()}, 49 | \code{\link{plot_volcano}()}, 50 | \code{\link{reactome_links}()}, 51 | \code{\link{result_types}()} 52 | } 53 | \concept{ReactomeAnalysisResult functions} 54 | -------------------------------------------------------------------------------- /man/is_gsva_result.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gsva_plotting_functions.R 3 | \name{is_gsva_result} 4 | \alias{is_gsva_result} 5 | \title{is_gsva_result} 6 | \usage{ 7 | is_gsva_result(object) 8 | } 9 | \arguments{ 10 | \item{object}{A \code{\link{ReactomeAnalysisResult}} object} 11 | } 12 | \value{ 13 | Boolean indicating whether the object is a GSVA result. 14 | } 15 | \description{ 16 | is_gsva_result 17 | } 18 | -------------------------------------------------------------------------------- /man/load_public_dataset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/public_data.R 3 | \name{load_public_dataset} 4 | \alias{load_public_dataset} 5 | \title{load_public_dataset} 6 | \usage{ 7 | load_public_dataset(dataset_entry, verbose = FALSE, reactome_url = NULL) 8 | } 9 | \arguments{ 10 | \item{dataset_entry}{The entry of the respective dataset as returned by 11 | the \code{\link{find_public_datasets}} function.} 12 | 13 | \item{verbose}{If set to \code{TRUE}, status messages and a status bar are displayed.} 14 | 15 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 16 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 17 | } 18 | \value{ 19 | The loaded data as an ExpressionSet object. 20 | } 21 | \description{ 22 | Loads a public dataset that was found through the 23 | \code{\link{find_public_datasets}} function. The dataset 24 | is returned as a Biobase ExpressionSet object. 25 | } 26 | \examples{ 27 | # As a first step, you need to find available datasets 28 | available_datasets <- find_public_datasets("psoriasis tnf") 29 | 30 | # have a quick look at the found datasets 31 | available_datasets[, c("id", "title")] 32 | 33 | # load the first one, use the whole row of the found datasets 34 | # data.frame as the parameter 35 | dataset_1 <- load_public_dataset(available_datasets[1,], verbose = TRUE) 36 | 37 | } 38 | -------------------------------------------------------------------------------- /man/names-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{names,ReactomeAnalysisResult-method} 4 | \alias{names,ReactomeAnalysisResult-method} 5 | \title{ReactomeAnalysisResult - names} 6 | \usage{ 7 | \S4method{names}{ReactomeAnalysisResult}(x) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | } 12 | \value{ 13 | character vector with the names of the contained datasets 14 | } 15 | \description{ 16 | Retrieves the names of the contained datasets within an \code{\link{ReactomeAnalysisResult}} 17 | object. 18 | } 19 | \examples{ 20 | # load an example result object 21 | library(ReactomeGSA.data) 22 | data(griss_melanoma_result) 23 | 24 | # get the names of the available datasets 25 | names(griss_melanoma_result) 26 | } 27 | \seealso{ 28 | Other ReactomeAnalysisResult functions: 29 | \code{\link{get_result}()}, 30 | \code{\link{open_reactome}()}, 31 | \code{\link{pathways}()}, 32 | \code{\link{plot_correlations}()}, 33 | \code{\link{plot_gsva_heatmap}()}, 34 | \code{\link{plot_gsva_pathway}()}, 35 | \code{\link{plot_heatmap}()}, 36 | \code{\link{plot_volcano}()}, 37 | \code{\link{reactome_links}()}, 38 | \code{\link{result_types}()} 39 | } 40 | \concept{ReactomeAnalysisResult functions} 41 | -------------------------------------------------------------------------------- /man/open_reactome-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{open_reactome,ReactomeAnalysisResult-method} 4 | \alias{open_reactome,ReactomeAnalysisResult-method} 5 | \title{open_reactome - ReactomeAnalysisResult} 6 | \usage{ 7 | \S4method{open_reactome}{ReactomeAnalysisResult}(x, n_visualization = 1, ...) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | 12 | \item{n_visualization}{numeric The index of the visualization to display (default \code{1}). 13 | Use \code{\link{reactome_links}} 14 | to retrieve all available visualizations and their index. By default, 15 | the first visualization is opened.} 16 | 17 | \item{...}{Additional parameters passed to downstream functions.} 18 | } 19 | \value{ 20 | The opened link 21 | } 22 | \description{ 23 | Opens the specified Reactome visualization in the system's default browser. 24 | } 25 | \examples{ 26 | # Note: This function only works with a newly created result 27 | # since the visualization links only stay active for 7 days 28 | 29 | # load an example result 30 | library(ReactomeGSA.data) 31 | data(griss_melanoma_result) 32 | 33 | # get the reactome link - this does only work 34 | # with new results 35 | # open_reactome(griss_melanoma_result) 36 | } 37 | \seealso{ 38 | Other ReactomeAnalysisResult functions: 39 | \code{\link{get_result}()}, 40 | \code{\link{names,ReactomeAnalysisResult-method}}, 41 | \code{\link{pathways}()}, 42 | \code{\link{plot_correlations}()}, 43 | \code{\link{plot_gsva_heatmap}()}, 44 | \code{\link{plot_gsva_pathway}()}, 45 | \code{\link{plot_heatmap}()}, 46 | \code{\link{plot_volcano}()}, 47 | \code{\link{reactome_links}()}, 48 | \code{\link{result_types}()} 49 | } 50 | -------------------------------------------------------------------------------- /man/open_reactome.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{open_reactome} 4 | \alias{open_reactome} 5 | \title{open_reactome} 6 | \usage{ 7 | open_reactome(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | 12 | \item{...}{Additional parameters passed to downstream functions.} 13 | } 14 | \value{ 15 | The opened link 16 | } 17 | \description{ 18 | Opens the specified Reactome visualization in the system's default browser. 19 | } 20 | \examples{ 21 | # Note: This function only works with a newly created result 22 | # since the visualization links only stay active for 7 days 23 | 24 | # load an example result 25 | library(ReactomeGSA.data) 26 | data(griss_melanoma_result) 27 | 28 | # get the reactome link - this does only work 29 | # with new results 30 | # open_reactome(griss_melanoma_result) 31 | } 32 | \seealso{ 33 | Other ReactomeAnalysisResult functions: 34 | \code{\link{get_result}()}, 35 | \code{\link{names,ReactomeAnalysisResult-method}}, 36 | \code{\link{pathways}()}, 37 | \code{\link{plot_correlations}()}, 38 | \code{\link{plot_gsva_heatmap}()}, 39 | \code{\link{plot_gsva_pathway}()}, 40 | \code{\link{plot_heatmap}()}, 41 | \code{\link{plot_volcano}()}, 42 | \code{\link{reactome_links}()}, 43 | \code{\link{result_types}()} 44 | } 45 | \concept{ReactomeAnalysisResult functions} 46 | -------------------------------------------------------------------------------- /man/pathways-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{pathways,ReactomeAnalysisResult-method} 4 | \alias{pathways,ReactomeAnalysisResult-method} 5 | \title{ReactomeAnalysisResult - pathways} 6 | \usage{ 7 | \S4method{pathways}{ReactomeAnalysisResult}(x, p = 0.01, order_by = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | 12 | \item{p}{Minimum p-value to accept a pathway as significantly regulated. Default is 0.01.} 13 | 14 | \item{order_by}{Name of the dataset to sort the result list by. By default, the 15 | results are sorted based on the first dataset.} 16 | 17 | \item{...}{Additional parameters for specific implementations.} 18 | } 19 | \value{ 20 | A \code{data.frame} containing all merged pathways. 21 | } 22 | \description{ 23 | Combines and returns the pathways of all analysed datasets. 24 | } 25 | \examples{ 26 | # load an example result 27 | library(ReactomeGSA.data) 28 | data(griss_melanoma_result) 29 | 30 | # get the combined pathway result 31 | pathway_result <- pathways(griss_melanoma_result) 32 | 33 | head(pathway_result) 34 | } 35 | \seealso{ 36 | Other ReactomeAnalysisResult functions: 37 | \code{\link{get_result}()}, 38 | \code{\link{names,ReactomeAnalysisResult-method}}, 39 | \code{\link{open_reactome}()}, 40 | \code{\link{plot_correlations}()}, 41 | \code{\link{plot_gsva_heatmap}()}, 42 | \code{\link{plot_gsva_pathway}()}, 43 | \code{\link{plot_heatmap}()}, 44 | \code{\link{plot_volcano}()}, 45 | \code{\link{reactome_links}()}, 46 | \code{\link{result_types}()} 47 | } 48 | -------------------------------------------------------------------------------- /man/pathways.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{pathways} 4 | \alias{pathways} 5 | \title{pathways} 6 | \usage{ 7 | pathways(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | 12 | \item{...}{Additional parameters for specific implementations.} 13 | } 14 | \value{ 15 | A \code{data.frame} containing all merged pathways. 16 | } 17 | \description{ 18 | Combines and returns the pathways of all analysed datasets. 19 | } 20 | \examples{ 21 | # load an example result 22 | library(ReactomeGSA.data) 23 | data(griss_melanoma_result) 24 | 25 | # get the combined pathway result 26 | pathway_result <- pathways(griss_melanoma_result) 27 | 28 | head(pathway_result) 29 | } 30 | \seealso{ 31 | Other ReactomeAnalysisResult functions: 32 | \code{\link{get_result}()}, 33 | \code{\link{names,ReactomeAnalysisResult-method}}, 34 | \code{\link{open_reactome}()}, 35 | \code{\link{plot_correlations}()}, 36 | \code{\link{plot_gsva_heatmap}()}, 37 | \code{\link{plot_gsva_pathway}()}, 38 | \code{\link{plot_heatmap}()}, 39 | \code{\link{plot_volcano}()}, 40 | \code{\link{reactome_links}()}, 41 | \code{\link{result_types}()} 42 | } 43 | \concept{ReactomeAnalysisResult functions} 44 | -------------------------------------------------------------------------------- /man/perform_reactome_analysis.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/perform_analysis.R 3 | \name{perform_reactome_analysis} 4 | \alias{perform_reactome_analysis} 5 | \title{Perform a Reactome Analaysis} 6 | \usage{ 7 | perform_reactome_analysis( 8 | request, 9 | verbose = TRUE, 10 | compress = TRUE, 11 | reactome_url = NULL 12 | ) 13 | } 14 | \arguments{ 15 | \item{request}{\code{\link{ReactomeAnalysisRequest}} to submit.} 16 | 17 | \item{verbose}{logical. If \code{FALSE} status messages are not printed to the console.} 18 | 19 | \item{compress}{logical. If \code{TRUE} (default) the request data is compressed before submitting it to the ReactomeGSA API. 20 | This is the generally recommended way and should only be disabled for debugging purposes.} 21 | 22 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 23 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 24 | } 25 | \value{ 26 | The analysis' result 27 | } 28 | \description{ 29 | This function wraps all steps required to perform 30 | an Analysis using the Reactome Analysis Service. It submits 31 | the passed \code{\link{ReactomeAnalysisRequest}} object to the 32 | Reactome Analysis Service API, checks the submitted analysis' 33 | status and returns the result once the analysis is complete. 34 | } 35 | \examples{ 36 | # create a request using Camera as an analysis 37 | library(ReactomeGSA.data) 38 | data(griss_melanoma_proteomics) 39 | 40 | my_request <- ReactomeAnalysisRequest(method = "Camera") 41 | 42 | # set maximum missing values to 0.5 and do not create any reactome visualizations 43 | my_request <- set_parameters(request = my_request, 44 | max_missing_values = 0.5, 45 | create_reactome_visualization = FALSE) 46 | 47 | # add the dataset 48 | my_request <- add_dataset(request = my_request, 49 | expression_values = griss_melanoma_proteomics, 50 | name = "Proteomics", 51 | type = "proteomics_int", 52 | comparison_factor = "condition", 53 | comparison_group_1 = "MOCK", 54 | comparison_group_2 = "MCM", 55 | additional_factors = c("cell.type", "patient.id")) 56 | 57 | # perform the analysis 58 | my_result <- perform_reactome_analysis(request = my_request, verbose = FALSE) 59 | } 60 | -------------------------------------------------------------------------------- /man/plot_correlations-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting_functions.R 3 | \name{plot_correlations,ReactomeAnalysisResult-method} 4 | \alias{plot_correlations,ReactomeAnalysisResult-method} 5 | \title{plot_correlations - ReactomeAnalysisResult} 6 | \usage{ 7 | \S4method{plot_correlations}{ReactomeAnalysisResult}(x, hide_non_sig = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult. The result object to use as input} 11 | 12 | \item{hide_non_sig}{If set, non-significant pathways are not shown.} 13 | } 14 | \value{ 15 | A list of ggplot2 plot objects representing one plot per combination 16 | } 17 | \description{ 18 | Plots correlations of the average fold-changes of all pathways between 19 | the different datasets. This function is only available to GSA based 20 | results (not GSVA ones). 21 | } 22 | \examples{ 23 | # load an example result 24 | library(ReactomeGSA.data) 25 | data(griss_melanoma_result) 26 | 27 | # create the correlation plots 28 | plot_objs <- plot_correlations(griss_melanoma_result) 29 | 30 | # only one plot created for this result as it contains two datasets 31 | length(plot_objs) 32 | 33 | # show the plot using `print(plot_objs[[1]])` 34 | } 35 | \seealso{ 36 | Other ReactomeAnalysisResult functions: 37 | \code{\link{get_result}()}, 38 | \code{\link{names,ReactomeAnalysisResult-method}}, 39 | \code{\link{open_reactome}()}, 40 | \code{\link{pathways}()}, 41 | \code{\link{plot_gsva_heatmap}()}, 42 | \code{\link{plot_gsva_pathway}()}, 43 | \code{\link{plot_heatmap}()}, 44 | \code{\link{plot_volcano}()}, 45 | \code{\link{reactome_links}()}, 46 | \code{\link{result_types}()} 47 | } 48 | -------------------------------------------------------------------------------- /man/plot_correlations.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting_functions.R 3 | \name{plot_correlations} 4 | \alias{plot_correlations} 5 | \title{plot_correlations} 6 | \usage{ 7 | plot_correlations(x, hide_non_sig = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult. The result object to use as input} 11 | 12 | \item{hide_non_sig}{If set, non-significant pathways are not shown.} 13 | } 14 | \value{ 15 | A list of ggplot2 plot objects representing one plot per combination 16 | } 17 | \description{ 18 | Plots correlations of the average fold-changes of all pathways between 19 | the different datasets. This function is only available to GSA based 20 | results (not GSVA ones). 21 | } 22 | \examples{ 23 | # load an example result 24 | library(ReactomeGSA.data) 25 | data(griss_melanoma_result) 26 | 27 | # create the correlation plots 28 | plot_objs <- plot_correlations(griss_melanoma_result) 29 | 30 | # only one plot created for this result as it contains two datasets 31 | length(plot_objs) 32 | 33 | # show the plot using `print(plot_objs[[1]])` 34 | } 35 | \seealso{ 36 | Other ReactomeAnalysisResult functions: 37 | \code{\link{get_result}()}, 38 | \code{\link{names,ReactomeAnalysisResult-method}}, 39 | \code{\link{open_reactome}()}, 40 | \code{\link{pathways}()}, 41 | \code{\link{plot_gsva_heatmap}()}, 42 | \code{\link{plot_gsva_pathway}()}, 43 | \code{\link{plot_heatmap}()}, 44 | \code{\link{plot_volcano}()}, 45 | \code{\link{reactome_links}()}, 46 | \code{\link{result_types}()} 47 | } 48 | \concept{ReactomeAnalysisResult functions} 49 | -------------------------------------------------------------------------------- /man/plot_gsva_heatmap-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gsva_plotting_functions.R 3 | \name{plot_gsva_heatmap,ReactomeAnalysisResult-method} 4 | \alias{plot_gsva_heatmap,ReactomeAnalysisResult-method} 5 | \title{plot_gsva_heatmap - ReactomeAnalysisResult function} 6 | \usage{ 7 | \S4method{plot_gsva_heatmap}{ReactomeAnalysisResult}( 8 | object, 9 | pathway_ids = NULL, 10 | max_pathways = 20, 11 | truncate_names = TRUE, 12 | ... 13 | ) 14 | } 15 | \arguments{ 16 | \item{object}{The \code{\link{ReactomeAnalysisResult}} object.} 17 | 18 | \item{pathway_ids}{A vector of pathway ids. If set, only these pathways are included in the plot.} 19 | 20 | \item{max_pathways}{The maximum number of pathways to include. Only takes effect if \code{pathway_ids} 21 | is not set.} 22 | 23 | \item{truncate_names}{If set, long pathway names are truncated.} 24 | 25 | \item{...}{Additional parameters passed to the heatmap.2 function.} 26 | } 27 | \value{ 28 | None 29 | } 30 | \description{ 31 | Plots pathway expression values / sample as a heatmap. Ranks pathways based on their 32 | expression difference. 33 | } 34 | \examples{ 35 | # load the scRNA-seq example data 36 | library(ReactomeGSA.data) 37 | data(jerby_b_cells) 38 | 39 | # perform the GSVA analysis 40 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 41 | 42 | # plot the heatmap 43 | relevant_pathways <- c("R-HSA-983170", "R-HSA-388841", "R-HSA-2132295", 44 | "R-HSA-983705", "R-HSA-5690714") 45 | plot_gsva_heatmap(gsva_result, 46 | pathway_ids = relevant_pathways, # limit to these pathways 47 | margins = c(6,30), # adapt the figure margins in heatmap.2 48 | dendrogram = "col", # only plot column dendrogram 49 | scale = "row", # scale for each pathway 50 | key = FALSE, # don't display the color key 51 | lwid=c(0.1,4)) # remove the white space on the left 52 | } 53 | \seealso{ 54 | Other ReactomeAnalysisResult functions: 55 | \code{\link{get_result}()}, 56 | \code{\link{names,ReactomeAnalysisResult-method}}, 57 | \code{\link{open_reactome}()}, 58 | \code{\link{pathways}()}, 59 | \code{\link{plot_correlations}()}, 60 | \code{\link{plot_gsva_pathway}()}, 61 | \code{\link{plot_heatmap}()}, 62 | \code{\link{plot_volcano}()}, 63 | \code{\link{reactome_links}()}, 64 | \code{\link{result_types}()} 65 | } 66 | -------------------------------------------------------------------------------- /man/plot_gsva_heatmap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gsva_plotting_functions.R 3 | \name{plot_gsva_heatmap} 4 | \alias{plot_gsva_heatmap} 5 | \title{plot_gsva_heatmap} 6 | \usage{ 7 | plot_gsva_heatmap( 8 | object, 9 | pathway_ids = NULL, 10 | max_pathways = 20, 11 | truncate_names = TRUE, 12 | ... 13 | ) 14 | } 15 | \arguments{ 16 | \item{object}{The \code{\link{ReactomeAnalysisResult}} object.} 17 | 18 | \item{pathway_ids}{A vector of pathway ids. If set, only these pathways are included in the plot.} 19 | 20 | \item{max_pathways}{The maximum number of pathways to include. Only takes effect if \code{pathway_ids} 21 | is not set.} 22 | 23 | \item{truncate_names}{If set, long pathway names are truncated.} 24 | 25 | \item{...}{Additional parameters passed to specific implementations.} 26 | } 27 | \value{ 28 | None 29 | } 30 | \description{ 31 | Plots pathway expression values / sample as a heatmap. Ranks pathways based on their 32 | expression difference. 33 | } 34 | \examples{ 35 | # load the scRNA-seq example data 36 | library(ReactomeGSA.data) 37 | data(jerby_b_cells) 38 | 39 | # perform the GSVA analysis 40 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 41 | 42 | # plot the heatmap 43 | relevant_pathways <- c("R-HSA-983170", "R-HSA-388841", "R-HSA-2132295", 44 | "R-HSA-983705", "R-HSA-5690714") 45 | plot_gsva_heatmap(gsva_result, 46 | pathway_ids = relevant_pathways, # limit to these pathways 47 | margins = c(6,30), # adapt the figure margins in heatmap.2 48 | dendrogram = "col", # only plot column dendrogram 49 | scale = "row", # scale for each pathway 50 | key = FALSE, # don't display the color key 51 | lwid=c(0.1,4)) # remove the white space on the left 52 | } 53 | \seealso{ 54 | Other ReactomeAnalysisResult functions: 55 | \code{\link{get_result}()}, 56 | \code{\link{names,ReactomeAnalysisResult-method}}, 57 | \code{\link{open_reactome}()}, 58 | \code{\link{pathways}()}, 59 | \code{\link{plot_correlations}()}, 60 | \code{\link{plot_gsva_pathway}()}, 61 | \code{\link{plot_heatmap}()}, 62 | \code{\link{plot_volcano}()}, 63 | \code{\link{reactome_links}()}, 64 | \code{\link{result_types}()} 65 | } 66 | \concept{ReactomeAnalysisResult functions} 67 | -------------------------------------------------------------------------------- /man/plot_gsva_pathway-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gsva_plotting_functions.R 3 | \name{plot_gsva_pathway,ReactomeAnalysisResult-method} 4 | \alias{plot_gsva_pathway,ReactomeAnalysisResult-method} 5 | \title{ReactomeAnalysisResult - plot_gsva_pathway} 6 | \usage{ 7 | \S4method{plot_gsva_pathway}{ReactomeAnalysisResult}(object, pathway_id, ...) 8 | } 9 | \arguments{ 10 | \item{object}{The \code{\link{ReactomeAnalysisResult}} object.} 11 | 12 | \item{pathway_id}{The pathway's id} 13 | 14 | \item{...}{Additional parameters for specific implementations.} 15 | } 16 | \value{ 17 | A ggplot2 plot object 18 | } 19 | \description{ 20 | Plots the expression of a specific pathway from a ssGSEA result. 21 | } 22 | \examples{ 23 | # load the scRNA-seq example data 24 | library(ReactomeGSA.data) 25 | data(jerby_b_cells) 26 | 27 | # perform the GSVA analysis 28 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 29 | 30 | # create the plot 31 | plot_obj <- plot_gsva_pathway(gsva_result, "R-HSA-389542") 32 | } 33 | \seealso{ 34 | Other ReactomeAnalysisResult functions: 35 | \code{\link{get_result}()}, 36 | \code{\link{names,ReactomeAnalysisResult-method}}, 37 | \code{\link{open_reactome}()}, 38 | \code{\link{pathways}()}, 39 | \code{\link{plot_correlations}()}, 40 | \code{\link{plot_gsva_heatmap}()}, 41 | \code{\link{plot_heatmap}()}, 42 | \code{\link{plot_volcano}()}, 43 | \code{\link{reactome_links}()}, 44 | \code{\link{result_types}()} 45 | } 46 | -------------------------------------------------------------------------------- /man/plot_gsva_pathway.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gsva_plotting_functions.R 3 | \name{plot_gsva_pathway} 4 | \alias{plot_gsva_pathway} 5 | \title{plot_gsva_pathway} 6 | \usage{ 7 | plot_gsva_pathway(object, pathway_id, ...) 8 | } 9 | \arguments{ 10 | \item{object}{The \code{\link{ReactomeAnalysisResult}} object.} 11 | 12 | \item{pathway_id}{The pathway's id} 13 | 14 | \item{...}{Additional parameters for specific implementations.} 15 | } 16 | \value{ 17 | A ggplot2 plot object 18 | } 19 | \description{ 20 | Plots the expression of a specific pathway from a ssGSEA result. 21 | } 22 | \examples{ 23 | # load the scRNA-seq example data 24 | library(ReactomeGSA.data) 25 | data(jerby_b_cells) 26 | 27 | # perform the GSVA analysis 28 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 29 | 30 | # create the plot 31 | plot_obj <- plot_gsva_pathway(gsva_result, "R-HSA-389542") 32 | } 33 | \seealso{ 34 | Other ReactomeAnalysisResult functions: 35 | \code{\link{get_result}()}, 36 | \code{\link{names,ReactomeAnalysisResult-method}}, 37 | \code{\link{open_reactome}()}, 38 | \code{\link{pathways}()}, 39 | \code{\link{plot_correlations}()}, 40 | \code{\link{plot_gsva_heatmap}()}, 41 | \code{\link{plot_heatmap}()}, 42 | \code{\link{plot_volcano}()}, 43 | \code{\link{reactome_links}()}, 44 | \code{\link{result_types}()} 45 | } 46 | \concept{ReactomeAnalysisResult functions} 47 | -------------------------------------------------------------------------------- /man/plot_gsva_pca-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gsva_plotting_functions.R 3 | \name{plot_gsva_pca,ReactomeAnalysisResult-method} 4 | \alias{plot_gsva_pca,ReactomeAnalysisResult-method} 5 | \title{plot_gsva_pca - ReactomeAnalysisResult} 6 | \usage{ 7 | \S4method{plot_gsva_pca}{ReactomeAnalysisResult}(object, pathway_ids = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{object}{A \code{\link{ReactomeAnalysisResult}} object containing a ssGSEA result} 11 | 12 | \item{pathway_ids}{A character vector of pathway ids. If set, only these pathways will be 13 | used for the PCA analysis.} 14 | 15 | \item{...}{Additional parameters are passed to \code{prcomp}} 16 | } 17 | \value{ 18 | A ggplot2 object representing the plot. 19 | } 20 | \description{ 21 | Runs a Principal Component analysis (using \code{prcomp}) on the samples 22 | based on the pathway analysis results. 23 | } 24 | \examples{ 25 | # load the scRNA-seq example data 26 | library(ReactomeGSA.data) 27 | data(jerby_b_cells) 28 | 29 | # perform the GSVA analysis 30 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 31 | } 32 | -------------------------------------------------------------------------------- /man/plot_gsva_pca.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gsva_plotting_functions.R 3 | \name{plot_gsva_pca} 4 | \alias{plot_gsva_pca} 5 | \title{plot_gsva_pca} 6 | \usage{ 7 | plot_gsva_pca(object, pathway_ids = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{object}{A \code{\link{ReactomeAnalysisResult}} object containing a ssGSEA result} 11 | 12 | \item{pathway_ids}{A character vector of pathway ids. If set, only these pathways will be 13 | used for the PCA analysis.} 14 | 15 | \item{...}{Additional paramters passed to specific implementations.} 16 | } 17 | \value{ 18 | A ggplot2 object representing the plot. 19 | } 20 | \description{ 21 | Runs a Principal Component analysis (using \code{prcomp}) on the samples 22 | based on the pathway analysis results. 23 | } 24 | \examples{ 25 | # load the scRNA-seq example data 26 | library(ReactomeGSA.data) 27 | data(jerby_b_cells) 28 | 29 | # perform the GSVA analysis 30 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = FALSE) 31 | } 32 | -------------------------------------------------------------------------------- /man/plot_heatmap-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting_functions.R 3 | \name{plot_heatmap,ReactomeAnalysisResult-method} 4 | \alias{plot_heatmap,ReactomeAnalysisResult-method} 5 | \title{plot_heatmap - ReactomeAnalysisResult} 6 | \usage{ 7 | \S4method{plot_heatmap}{ReactomeAnalysisResult}( 8 | x, 9 | fdr = 0.01, 10 | max_pathways = 30, 11 | break_long_names = TRUE, 12 | return_data = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{x}{ReactomeAnalysisResult. The result object to use as input} 17 | 18 | \item{fdr}{numeric. The minimum FDR to consider a pathways as significantly 19 | regulated. (Default 0.01)} 20 | 21 | \item{max_pathways}{numeric. The maximum number of pathways to plot. Pathways 22 | are sorted based on in how many datasets they are significantly regulated. 23 | This has no effect if \code{return_data} is set to \code{TRUE}.} 24 | 25 | \item{break_long_names}{logical. If set, long pathway names are broken into 26 | two lines.} 27 | 28 | \item{return_data}{logical. If set, only the plotting data, but not the plot 29 | object itself is returned. This can be used to create customized plots 30 | that use the same data structure.} 31 | } 32 | \value{ 33 | A ggplot2 plot object representing the heatmap of pathways 34 | } 35 | \description{ 36 | Creates a heatmap to show which pathways are up- and down-regulated 37 | in different datasets 38 | } 39 | \examples{ 40 | # load an example result 41 | library(ReactomeGSA.data) 42 | data(griss_melanoma_result) 43 | 44 | # create the heatmap plot 45 | plot_obj <- plot_heatmap(griss_melanoma_result) 46 | 47 | # show the plot 48 | print(plot_obj) 49 | } 50 | \seealso{ 51 | Other ReactomeAnalysisResult functions: 52 | \code{\link{get_result}()}, 53 | \code{\link{names,ReactomeAnalysisResult-method}}, 54 | \code{\link{open_reactome}()}, 55 | \code{\link{pathways}()}, 56 | \code{\link{plot_correlations}()}, 57 | \code{\link{plot_gsva_heatmap}()}, 58 | \code{\link{plot_gsva_pathway}()}, 59 | \code{\link{plot_volcano}()}, 60 | \code{\link{reactome_links}()}, 61 | \code{\link{result_types}()} 62 | } 63 | -------------------------------------------------------------------------------- /man/plot_heatmap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting_functions.R 3 | \name{plot_heatmap} 4 | \alias{plot_heatmap} 5 | \title{plot_heatmap} 6 | \usage{ 7 | plot_heatmap( 8 | x, 9 | fdr = 0.01, 10 | max_pathways = 30, 11 | break_long_names = TRUE, 12 | return_data = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{x}{ReactomeAnalysisResult. The result object to use as input} 17 | 18 | \item{fdr}{numeric. The minimum FDR to consider a pathways as significantly 19 | regulated. (Default 0.01)} 20 | 21 | \item{max_pathways}{numeric. The maximum number of pathways to plot. Pathways 22 | are sorted based on in how many datasets they are significantly regulated. 23 | This has no effect if \code{return_data} is set to \code{TRUE}.} 24 | 25 | \item{break_long_names}{logical. If set, long pathway names are broken into 26 | two lines.} 27 | 28 | \item{return_data}{logical. If set, only the plotting data, but not the plot 29 | object itself is returned. This can be used to create customized plots 30 | that use the same data structure.} 31 | } 32 | \value{ 33 | A ggplot2 plot object representing the heatmap of pathways 34 | } 35 | \description{ 36 | Creates a heatmap to show which pathways are up- and down-regulated 37 | in different datasets 38 | } 39 | \examples{ 40 | # load an example result 41 | library(ReactomeGSA.data) 42 | data(griss_melanoma_result) 43 | 44 | # create the heatmap plot 45 | plot_obj <- plot_heatmap(griss_melanoma_result) 46 | 47 | # show the plot 48 | print(plot_obj) 49 | } 50 | \seealso{ 51 | Other ReactomeAnalysisResult functions: 52 | \code{\link{get_result}()}, 53 | \code{\link{names,ReactomeAnalysisResult-method}}, 54 | \code{\link{open_reactome}()}, 55 | \code{\link{pathways}()}, 56 | \code{\link{plot_correlations}()}, 57 | \code{\link{plot_gsva_heatmap}()}, 58 | \code{\link{plot_gsva_pathway}()}, 59 | \code{\link{plot_volcano}()}, 60 | \code{\link{reactome_links}()}, 61 | \code{\link{result_types}()} 62 | } 63 | \concept{ReactomeAnalysisResult functions} 64 | -------------------------------------------------------------------------------- /man/plot_volcano-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting_functions.R 3 | \name{plot_volcano,ReactomeAnalysisResult-method} 4 | \alias{plot_volcano,ReactomeAnalysisResult-method} 5 | \title{ReactomeAnalysisResult - plot_volcano} 6 | \usage{ 7 | \S4method{plot_volcano}{ReactomeAnalysisResult}(x, dataset = 1, ...) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult. The analysis result to plot the volcano plot for.} 11 | 12 | \item{dataset}{The name or index of the dataset to plot (first one by default).} 13 | 14 | \item{...}{Additional parameters for specific implementations.} 15 | } 16 | \value{ 17 | A ggplot2 plot object representing the volcano plot. 18 | } 19 | \description{ 20 | Creates a volcano plot for the pathway analysis result. Every point represents one 21 | pathway, the x-axis the log fold-change and the y-axis the adjusted p-value (-log10). 22 | } 23 | \details{ 24 | This function is only available for GSA-based analysis results. 25 | } 26 | \examples{ 27 | # load an example result 28 | library(ReactomeGSA.data) 29 | data(griss_melanoma_result) 30 | 31 | # create the volcano plot for the first dataset 32 | plot_obj <- plot_volcano(griss_melanoma_result) 33 | 34 | # display the plot using `print(plot_obj)` 35 | } 36 | \seealso{ 37 | Other ReactomeAnalysisResult functions: 38 | \code{\link{get_result}()}, 39 | \code{\link{names,ReactomeAnalysisResult-method}}, 40 | \code{\link{open_reactome}()}, 41 | \code{\link{pathways}()}, 42 | \code{\link{plot_correlations}()}, 43 | \code{\link{plot_gsva_heatmap}()}, 44 | \code{\link{plot_gsva_pathway}()}, 45 | \code{\link{plot_heatmap}()}, 46 | \code{\link{reactome_links}()}, 47 | \code{\link{result_types}()} 48 | } 49 | -------------------------------------------------------------------------------- /man/plot_volcano.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting_functions.R 3 | \name{plot_volcano} 4 | \alias{plot_volcano} 5 | \title{plot_volcano} 6 | \usage{ 7 | plot_volcano(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult. The analysis result to plot the volcano plot for.} 11 | 12 | \item{...}{Additional parameters for specific implementations.} 13 | } 14 | \value{ 15 | A ggplot2 plot object representing the volcano plot. 16 | } 17 | \description{ 18 | Creates a volcano plot for the pathway analysis result. Every point represents one 19 | pathway, the x-axis the log fold-change and the y-axis the adjusted p-value (-log10). 20 | } 21 | \details{ 22 | This function is only available for GSA-based analysis results. 23 | } 24 | \examples{ 25 | # load an example result 26 | library(ReactomeGSA.data) 27 | data(griss_melanoma_result) 28 | 29 | # create the volcano plot for the first dataset 30 | plot_obj <- plot_volcano(griss_melanoma_result) 31 | 32 | # display the plot using `print(plot_obj)` 33 | } 34 | \seealso{ 35 | Other ReactomeAnalysisResult functions: 36 | \code{\link{get_result}()}, 37 | \code{\link{names,ReactomeAnalysisResult-method}}, 38 | \code{\link{open_reactome}()}, 39 | \code{\link{pathways}()}, 40 | \code{\link{plot_correlations}()}, 41 | \code{\link{plot_gsva_heatmap}()}, 42 | \code{\link{plot_gsva_pathway}()}, 43 | \code{\link{plot_heatmap}()}, 44 | \code{\link{reactome_links}()}, 45 | \code{\link{result_types}()} 46 | } 47 | \concept{ReactomeAnalysisResult functions} 48 | -------------------------------------------------------------------------------- /man/print-ReactomeAnalysisRequest-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{print,ReactomeAnalysisRequest-method} 4 | \alias{print,ReactomeAnalysisRequest-method} 5 | \title{print - ReactomeAnalysisRequest} 6 | \usage{ 7 | \S4method{print}{ReactomeAnalysisRequest}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{\code{\link{ReactomeAnalysisRequest}}} 11 | 12 | \item{...}{Not used} 13 | } 14 | \value{ 15 | The classname of the object 16 | } 17 | \description{ 18 | Shows a \code{\link{ReactomeAnalysisRequest}} object summary. 19 | } 20 | \examples{ 21 | library(methods) 22 | 23 | request <- ReactomeAnalysisRequest(method = "Camera") 24 | print(request) 25 | 26 | # add additional parameters 27 | request <- set_parameters(request, "max_missing_values" = 0.5) 28 | show(request) 29 | } 30 | -------------------------------------------------------------------------------- /man/print-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{print,ReactomeAnalysisResult-method} 4 | \alias{print,ReactomeAnalysisResult-method} 5 | \title{print - ReactomeAnalysisResult} 6 | \usage{ 7 | \S4method{print}{ReactomeAnalysisResult}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | 12 | \item{...}{Not used} 13 | } 14 | \value{ 15 | character classname of the object 16 | } 17 | \description{ 18 | Displays basic information about the \code{\link{ReactomeAnalysisResult}} 19 | object. 20 | } 21 | \examples{ 22 | library(ReactomeGSA.data) 23 | data(griss_melanoma_result) 24 | 25 | print(griss_melanoma_result) 26 | } 27 | -------------------------------------------------------------------------------- /man/reactome_links-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{reactome_links,ReactomeAnalysisResult-method} 4 | \alias{reactome_links,ReactomeAnalysisResult-method} 5 | \title{ReactomeAnalysisResult - reactome_links} 6 | \usage{ 7 | \S4method{reactome_links}{ReactomeAnalysisResult}(x, print_result = TRUE, return_result = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | 12 | \item{print_result}{If set to \code{FALSE} the links are not printed to the console.} 13 | 14 | \item{return_result}{If \code{TRUE} the available visualizations are returned as a list containing 15 | named vectors for every visualization. These vectors' have a \code{url}, \code{name}, 16 | and optionally a \code{description} slot.} 17 | } 18 | \value{ 19 | If \code{return_result} is set to \code{TRUE}, a vector of the available visualizations. 20 | } 21 | \description{ 22 | Displays detailed information about the result visualizations in Reactome. 23 | } 24 | \examples{ 25 | # Note: This function only works with a newly created result 26 | # since the visualization links only stay active for 7 days 27 | 28 | # load an example result 29 | library(ReactomeGSA.data) 30 | data(griss_melanoma_result) 31 | 32 | # get the reactome link - this does only work 33 | # with new results 34 | reactome_links(griss_melanoma_result) 35 | } 36 | \seealso{ 37 | Other ReactomeAnalysisResult functions: 38 | \code{\link{get_result}()}, 39 | \code{\link{names,ReactomeAnalysisResult-method}}, 40 | \code{\link{open_reactome}()}, 41 | \code{\link{pathways}()}, 42 | \code{\link{plot_correlations}()}, 43 | \code{\link{plot_gsva_heatmap}()}, 44 | \code{\link{plot_gsva_pathway}()}, 45 | \code{\link{plot_heatmap}()}, 46 | \code{\link{plot_volcano}()}, 47 | \code{\link{result_types}()} 48 | } 49 | -------------------------------------------------------------------------------- /man/reactome_links.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{reactome_links} 4 | \alias{reactome_links} 5 | \title{reactome_links} 6 | \usage{ 7 | reactome_links(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | 12 | \item{...}{Additional parameters for specific implementations.} 13 | } 14 | \value{ 15 | If \code{return_result} is set to \code{TRUE}, a vector of the available visualizations. 16 | } 17 | \description{ 18 | Displays detailed information about the result visualizations in Reactome. 19 | } 20 | \examples{ 21 | # Note: This function only works with a newly created result 22 | # since the visualization links only stay active for 7 days 23 | 24 | # load an example result 25 | library(ReactomeGSA.data) 26 | data(griss_melanoma_result) 27 | 28 | # get the reactome link - this does only work 29 | # with new results 30 | reactome_links(griss_melanoma_result) 31 | } 32 | \seealso{ 33 | Other ReactomeAnalysisResult functions: 34 | \code{\link{get_result}()}, 35 | \code{\link{names,ReactomeAnalysisResult-method}}, 36 | \code{\link{open_reactome}()}, 37 | \code{\link{pathways}()}, 38 | \code{\link{plot_correlations}()}, 39 | \code{\link{plot_gsva_heatmap}()}, 40 | \code{\link{plot_gsva_pathway}()}, 41 | \code{\link{plot_heatmap}()}, 42 | \code{\link{plot_volcano}()}, 43 | \code{\link{result_types}()} 44 | } 45 | \concept{ReactomeAnalysisResult functions} 46 | -------------------------------------------------------------------------------- /man/remove_dataset-ReactomeAnalysisRequest-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{remove_dataset,ReactomeAnalysisRequest-method} 4 | \alias{remove_dataset,ReactomeAnalysisRequest-method} 5 | \title{remove_dataset - ReactomeAnalysisRequest} 6 | \usage{ 7 | \S4method{remove_dataset}{ReactomeAnalysisRequest}(x, dataset_name) 8 | } 9 | \arguments{ 10 | \item{x}{The \code{\link{ReactomeAnalysisRequest}} to remove the dataset from} 11 | 12 | \item{dataset_name}{character The dataset's name} 13 | } 14 | \value{ 15 | The updated \code{\link{ReactomeAnalysisRequest}} 16 | } 17 | \description{ 18 | Remove the dataset from the \code{\link{ReactomeAnalysisRequest}} object. 19 | } 20 | -------------------------------------------------------------------------------- /man/remove_dataset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{remove_dataset} 4 | \alias{remove_dataset} 5 | \title{remove_dataset} 6 | \usage{ 7 | remove_dataset(x, dataset_name) 8 | } 9 | \arguments{ 10 | \item{x}{The \code{\link{ReactomeAnalysisRequest}} to remove the dataset from} 11 | 12 | \item{dataset_name}{character The dataset's name} 13 | } 14 | \value{ 15 | The updated \code{\link{ReactomeAnalysisRequest}} 16 | } 17 | \description{ 18 | Remove the dataset from the \code{\link{ReactomeAnalysisRequest}} object. 19 | } 20 | -------------------------------------------------------------------------------- /man/result_types-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{result_types,ReactomeAnalysisResult-method} 4 | \alias{result_types,ReactomeAnalysisResult-method} 5 | \title{ReactomeAnalysisResult - result_types} 6 | \usage{ 7 | \S4method{result_types}{ReactomeAnalysisResult}(x) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | } 12 | \value{ 13 | A cacharacter vector of result types. 14 | } 15 | \description{ 16 | Retrieves the available result types for the \code{\link{ReactomeAnalysisResult}} object. Currently, 17 | the Reactome Analysis System supports \code{pathways} and gene level \code{fold_changes} 18 | as result types. Not all analysis methods return both data types though. 19 | Use the \code{names} function to find out which datasets are available 20 | in the result object. 21 | } 22 | \examples{ 23 | # load an example result object 24 | library(ReactomeGSA.data) 25 | data(griss_melanoma_result) 26 | 27 | # get the available result types 28 | result_types(griss_melanoma_result) 29 | } 30 | \seealso{ 31 | Other ReactomeAnalysisResult functions: 32 | \code{\link{get_result}()}, 33 | \code{\link{names,ReactomeAnalysisResult-method}}, 34 | \code{\link{open_reactome}()}, 35 | \code{\link{pathways}()}, 36 | \code{\link{plot_correlations}()}, 37 | \code{\link{plot_gsva_heatmap}()}, 38 | \code{\link{plot_gsva_pathway}()}, 39 | \code{\link{plot_heatmap}()}, 40 | \code{\link{plot_volcano}()}, 41 | \code{\link{reactome_links}()} 42 | } 43 | -------------------------------------------------------------------------------- /man/result_types.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{result_types} 4 | \alias{result_types} 5 | \title{result_types} 6 | \usage{ 7 | result_types(x) 8 | } 9 | \arguments{ 10 | \item{x}{ReactomeAnalysisResult.} 11 | } 12 | \value{ 13 | A cacharacter vector of result types. 14 | } 15 | \description{ 16 | Retrieves the available result types for the \code{\link{ReactomeAnalysisResult}} object. Currently, 17 | the Reactome Analysis System supports \code{pathways} and gene level \code{fold_changes} 18 | as result types. Not all analysis methods return both data types though. 19 | Use the \code{names} function to find out which datasets are available 20 | in the result object. 21 | } 22 | \examples{ 23 | # load an example result object 24 | library(ReactomeGSA.data) 25 | data(griss_melanoma_result) 26 | 27 | # get the available result types 28 | result_types(griss_melanoma_result) 29 | } 30 | \seealso{ 31 | Other ReactomeAnalysisResult functions: 32 | \code{\link{get_result}()}, 33 | \code{\link{names,ReactomeAnalysisResult-method}}, 34 | \code{\link{open_reactome}()}, 35 | \code{\link{pathways}()}, 36 | \code{\link{plot_correlations}()}, 37 | \code{\link{plot_gsva_heatmap}()}, 38 | \code{\link{plot_gsva_pathway}()}, 39 | \code{\link{plot_heatmap}()}, 40 | \code{\link{plot_volcano}()}, 41 | \code{\link{reactome_links}()} 42 | } 43 | \concept{ReactomeAnalysisResult functions} 44 | -------------------------------------------------------------------------------- /man/set_method-ReactomeAnalysisRequest-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{set_method,ReactomeAnalysisRequest-method} 4 | \alias{set_method,ReactomeAnalysisRequest-method} 5 | \title{set_method - ReactomeAnalysisRequest} 6 | \usage{ 7 | \S4method{set_method}{ReactomeAnalysisRequest}(request, method, ...) 8 | } 9 | \arguments{ 10 | \item{request}{The \code{\link{ReactomeAnalysisRequest}} to adjust} 11 | 12 | \item{method}{The name of the method to use. Use \code{\link{get_reactome_methods}} to 13 | retrieve all available methods} 14 | 15 | \item{...}{Additional parameters passed to specific implementations} 16 | } 17 | \value{ 18 | The \code{\link{ReactomeAnalysisRequest}} with the adapted method 19 | } 20 | \description{ 21 | Set the analysis method used by the \code{\link{ReactomeAnalysisRequest}} 22 | } 23 | \examples{ 24 | # create a request using Camera as an analysis 25 | data(griss_melanoma_proteomics) 26 | library(methods) 27 | 28 | my_request <- ReactomeAnalysisRequest(method = "Camera") 29 | 30 | print(my_request) 31 | 32 | # change the method to ssGSEA 33 | my_request <- set_method(my_request, "ssGSEA") 34 | 35 | print(my_request) 36 | } 37 | -------------------------------------------------------------------------------- /man/set_method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{set_method} 4 | \alias{set_method} 5 | \title{set_method} 6 | \usage{ 7 | set_method(request, method, ...) 8 | } 9 | \arguments{ 10 | \item{request}{The \code{\link{ReactomeAnalysisRequest}} to adjust} 11 | 12 | \item{method}{The name of the method to use. Use \code{\link{get_reactome_methods}} to 13 | retrieve all available methods} 14 | 15 | \item{...}{Additional parameters passed to specific implementations} 16 | } 17 | \value{ 18 | The \code{\link{ReactomeAnalysisRequest}} with the adapted method 19 | } 20 | \description{ 21 | Set the analysis method used by the \code{\link{ReactomeAnalysisRequest}} 22 | } 23 | \examples{ 24 | # create a request using Camera as an analysis 25 | data(griss_melanoma_proteomics) 26 | library(methods) 27 | 28 | my_request <- ReactomeAnalysisRequest(method = "Camera") 29 | 30 | print(my_request) 31 | 32 | # change the method to ssGSEA 33 | my_request <- set_method(my_request, "ssGSEA") 34 | 35 | print(my_request) 36 | } 37 | -------------------------------------------------------------------------------- /man/set_parameters-ReactomeAnalysisRequest-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{set_parameters,ReactomeAnalysisRequest-method} 4 | \alias{set_parameters,ReactomeAnalysisRequest-method} 5 | \title{ReactomeAnalysisRequest - set_parameters} 6 | \usage{ 7 | \S4method{set_parameters}{ReactomeAnalysisRequest}(request, ...) 8 | } 9 | \arguments{ 10 | \item{request}{The \code{\link{ReactomeAnalysisRequest}} to set the parameters for.} 11 | 12 | \item{...}{Any name / value pair to set a parameter (see example). For a complete list of 13 | available parameters use \code{\link{get_reactome_methods}}} 14 | } 15 | \value{ 16 | The modified \code{\link{ReactomeAnalysisRequest}} object 17 | } 18 | \description{ 19 | Sets the analysis parameters for the given \code{\link{ReactomeAnalysisRequest}}. If the 20 | parameter is already set, it is overwritten. Use \code{\link{get_reactome_methods}} 21 | to get a list of all available parameters for each available method. 22 | } 23 | \details{ 24 | Both, parameters with the scope "dataset" as well as "analysis" can be set on the analysis 25 | level. In this case, these parameters overwrite the system's default values. If a parameter 26 | with the scope "dataset" is defined again at the dataset level, this value will overwrite 27 | the analysis' scope value for the given dataset. 28 | } 29 | \examples{ 30 | library(methods) 31 | 32 | # create a request object 33 | request <- ReactomeAnalysisRequest(method = "Camera") 34 | 35 | # add a parameter 36 | request <- set_parameters(request, max_missing_values = 0.5, discrete_norm_function = "TMM") 37 | } 38 | -------------------------------------------------------------------------------- /man/set_parameters.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{set_parameters} 4 | \alias{set_parameters} 5 | \title{set_parameters} 6 | \usage{ 7 | set_parameters(request, ...) 8 | } 9 | \arguments{ 10 | \item{request}{The \code{\link{ReactomeAnalysisRequest}} to set the parameters for.} 11 | 12 | \item{...}{Any name / value pair to set a parameter (see example). For a complete list of 13 | available parameters use \code{\link{get_reactome_methods}}} 14 | } 15 | \value{ 16 | The modified \code{\link{ReactomeAnalysisRequest}} object 17 | } 18 | \description{ 19 | Sets the analysis parameters for the given \code{\link{ReactomeAnalysisRequest}}. If the 20 | parameter is already set, it is overwritten. Use \code{\link{get_reactome_methods}} 21 | to get a list of all available parameters for each available method. 22 | } 23 | \details{ 24 | Both, parameters with the scope "dataset" as well as "analysis" can be set on the analysis 25 | level. In this case, these parameters overwrite the system's default values. If a parameter 26 | with the scope "dataset" is defined again at the dataset level, this value will overwrite 27 | the analysis' scope value for the given dataset. 28 | } 29 | \examples{ 30 | library(methods) 31 | 32 | # create a request object 33 | request <- ReactomeAnalysisRequest(method = "Camera") 34 | 35 | # add a parameter 36 | request <- set_parameters(request, max_missing_values = 0.5, discrete_norm_function = "TMM") 37 | } 38 | -------------------------------------------------------------------------------- /man/show-ReactomeAnalysisRequest-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_request.R 3 | \name{show,ReactomeAnalysisRequest-method} 4 | \alias{show,ReactomeAnalysisRequest-method} 5 | \title{print - ReactomeAnalysisRequest} 6 | \usage{ 7 | \S4method{show}{ReactomeAnalysisRequest}(object) 8 | } 9 | \arguments{ 10 | \item{object}{\code{\link{ReactomeAnalysisRequest}}} 11 | } 12 | \value{ 13 | The classname of the object 14 | } 15 | \description{ 16 | Shows a \code{\link{ReactomeAnalysisRequest}} object summary. 17 | } 18 | \examples{ 19 | library(methods) 20 | 21 | request <- ReactomeAnalysisRequest(method = "Camera") 22 | print(request) 23 | 24 | # add additional parameters 25 | request <- set_parameters(request, "max_missing_values" = 0.5) 26 | show(request) 27 | } 28 | -------------------------------------------------------------------------------- /man/show-ReactomeAnalysisResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/analysis_result.R 3 | \name{show,ReactomeAnalysisResult-method} 4 | \alias{show,ReactomeAnalysisResult-method} 5 | \title{show - ReactomeAnalysisResult} 6 | \usage{ 7 | \S4method{show}{ReactomeAnalysisResult}(object) 8 | } 9 | \arguments{ 10 | \item{object}{ReactomeAnalysisResult.} 11 | } 12 | \value{ 13 | character classname of the object 14 | } 15 | \description{ 16 | Displays basic information about the \code{\link{ReactomeAnalysisResult}} 17 | object. 18 | } 19 | \examples{ 20 | library(ReactomeGSA.data) 21 | data(griss_melanoma_result) 22 | 23 | show(griss_melanoma_result) 24 | } 25 | -------------------------------------------------------------------------------- /man/split_clustering.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_pseudo_bulk_data.R 3 | \name{split_clustering} 4 | \alias{split_clustering} 5 | \title{method implementation subclustering} 6 | \usage{ 7 | split_clustering(seurat_object, group_by, res, alg, cluster1, cluster2) 8 | } 9 | \arguments{ 10 | \item{seurat_object}{The Seurat object to analyse.} 11 | 12 | \item{group_by}{entry in metadata table, based on these cluster annotation pseudo bulk is performed} 13 | 14 | \item{res}{The clustering resolution to use.} 15 | 16 | \item{alg}{Seurat subclustering algorithm id} 17 | 18 | \item{cluster1}{cluster to subcluster} 19 | 20 | \item{cluster2}{cluster to subcluster} 21 | } 22 | \value{ 23 | returns pseudo bulk generated data 24 | } 25 | \description{ 26 | method implementation subclustering 27 | } 28 | -------------------------------------------------------------------------------- /man/split_random_sce.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_pseudo_bulk_data.R 3 | \name{split_random_sce} 4 | \alias{split_random_sce} 5 | \title{split SCE Object with random pooling} 6 | \usage{ 7 | split_random_sce(sce_object, group_by, k_variable) 8 | } 9 | \arguments{ 10 | \item{sce_object}{The SingleCellExperiment object to analyse.} 11 | 12 | \item{group_by}{entry in metadata table, based on these cluster annotation pseudo bulk is performed} 13 | 14 | \item{k_variable}{number of pools that should be created} 15 | } 16 | \value{ 17 | returns pseudo bulk generated data 18 | } 19 | \description{ 20 | split SCE Object with random pooling 21 | } 22 | -------------------------------------------------------------------------------- /man/split_subclustering_sce.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_pseudo_bulk_data.R 3 | \name{split_subclustering_sce} 4 | \alias{split_subclustering_sce} 5 | \title{split SCE Object with random pooling} 6 | \usage{ 7 | split_subclustering_sce( 8 | sce_object, 9 | group_by, 10 | resolution, 11 | subcluster_ref, 12 | subcluster_comp 13 | ) 14 | } 15 | \arguments{ 16 | \item{sce_object}{The SingleCellExperiment object to analyse.} 17 | 18 | \item{group_by}{entry in metadata table, based on these 19 | cluster annotation pseudo bulk is performed} 20 | 21 | \item{resolution}{resolution} 22 | 23 | \item{subcluster_ref}{cluster to subcluster as areference} 24 | 25 | \item{subcluster_comp}{cluster to subcluster for comparison} 26 | } 27 | \value{ 28 | returns pseudo bulk generated data 29 | } 30 | \description{ 31 | split SCE Object with random pooling 32 | } 33 | -------------------------------------------------------------------------------- /man/split_variable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_pseudo_bulk_data.R 3 | \name{split_variable} 4 | \alias{split_variable} 5 | \title{split Seurat object by variable} 6 | \usage{ 7 | split_variable(seurat_object, group_by, k_variable) 8 | } 9 | \arguments{ 10 | \item{seurat_object}{The Seurat object to analyse.} 11 | 12 | \item{group_by}{entry in metadata table, based on these cluster annotation pseudo bulk is performed} 13 | 14 | \item{k_variable}{variable dependent on the split_by -> meta data entry} 15 | } 16 | \value{ 17 | returns pseudo bulk generated data 18 | } 19 | \description{ 20 | split Seurat object by variable 21 | } 22 | -------------------------------------------------------------------------------- /man/split_variable_random.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_pseudo_bulk_data.R 3 | \name{split_variable_random} 4 | \alias{split_variable_random} 5 | \title{split Seurat object by random pooling} 6 | \usage{ 7 | split_variable_random(seurat_object, group_by, k_variable) 8 | } 9 | \arguments{ 10 | \item{seurat_object}{The Seurat object to analyse.} 11 | 12 | \item{group_by}{entry in metadata table, based on these cluster annotation pseudo bulk is performed} 13 | 14 | \item{k_variable}{number of random pools} 15 | } 16 | \value{ 17 | returns pseudo bulk generated data 18 | } 19 | \description{ 20 | split Seurat object by random pooling 21 | } 22 | -------------------------------------------------------------------------------- /man/split_variable_sce.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generate_pseudo_bulk_data.R 3 | \name{split_variable_sce} 4 | \alias{split_variable_sce} 5 | \title{split SCE Object by variable} 6 | \usage{ 7 | split_variable_sce(sce_object, group_by, k_variable) 8 | } 9 | \arguments{ 10 | \item{sce_object}{The SingleCellExperiment object to analyse.} 11 | 12 | \item{group_by}{entry in metadata table, based on these cluster annotation pseudo bulk is performed} 13 | 14 | \item{k_variable}{variable for sub setting must be in the metadata} 15 | } 16 | \value{ 17 | returns pseudo bulk generated data 18 | } 19 | \description{ 20 | split SCE Object by variable 21 | } 22 | -------------------------------------------------------------------------------- /man/start_reactome_analysis.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/send_request.R 3 | \name{start_reactome_analysis} 4 | \alias{start_reactome_analysis} 5 | \title{Start Reactome Analysis} 6 | \usage{ 7 | start_reactome_analysis(request, compress = TRUE, reactome_url = NULL) 8 | } 9 | \arguments{ 10 | \item{request}{\code{\link{ReactomeAnalysisRequest}} object to submit.} 11 | 12 | \item{compress}{If set (default) the JSON request data is compressed using gzip.} 13 | 14 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 15 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 16 | } 17 | \value{ 18 | character The analysis job's id. 19 | 20 | #' @examples 21 | # create a request using Camera as an analysis 22 | library(ReactomeGSA.data) 23 | data(griss_melanoma_proteomics) 24 | 25 | my_request <- ReactomeAnalysisRequest(method = "Camera") 26 | 27 | # set maximum missing values to 0.5 and do not create any reactome visualizations 28 | my_request <- set_parameters(request = my_request, 29 | max_missing_values = 0.5, 30 | create_reactome_visualization = FALSE) 31 | 32 | # add the dataset 33 | my_request <- add_dataset(request = my_request, 34 | expression_values = griss_melanoma_proteomics, 35 | name = "Proteomics", 36 | type = "proteomics_int", 37 | comparison_factor = "condition", 38 | comparison_group_1 = "MOCK", 39 | comparison_group_2 = "MCM", 40 | additional_factors = c("cell.type", "patient.id")) 41 | # start the analysis 42 | analysis_id <- start_reactome_analysis(my_request) 43 | } 44 | \description{ 45 | Submits a \code{\link{ReactomeAnalysisRequest}} to the Reactome Analysis Service API and 46 | returns the analysis id of the submitted job. 47 | } 48 | \details{ 49 | This function should only be used for very large requests that likely take a long time to complete. 50 | By default, users should use the \code{\link{perform_reactome_analysis}} function to run an analysis. 51 | } 52 | -------------------------------------------------------------------------------- /man/wait_for_loading_dataset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/public_data.R 3 | \name{wait_for_loading_dataset} 4 | \alias{wait_for_loading_dataset} 5 | \title{wait_for_loading_dataset} 6 | \usage{ 7 | wait_for_loading_dataset(request, verbose, reactome_url) 8 | } 9 | \arguments{ 10 | \item{request}{The httr request object of the dataset loading request.} 11 | 12 | \item{verbose}{If set to \code{TRUE}, the progress is displayed as a status bar.} 13 | 14 | \item{reactome_url}{URL of the Reactome API Server. Overwrites the URL set in the 'reactome_gsa.url' option. 15 | Specific ports can be set using the standard URL specification (for example http://your.service:1234)} 16 | } 17 | \description{ 18 | This function loops until the dataset is available. If 19 | verbose is set to \code{TRUE}, the progress is displayed 20 | in a status bar. 21 | } 22 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(ReactomeGSA) 3 | 4 | test_check("ReactomeGSA") 5 | -------------------------------------------------------------------------------- /tests/testthat/test_analysis_request.R: -------------------------------------------------------------------------------- 1 | context("ReactomeAnalysisRequest functions") 2 | library(ReactomeGSA) 3 | 4 | test_that("Request method is set by the constructor", { 5 | request_obj <- new("ReactomeAnalysisRequest", method = "Camera") 6 | expect_equal(request_obj@method, "Camera") 7 | 8 | request_obj <- new("ReactomeAnalysisRequest", method = "ssGSEA") 9 | expect_equal(request_obj@method, "ssGSEA") 10 | 11 | # invalid methods possible as well 12 | request_obj <- new("ReactomeAnalysisRequest", method = "asda") 13 | expect_equal(request_obj@method, "asda") 14 | 15 | # make sure the method is changed 16 | request_obj <- set_method(request_obj, method = "osda") 17 | expect_equal(request_obj@method, "osda") 18 | }) 19 | 20 | test_that("Set parameters changes parameters", { 21 | request_obj <- new("ReactomeAnalysisRequest", method = "Camera") 22 | 23 | # parameters are missing 24 | expect_equal("parameters" %in% names(request_obj@request_object), FALSE) 25 | 26 | # setting a parameter creates the parameters object 27 | request_obj <- set_parameters(request_obj, min_missing_values = 0.01) 28 | 29 | expect_equal("parameters" %in% names(request_obj@request_object), TRUE) 30 | expect_equal(nrow(request_obj@request_object[["parameters"]]), 1) 31 | 32 | request_obj <- set_parameters(request_obj, create_reactome_visualization = FALSE) 33 | expect_equal(nrow(request_obj@request_object[["parameters"]]), 2) 34 | # bool converted to string 35 | expect_equal(request_obj@request_object[["parameters"]][2, "value"], "FALSE") 36 | }) 37 | 38 | test_that("remove_dataset removes datasets", { 39 | request_obj <- new("ReactomeAnalysisRequest", method = "Camera") 40 | 41 | # create test data 42 | test_expr <- data.frame( 43 | sample.1 = c(1,2,3,4), 44 | sample.2 = c(1,2,3,4), 45 | sample.3 = c(1,2,3,4), 46 | row.names = c("CD19", "MS4A1", "MITF", "SDC1") 47 | ) 48 | 49 | sample_data <- data.frame( 50 | treatment = c("Control", "Treatment", "Control"), 51 | lab = c("L1", "L1", "L2"), 52 | row.names = paste0("sample.", 1:3) 53 | ) 54 | 55 | request_obj <- add_dataset(request_obj, expression_values = test_expr, name = "Test 1", type = "rnaseq_counts", 56 | comparison_factor = "treatment", comparison_group_1 = "Control", comparison_group_2 = "Treatment", 57 | sample_data = sample_data) 58 | 59 | expect_equal("datasets" %in% names(request_obj@request_object), TRUE) 60 | expect_equal(nrow(request_obj@request_object[["datasets"]]), 1) 61 | 62 | # remove the dataset again 63 | request_obj <- remove_dataset(request_obj, "Test 1") 64 | 65 | expect_equal(nrow(request_obj@request_object[["datasets"]]), 0) 66 | }) 67 | 68 | test_that("add_dataset adds different datasets", { 69 | request_obj <- new("ReactomeAnalysisRequest", method = "Camera") 70 | expect_equal("datasets" %in% names(request_obj@request_object), FALSE) 71 | 72 | # create test data 73 | test_expr <- data.frame( 74 | sample.1 = c(1,2,3,4), 75 | sample.2 = c(1,2,3,4), 76 | sample.3 = c(1,2,3,4), 77 | row.names = c("CD19", "MS4A1", "MITF", "SDC1") 78 | ) 79 | 80 | sample_data <- data.frame( 81 | treatment = c("Control", "Treatment", "Control"), 82 | lab = c("L1", "L1", "L2"), 83 | row.names = paste0("sample.", 1:3) 84 | ) 85 | 86 | request_obj <- add_dataset(request_obj, expression_values = test_expr, name = "Test 1", type = "rnaseq_counts", 87 | comparison_factor = "treatment", comparison_group_1 = "Control", comparison_group_2 = "Treatment", 88 | sample_data = sample_data) 89 | 90 | expect_equal("datasets" %in% names(request_obj@request_object), TRUE) 91 | expect_equal(nrow(request_obj@request_object[["datasets"]]), 1) 92 | 93 | # add a second dataset 94 | request_obj <- add_dataset(request_obj, expression_values = test_expr, name = "Test 2", type = "rnaseq_counts", 95 | comparison_factor = "treatment", comparison_group_1 = "Control", comparison_group_2 = "Treatment", 96 | sample_data = sample_data) 97 | 98 | expect_equal(nrow(request_obj@request_object[["datasets"]]), 2) 99 | 100 | # overwrite the second dataset 101 | request_obj <- add_dataset(request_obj, expression_values = test_expr, name = "Test 2", type = "rnaseq_counts", 102 | comparison_factor = "treatment", comparison_group_1 = "Control", comparison_group_2 = "Treatment", 103 | sample_data = sample_data, overwrite = TRUE) 104 | 105 | expect_equal(nrow(request_obj@request_object[["datasets"]]), 2) 106 | }) 107 | -------------------------------------------------------------------------------- /vignettes/analysing-scRNAseq.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Analysing single-cell RNA-sequencing Data" 3 | author: "Johannes Griss" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Analysing single-cell RNAseq data} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r setup, include = FALSE} 13 | knitr::opts_chunk$set( 14 | collapse = TRUE, 15 | comment = "#>" 16 | ) 17 | ``` 18 | 19 | ## Introduction 20 | 21 | 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. 22 | 23 | This vignette shows how the ReactomeGSA package can be used to perform a pathway analysis of cell clusters in single-cell RNA-sequencing data. 24 | 25 | ### Citation 26 | 27 | To cite this package, use 28 | 29 | ``` 30 | Griss J. ReactomeGSA, https://github.com/reactome/ReactomeGSA (2019) 31 | ``` 32 | 33 | ## Installation 34 | 35 | The `ReactomeGSA` package can be directly installed from Bioconductor: 36 | 37 | ```{r, eval=FALSE} 38 | if (!requireNamespace("BiocManager", quietly = TRUE)) 39 | install.packages("BiocManager") 40 | 41 | if (!require(ReactomeGSA)) 42 | BiocManager::install("ReactomeGSA") 43 | 44 | # install the ReactomeGSA.data package for the example data 45 | if (!require(ReactomeGSA.data)) 46 | BiocManager::install("ReactomeGSA.data") 47 | ``` 48 | 49 | For more information, see https://bioconductor.org/install/. 50 | 51 | ## Example data 52 | 53 | 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). 54 | 55 | **Note**: This is not a complete Seurat object. To decrease the size, the object only contains gene expression values and cluster annotations. 56 | 57 | ```{r} 58 | library(ReactomeGSA.data) 59 | data(jerby_b_cells) 60 | 61 | jerby_b_cells 62 | ``` 63 | 64 | ## Types of analyses 65 | 66 | There are two methods to analyse scRNA-seq data using ReactomeGSA: 67 | 68 | ReactomeGSA can generate pseudo-bulk data from scRNA-seq 69 | data and then analyse this data using the classical quantitative pathway 70 | analysis algorithms. Thereby, it is possible to directly compare, f.e. 71 | two cell types with each other or two treatment approaches. 72 | The result is a classical pathway analysis result with 73 | p-values and fold-changes attributed to each pathway. 74 | 75 | The `analyse_sc_clusters` function offers a second approach using 76 | the gene set variation algorithm `ssGSEA` to derive pathway-level 77 | quantitative values for each cluster or cell type in the dataset. 78 | This is helpful to visualize the "expression level" of pathways 79 | accross the dataset. Statistical analyses have to be performed separately. 80 | 81 | ## Comparative pathway analysis (pseudo-bulk approach) 82 | 83 | The pathway analysis is at the very end of a scRNA-seq workflow. This means, 84 | that any Q/C was already performed, the data was normalized and cells were already clustered. 85 | 86 | In this example we are going to compare `Cluster 1` against `Cluster 2`. 87 | 88 | ```{r} 89 | # store the Idents as a meta.data field - this was 90 | # removed while compressing the object as an example 91 | jerby_b_cells$clusters <- Idents(jerby_b_cells) 92 | 93 | table(jerby_b_cells$clusters) 94 | ``` 95 | 96 | As a next step, we need to create the pseudo-bulk data for the analysis. This 97 | is achieved through the `generate_pseudo_bulk_data` function. 98 | 99 | ```{R} 100 | library(ReactomeGSA) 101 | 102 | # This creates a pseudo-bulk object by splitting each cluster in 4 103 | # random bulks of data. This approach can be changed through the 104 | # split_by and k_variable parameter. 105 | pseudo_bulk_data <- generate_pseudo_bulk_data(jerby_b_cells, group_by = "clusters") 106 | 107 | # we can immediately create the metadata data.frame for this data 108 | pseudo_metadata <- generate_metadata(pseudo_bulk_data) 109 | ``` 110 | 111 | This pseudo-bulk data is directly compatible with the existing algorithms 112 | for quantitative pathway analysis and can be processed using the respective 113 | ReactomeGSA methods. 114 | 115 | ```{r} 116 | # Create a new request object using 'Camera' for the gene set analysis 117 | my_request <- ReactomeAnalysisRequest(method = "Camera") 118 | 119 | # set the maximum number of allowed missing values to 50% 120 | my_request <- set_parameters(request = my_request, max_missing_values = 0.5) 121 | 122 | # add the pseudo-bulk data as a dataset 123 | my_request <- add_dataset(request = my_request, 124 | expression_values = pseudo_bulk_data, 125 | sample_data = pseudo_metadata, 126 | name = "Pseudo-bulk", 127 | type = "rnaseq_counts", 128 | comparison_factor = "Group", 129 | comparison_group_1 = "Cluster 1", 130 | comparison_group_2 = "Cluster 2") 131 | 132 | my_request 133 | ``` 134 | 135 | This request object can be directly submitted to the ReactomeGSA analysis. 136 | 137 | ```{r} 138 | quant_result <- perform_reactome_analysis(my_request, compress = FALSE) 139 | quant_result 140 | ``` 141 | 142 | This object can be used in the same fashion as any ReactomeGSA result object. 143 | 144 | ```{r} 145 | # get the pathway-level results 146 | quant_pathways <- pathways(quant_result) 147 | head(quant_pathways) 148 | ``` 149 | 150 | ```{r} 151 | # get the top pathways to label them 152 | library(tidyr) 153 | library(dplyr) 154 | 155 | top_pathways <- quant_pathways %>% 156 | tibble::rownames_to_column(var = "Id") %>% 157 | filter(`FDR.Pseudo-bulk` < 0.001) %>% 158 | arrange(desc(`av_foldchange.Pseudo-bulk`)) 159 | 160 | # limit to a few pathway for aesthetic reasons 161 | top_pathways <- top_pathways[c(1,5,6), ] 162 | 163 | # create a simple volcano plot of the pathway results 164 | library(ggplot2) 165 | ggplot(quant_pathways, 166 | aes(x = `av_foldchange.Pseudo-bulk`, 167 | y = -log10(`FDR.Pseudo-bulk`))) + 168 | geom_vline(xintercept = c(log2(0.5), log2(2)), colour="grey", linetype = "longdash") + 169 | geom_hline(yintercept = -log10(0.05), colour="grey", linetype = "longdash") + 170 | geom_point() + 171 | geom_label(data = top_pathways, aes(label = Name), nudge_y = 1, check_overlap = TRUE) 172 | ``` 173 | 174 | ## Pathway analysis of cell clusters (analyse_sc_clusters) 175 | 176 | 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. 177 | 178 | All of this is wrapped in the single `analyse_sc_clusters` function. 179 | 180 | ```{R} 181 | gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = TRUE) 182 | ``` 183 | 184 | The resulting object is a standard `ReactomeAnalysisResult` object. 185 | 186 | ```{r} 187 | gsva_result 188 | ``` 189 | 190 | `pathways` returns the pathway-level expression values per cell cluster: 191 | 192 | ```{r} 193 | pathway_expression <- pathways(gsva_result) 194 | 195 | # simplify the column names by removing the default dataset identifier 196 | colnames(pathway_expression) <- gsub("\\.Seurat", "", colnames(pathway_expression)) 197 | 198 | pathway_expression[1:3,] 199 | ``` 200 | 201 | A simple approach to find the most relevant pathways is to assess the maximum difference in expression for every pathway: 202 | 203 | ```{r} 204 | # find the maximum differently expressed pathway 205 | max_difference <- do.call(rbind, apply(pathway_expression, 1, function(row) { 206 | values <- as.numeric(row[2:length(row)]) 207 | return(data.frame(name = row[1], min = min(values), max = max(values))) 208 | })) 209 | 210 | max_difference$diff <- max_difference$max - max_difference$min 211 | 212 | # sort based on the difference 213 | max_difference <- max_difference[order(max_difference$diff, decreasing = T), ] 214 | 215 | head(max_difference) 216 | ``` 217 | 218 | ### Plotting the results 219 | 220 | The ReactomeGSA package contains two functions to visualize these pathway results. The first simply plots the expression for a selected pathway: 221 | 222 | ```{r, fig.width=7, fig.height=4} 223 | plot_gsva_pathway(gsva_result, pathway_id = rownames(max_difference)[1]) 224 | ``` 225 | 226 | For a better overview, the expression of multiple pathways can be shown as a heatmap using `gplots` `heatmap.2` function: 227 | 228 | ```{r, fig.width=7, fig.height=8} 229 | # Additional parameters are directly passed to gplots heatmap.2 function 230 | plot_gsva_heatmap(gsva_result, max_pathways = 15, margins = c(6,20)) 231 | ``` 232 | 233 | The `plot_gsva_heatmap` function can also be used to only display specific pahtways: 234 | ```{r, fig.width=7, fig.height=4} 235 | # limit to selected B cell related pathways 236 | relevant_pathways <- c("R-HSA-983170", "R-HSA-388841", "R-HSA-2132295", "R-HSA-983705", "R-HSA-5690714") 237 | plot_gsva_heatmap(gsva_result, 238 | pathway_ids = relevant_pathways, # limit to these pathways 239 | margins = c(6,30), # adapt the figure margins in heatmap.2 240 | dendrogram = "col", # only plot column dendrogram 241 | scale = "row", # scale for each pathway 242 | key = FALSE, # don't display the color key 243 | lwid=c(0.1,4)) # remove the white space on the left 244 | ``` 245 | 246 | 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. 247 | 248 | Therefore, we are able to further classify the observed B cell subtypes based on their pathway activity. 249 | 250 | ### Pathway-level PCA 251 | 252 | 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`: 253 | 254 | ```{r, fig.width=6, fig.height=4} 255 | plot_gsva_pca(gsva_result) 256 | ``` 257 | 258 | In this analysis, cluster 11 is a clear outlier from the other B cell subtypes and therefore might be prioritised for further evaluation. 259 | 260 | ## Session Info 261 | 262 | ```{r} 263 | sessionInfo() 264 | ``` -------------------------------------------------------------------------------- /vignettes/reanalysing-public-data.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Loading and re-analysing public data through ReactomeGSA" 3 | author: "Johannes Griss" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Loading and re-analysing public data through ReactomeGSA} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r setup, include = FALSE} 13 | knitr::opts_chunk$set( 14 | collapse = TRUE, 15 | comment = "#>" 16 | ) 17 | ``` 18 | 19 | ## Introduction 20 | 21 | Since October 2023, ReactomeGSA was extended to simplify the reuse of public data. As key features, 22 | ReactomeGSA can now directly load data from **EBI's ExpressionAtlas**, and **NCBI's GREIN**. Both of 23 | these resources reprocess available public datasets using consistent pipelines. 24 | 25 | Additionally, a search function was integrated into ReactomeGSA that can search for datasets simultaneously 26 | in all of these supported resources. 27 | 28 | The ReactomeGSA R package now also has all required functions to directly access this web-based service. It 29 | is thereby possible to search for public datasets directly and download them as **ExpressionSet** objects. 30 | 31 | ## Installation 32 | 33 | The `ReactomeGSA` package can be directly installed from Bioconductor: 34 | 35 | ```{r, eval=FALSE } 36 | if (!requireNamespace("BiocManager", quietly = TRUE)) 37 | install.packages("BiocManager") 38 | 39 | if (!require(ReactomeGSA)) 40 | BiocManager::install("ReactomeGSA") 41 | ``` 42 | 43 | For more information, see https://bioconductor.org/install/. 44 | 45 | ## Searching for Public Datasets 46 | 47 | The `find_public_datasets` function uses ReactomeGSA's web service to search for public datasets 48 | in all supported resources. 49 | 50 | By default, the datasets are limited to human studies. This can be changed by setting the `species` 51 | parameter. The complete list of available species is returned by the `get_public_species` function. 52 | 53 | ```{r} 54 | library(ReactomeGSA) 55 | 56 | # get all available species found in the datasets 57 | all_species <- get_public_species() 58 | 59 | head(all_species) 60 | ``` 61 | 62 | The `search_term` parameter takes a single string as an argument. Words separated by a space are 63 | logically combined using an **AND**. 64 | 65 | ```{r} 66 | # search for datasets on BRAF and melanoma 67 | datasets <- find_public_datasets("melanoma BRAF") 68 | 69 | # the function returns the found datasets as a data.frame 70 | datasets[1:4, c("id", "title")] 71 | ``` 72 | 73 | ## Load a public dataset 74 | 75 | Datasets found through the `find_public_datasets` function can subsequently 76 | loaded using the `load_public_dataset` function. 77 | 78 | ```{r} 79 | # find the correct entry in the search result 80 | # this must be the complete row of the data.frame returned 81 | # by the find_public_datasets function 82 | dataset_search_entry <- datasets[datasets$id == "E-MTAB-7453", ] 83 | 84 | str(dataset_search_entry) 85 | ``` 86 | 87 | The selected dataset can now be loaded through the `load_public_dataset` function. 88 | 89 | ```{r} 90 | # this function only takes one argument, which must be 91 | # a single row from the data.frame returned by the 92 | # find_public_datasets function 93 | mel_cells_braf <- load_public_dataset(dataset_search_entry, verbose = TRUE) 94 | ``` 95 | 96 | The returned object is an `ExpressionSet` object that already contains 97 | all available metada. 98 | 99 | ```{r} 100 | # use the biobase functions to access the metadata 101 | library(Biobase) 102 | 103 | # basic metadata 104 | pData(mel_cells_braf) 105 | ``` 106 | 107 | Detailed descriptions of the loaded study are further stored in the metadata slot. 108 | 109 | ```{r} 110 | # access the stored metadata using the experimentData function 111 | experimentData(mel_cells_braf) 112 | 113 | # for some datasets, longer descriptions are available. These 114 | # can be accessed using the abstract function 115 | abstract(mel_cells_braf) 116 | ``` 117 | 118 | 119 | Additionally, you can use the `table` function to quickly get the number 120 | of available samples for a specific metadata field. 121 | 122 | ```{r} 123 | table(mel_cells_braf$compound) 124 | ``` 125 | 126 | ## Perform the pathway analysis using ReactomeGSA 127 | 128 | This object is now directly compatible with ReactomeGSA's pathway 129 | analysis functions. A detailed explanation of how to perform 130 | this analysis, please have a look at the respective vignette. 131 | 132 | ```{r} 133 | # create the analysis request 134 | my_request <-ReactomeAnalysisRequest(method = "Camera") 135 | 136 | # do not create a visualization for this example 137 | my_request <- set_parameters(request = my_request, create_reactome_visualization = FALSE) 138 | 139 | # add the dataset using the loaded object 140 | my_request <- add_dataset(request = my_request, 141 | expression_values = mel_cells_braf, 142 | name = "E-MTAB-7453", 143 | type = "rnaseq_counts", 144 | comparison_factor = "compound", 145 | comparison_group_1 = "PLX4720", 146 | comparison_group_2 = "none") 147 | 148 | my_request 149 | ``` 150 | 151 | The analysis can now started using the standard workflow: 152 | 153 | ```{r} 154 | # perform the analysis using ReactomeGSA 155 | res <- perform_reactome_analysis(my_request) 156 | 157 | # basic overview of the result 158 | print(res) 159 | 160 | # key pathways 161 | res_pathways <- pathways(res) 162 | 163 | head(res_pathways) 164 | ``` 165 | 166 | ## Session Info 167 | 168 | ```{r} 169 | sessionInfo() 170 | ``` 171 | -------------------------------------------------------------------------------- /vignettes/using-reactomegsa.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Using the ReactomeGSA package" 3 | author: "Johannes Griss" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Using the ReactomeGSA package} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r setup, include = FALSE} 13 | knitr::opts_chunk$set( 14 | collapse = TRUE, 15 | comment = "#>" 16 | ) 17 | ``` 18 | 19 | ## Introduction 20 | 21 | 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. 22 | 23 | The main advantages of using the Reactome Analysis System are: 24 | 25 | * Simultaneous analysis and visualization of different types of 'omics data 26 | * Support for direct comparison across different species 27 | * Directly linked with Reactome's powerful pathway browser producing publication-ready figures of your gene set analysis 28 | 29 | ### Citation 30 | 31 | To cite this package, use 32 | 33 | ``` 34 | Griss J. ReactomeGSA, https://github.com/reactome/ReactomeGSA (2019) 35 | ``` 36 | 37 | ## Installation 38 | 39 | The `ReactomeGSA` package can be directly installed from Bioconductor: 40 | 41 | ```{r, eval=FALSE } 42 | if (!requireNamespace("BiocManager", quietly = TRUE)) 43 | install.packages("BiocManager") 44 | 45 | if (!require(ReactomeGSA)) 46 | BiocManager::install("ReactomeGSA") 47 | ``` 48 | 49 | For more information, see https://bioconductor.org/install/. 50 | 51 | ## Getting available methods 52 | 53 | The Reactome Analysis System will be continuously updated. Before starting your analysis it is therefore a good approach to check which methods are available. 54 | 55 | This can simply be done by using: 56 | 57 | ```{r show_methods} 58 | library(ReactomeGSA) 59 | 60 | available_methods <- get_reactome_methods(print_methods = FALSE, return_result = TRUE) 61 | 62 | # only show the names of the available methods 63 | available_methods$name 64 | ``` 65 | 66 | To get more information about a specific method, set `print_details` to `TRUE` and specify the `method`: 67 | 68 | ```{r get_method_details} 69 | # Use this command to print the description of the specific method to the console 70 | # get_reactome_methods(print_methods = TRUE, print_details = TRUE, method = "PADOG", return_result = FALSE) 71 | 72 | # show the parameter names for the method 73 | padog_params <- available_methods$parameters[available_methods$name == "PADOG"][[1]] 74 | 75 | paste0(padog_params$name, " (", padog_params$type, ", ", padog_params$default, ")") 76 | ``` 77 | 78 | ## Creating an analysis request 79 | 80 | 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. 81 | 82 | When creating the request object, you already have to specify the analysis method you want to use: 83 | 84 | ```{r create_request} 85 | # Create a new request object using 'Camera' for the gene set analysis 86 | my_request <-ReactomeAnalysisRequest(method = "Camera") 87 | 88 | my_request 89 | ``` 90 | 91 | ## Setting parameters 92 | 93 | To get a list of supported parameters for each method, use the `get_reactome_methods` function (see above). 94 | 95 | Parameters are simply set using the `set_parameters` function: 96 | 97 | ```{r set_parameters} 98 | # set the maximum number of allowed missing values to 50% 99 | my_request <- set_parameters(request = my_request, max_missing_values = 0.5) 100 | 101 | my_request 102 | ``` 103 | 104 | Multiple parameters can by set simulataneously by simply adding more name-value pairs to the function call. 105 | 106 | ## Adding datasets 107 | 108 | 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: 109 | 110 | ```{r add_dataset} 111 | library(ReactomeGSA.data) 112 | data("griss_melanoma_proteomics") 113 | ``` 114 | 115 | This is a limma `EList` object with the sample data already added 116 | 117 | ```{r} 118 | class(griss_melanoma_proteomics) 119 | head(griss_melanoma_proteomics$samples) 120 | ``` 121 | 122 | The dataset can now simply be added to the request using the `add_dataset` function: 123 | 124 | ```{r} 125 | my_request <- add_dataset(request = my_request, 126 | expression_values = griss_melanoma_proteomics, 127 | name = "Proteomics", 128 | type = "proteomics_int", 129 | comparison_factor = "condition", 130 | comparison_group_1 = "MOCK", 131 | comparison_group_2 = "MCM", 132 | additional_factors = c("cell.type", "patient.id")) 133 | my_request 134 | ``` 135 | 136 | Several datasets (of the same experiment) can be added to one request. This RNA-seq data is stored as an `edgeR` `DGEList` object: 137 | 138 | ```{r} 139 | data("griss_melanoma_rnaseq") 140 | 141 | # only keep genes with >= 100 reads in total 142 | total_reads <- rowSums(griss_melanoma_rnaseq$counts) 143 | griss_melanoma_rnaseq <- griss_melanoma_rnaseq[total_reads >= 100, ] 144 | 145 | # this is a edgeR DGEList object 146 | class(griss_melanoma_rnaseq) 147 | head(griss_melanoma_rnaseq$samples) 148 | ``` 149 | 150 | Again, the dataset can simply be added using `add_dataset`. Here, we added an additional parameter to the `add_dataset` 151 | call. Such additional parameters are treated as additional dataset-level parameters. 152 | ```{r} 153 | # add the dataset 154 | my_request <- add_dataset(request = my_request, 155 | expression_values = griss_melanoma_rnaseq, 156 | name = "RNA-seq", 157 | type = "rnaseq_counts", 158 | comparison_factor = "treatment", 159 | comparison_group_1 = "MOCK", 160 | comparison_group_2 = "MCM", 161 | additional_factors = c("cell_type", "patient"), 162 | # This adds the dataset-level parameter 'discrete_norm_function' to the request 163 | discrete_norm_function = "TMM") 164 | my_request 165 | ``` 166 | 167 | ### Sample annotations 168 | 169 | Datasets can be passed as limma `EList`, edgeR `DGEList`, any implementation of the Bioconductor `ExpressionSet`, or simply a `data.frame`. 170 | 171 | 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. 172 | 173 | ### Name 174 | 175 | Each dataset has to have a name. This can be anything but has to be unique within one analysis request. 176 | 177 | ### Type 178 | 179 | The ReactomeAnalysisSystem supports different types of 'omics data. To get a list of supported types, use the `get_reactome_data_types` function: 180 | 181 | ```{r get_data_types} 182 | get_reactome_data_types() 183 | ``` 184 | 185 | ### Defining the experimental design 186 | 187 | Defining the experimental design for a `ReactomeAnalysisRequest` is very simple. Basically, it only takes three parameters: 188 | 189 | * `comparison_factor`: Name of the property within the sample data to use 190 | * `comparison_group_1`: The first group to compare 191 | * `comparison_group_2`: The second group to compare 192 | 193 | 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). 194 | 195 | 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`. 196 | 197 | Blocking factors can simply be set `additional_factors` to a vector of names. These should again reference properties (or columns) in the sample data. 198 | 199 | ## Submitting the request 200 | 201 | Once the `ReactomeAnalysisRequest` is created, the complete analysis can be run using `perform_reactome_analysis`: 202 | 203 | ```{r perform_analysis} 204 | result <- perform_reactome_analysis(request = my_request, compress = F) 205 | ``` 206 | 207 | ## Investigating the result 208 | 209 | The result object is a `ReactomeAnalysisResult` S4 class with several helper functions to access the data. 210 | 211 | To retrieve the names of all available results (generally one per dataset), use the `names` function: 212 | 213 | ```{r} 214 | names(result) 215 | ``` 216 | 217 | For every dataset, different result types may be available. These can be shown using the `result_types` function: 218 | 219 | ```{r} 220 | result_types(result) 221 | ``` 222 | 223 | The `Camera` analysis method returns two types of results, pathway-level data and gene- / protein-level fold changes. 224 | 225 | A specific result can be retrieved using the `get_result` method: 226 | 227 | ```{r} 228 | # retrieve the fold-change data for the proteomics dataset 229 | proteomics_fc <- get_result(result, type = "fold_changes", name = "Proteomics") 230 | head(proteomics_fc) 231 | ``` 232 | 233 | Additionally, it is possible to directly merge the pathway level data for all result sets using the `pathways` function: 234 | 235 | ```{r} 236 | combined_pathways <- pathways(result) 237 | 238 | head(combined_pathways) 239 | ``` 240 | 241 | ## Visualising results 242 | 243 | 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`. 244 | 245 | `plot_correlations` can be used to quickly assess how similar two datasets are on the pathway level: 246 | 247 | ```{r} 248 | plot_correlations(result) 249 | ``` 250 | 251 | Individual datasets can further be visualised using volcano plots of the pathway data: 252 | 253 | ```{r} 254 | plot_volcano(result, 2) 255 | ``` 256 | 257 | Finally, it is possible to view the result as a heatmap: 258 | 259 | ```{r} 260 | plot_heatmap(result) + 261 | # reduce text size to create a better HTML rendering 262 | ggplot2::theme(text = ggplot2::element_text(size = 6)) 263 | ``` 264 | 265 | By default, only 30 pathways are shown in the heatmap. It is also possible to easily manually select 266 | pathways of interest to plot: 267 | 268 | ```{r} 269 | # get the data ready to plot with ggplot2 270 | plot_data <- plot_heatmap(result, return_data = TRUE) 271 | 272 | # select the pathways of interest - here all pathways 273 | # with "Interleukin" in their name 274 | interleukin_pathways <- grepl("Interleukin", plot_data$Name) 275 | 276 | interesting_data <- plot_data[interleukin_pathways, ] 277 | 278 | # create the heatmap 279 | ggplot2::ggplot(interesting_data, ggplot2::aes(x = dataset, y = Name, fill = direction)) + 280 | ggplot2::geom_tile() + 281 | ggplot2::scale_fill_brewer(palette = "RdYlBu") + 282 | ggplot2::labs(x = "Dataset", fill = "Direction") + 283 | ggplot2::theme(text = ggplot2::element_text(size = 6)) 284 | ``` 285 | 286 | ### Opening web-based visualization 287 | 288 | Additionally, it is possible to open the analysis in Reactome's web interface using the `open_reactome` command: 289 | 290 | ```{r} 291 | # Note: This command is not execute in the vignette, since it tries 292 | # to open the default web browser 293 | 294 | # open_reactome(result) 295 | ``` 296 | 297 | ## Session Info 298 | 299 | ```{r} 300 | sessionInfo() 301 | ``` 302 | --------------------------------------------------------------------------------