Skip to contents

Visualize GSEA results

Usage

VizGSEA(
  gsea_results,
  plot_type = c("summary", "gsea"),
  gene_ranks = "@gene_ranks",
  gene_sets = "@gene_sets",
  gs = NULL,
  ...
)

Arguments

gsea_results

A data frame with the results of the fgsea analysis

plot_type

The type of plot to create One of "summary", "gsea"

gene_ranks

A numeric vector of gene ranks with genes as names The gene ranks are used to plot the gene sets. If gene_ranks is a character vector starting with @, the gene ranks will be taken from the attribute of data.

gene_sets

A list of gene sets, typically from a record of a GMT file The names of the list should match the ID column of data. If gene_sets is a character vector starting with @, the gene sets will be taken from the attribute of data. The GSEA plots will be plotted for each gene set. So, the number of plots will be the number of gene sets. If you only want to plot a subset of gene sets, you can subset the gene_sets before passing it to this function.

gs

The names of the gene sets to plot If NULL, all gene sets in gene_sets will be plotted.

...

Additional arguments passed to the plotting function

Value

A ggplot object or a list of ggplot objects

Examples

# \donttest{
set.seed(123)
exprs <- matrix(rnorm(1000), nrow = 100, ncol = 10)
colnames(exprs) <- paste0("Sample", 1:10)
rownames(exprs) <- paste0("Gene", 1:100)
classes <- c(rep("A", 5), rep("B", 5))
ranks <- RunGSEAPreRank(exprs, case = "A", control = "B", classes = classes)
genesets <- list(
    set1 = c("Gene1", "Gene2", "Gene3"),
    set2 = c("Gene4", "Gene5", "Gene6"),
    set3 = c("Gene7", "Gene8", "Gene9"),
    set4 = c("Gene10", "Gene11", "Gene12"),
    set5 = c("Gene13", "Gene14", "Gene15"),
    set6 = c("Gene16", "Gene17", "Gene18"),
    set7 = c("Gene19", "Gene20", "Gene21"),
    set8 = c("Gene22", "Gene23", "Gene24"),
    set9 = c("Gene25", "Gene26", "Gene27"),
    set10 = c("Gene12", "Gene86", "Gene87", "Gene83", "Gene71")
)
r <- RunGSEA(ranks, genesets)

# Visualize the GSEA results
VizGSEA(r, plot_type = "summary")

VizGSEA(r, plot_type = "gsea", gs = c("set10", "set2"))

# }