50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

genekitr (version 1.2.8)

plotGSEA: Plot for gene enrichment analysis of GSEA method

Description

Gene Set Enrichment Analysis (GSEA) is a computational method that determines whether an a priori defined set of genes shows statistically significant, concordant differences between two biological states (e.g. phenotypes).

Usage

plotGSEA(
  gsea_list,
  plot_type = c("volcano", "classic", "fgsea", "ridge", "bar"),
  stats_metric = c("p.adjust", "pvalue", "qvalue"),
  show_pathway = NULL,
  show_gene = NULL,
  colour = NULL,
  wrap_length = NULL,
  label_by = c("id", "description"),
  ...
)

Value

A ggplot object

Arguments

gsea_list

GSEA result from `genGSEA` function

plot_type

GSEA plot type, one of 'volcano', 'classic', 'fgsea', 'ridge' or 'bar'.

stats_metric

Statistic metric from one of "pvalue", "p.adjust", "qvalue".

show_pathway

Select plotting pathways by number (will choose top N pathways) or pathway name (choose from ID column).

show_gene

Select genes to show. Default is "all". Used in "classic" plot.

colour

Colour vector. Deafault is NULL. Used in volcano, ridge and bar plot.

wrap_length

Numeric, wrap text if longer than this length. Default is NULL.

label_by

Select which column as the label. If user wants to modify labels in plot, please modify the "Description" column and set the argument as "description". Default is by 'id'.

...

other arguments transfer to `plot_theme` function

Examples

Run this code
# \donttest{
k1 = requireNamespace("cowplot",quietly = TRUE)
k2 = requireNamespace("fgsea",quietly = TRUE)
k3 = requireNamespace("ggplotify",quietly = TRUE)
k4 = requireNamespace("ggridges",quietly = TRUE)
if(k1&k2&k3&k4){
library(ggplot2)
## get GSEA result
data(geneList, package = "genekitr")
gs <- geneset::getMsigdb(org = "human",category = "H")
gse <- genGSEA(genelist = geneList, geneset = gs)

## volcano plot
# get top3 of up and down pathways
plotGSEA(gse, plot_type = "volcano", show_pathway = 3)
# choose pathway by character
pathways <- c('HALLMARK_KRAS_SIGNALING_UP','HALLMARK_P53_PATHWAY','HALLMARK_GLYCOLYSIS')
plotGSEA(gse, plot_type = "volcano", show_pathway = pathways)

## classic pathway plot
genes <- c('ENG','TP53','MET')
plotGSEA(gse, plot_type = "classic", show_pathway = pathways, show_gene = genes)

## fgsea table plot
plotGSEA(gse, plot_type = "fgsea", show_pathway = 3)

## ridgeplot
plotGSEA(gse,
  plot_type = "ridge",
  show_pathway = 10, stats_metric = "p.adjust"
)

## two-side barplot
plotGSEA(gse,
  plot_type = "bar", main_text_size = 8,
  colour = c("navyblue", "orange")
)
}
# }

Run the code above in your browser using DataLab