## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----eval=FALSE--------------------------------------------------------------- # if (!requireNamespace("BiocManager", quietly = TRUE)) # install.packages("BiocManager") # # if (!require(ReactomeGSA)) # BiocManager::install("ReactomeGSA") # # # install the ReactomeGSA.data package for the example data # if (!require(ReactomeGSA.data)) # BiocManager::install("ReactomeGSA.data") ## ----------------------------------------------------------------------------- library(ReactomeGSA.data) data(jerby_b_cells) jerby_b_cells ## ----------------------------------------------------------------------------- library(ReactomeGSA) gsva_result <- analyse_sc_clusters(jerby_b_cells, verbose = TRUE) ## ----------------------------------------------------------------------------- gsva_result ## ----------------------------------------------------------------------------- pathway_expression <- pathways(gsva_result) # simplify the column names by removing the default dataset identifier colnames(pathway_expression) <- gsub("\\.Seurat", "", colnames(pathway_expression)) pathway_expression[1:3,] ## ----------------------------------------------------------------------------- # find the maximum differently expressed pathway max_difference <- do.call(rbind, apply(pathway_expression, 1, function(row) { values <- as.numeric(row[2:length(row)]) return(data.frame(name = row[1], min = min(values), max = max(values))) })) max_difference$diff <- max_difference$max - max_difference$min # sort based on the difference max_difference <- max_difference[order(max_difference$diff, decreasing = T), ] head(max_difference) ## ----fig.width=7, fig.height=4------------------------------------------------ plot_gsva_pathway(gsva_result, pathway_id = rownames(max_difference)[1]) ## ----fig.width=7, fig.height=8------------------------------------------------ # Additional parameters are directly passed to gplots heatmap.2 function plot_gsva_heatmap(gsva_result, max_pathways = 15, margins = c(6,20)) ## ----fig.width=7, fig.height=4------------------------------------------------ # limit to selected B cell related pathways relevant_pathways <- c("R-HSA-983170", "R-HSA-388841", "R-HSA-2132295", "R-HSA-983705", "R-HSA-5690714") plot_gsva_heatmap(gsva_result, pathway_ids = relevant_pathways, # limit to these pathways margins = c(6,30), # adapt the figure margins in heatmap.2 dendrogram = "col", # only plot column dendrogram scale = "row", # scale for each pathway key = FALSE, # don't display the color key lwid=c(0.1,4)) # remove the white space on the left ## ----fig.width=6, fig.height=4------------------------------------------------ plot_gsva_pca(gsva_result) ## ----------------------------------------------------------------------------- sessionInfo()