Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
A GSEA plot (also called a GSEA enrichment plot) draws one gene set against a ranked gene list. It shows three things on a shared x-axis, the position in that ranked list: a running enrichment score that rises when a gene in the set is encountered and falls otherwise, tick marks for where the set’s members sit in the list, and the ranking statistic itself. The peak of the running score is the set’s enrichment score (ES), and the genes up to that peak form the leading-edge subset. You can draw the plot with the GSEA desktop application, with plotEnrichment() from the fgsea R package, or with gseaplot2() from enrichplot.
What a GSEA plot is used for in research
Gene set enrichment analysis (GSEA) asks whether the members of a predefined gene set fall toward the top or bottom of a list of genes ranked by their relationship to a phenotype, rather than asking whether individual genes cross a cut-off. The method was introduced by Subramanian and colleagues in PNAS in 2005. The result table reports a score and a p-value per set; the plot is where you check that the score reflects a real pattern in the ranking and not a single outlier gene. For the method itself, including normalised enrichment score (NES) and false discovery rate (FDR) q-values, see the CASRAI guide to gene set enrichment analysis (GSEA). For a plot that works from the result of an over-representation test instead, see Enrichr, and for upstream ranking statistics see differential gene expression analysis.
How to read a GSEA enrichment plot
The plot is the graphical form of the algorithm. In the 2005 paper, the score is calculated “by walking down the list L, increasing a running-sum statistic when we encounter a gene in S” and decreasing it for genes not in S; how large each increase is depends on the gene’s correlation with the phenotype. The enrichment score is “the maximum deviation from zero encountered in the random walk.” The figure legend for the paper’s schematic describes panel B as the plot of the running sum for S in the data set, “including the location of the maximum enrichment score (ES) and the leading-edge subset.”
Panel-by-panel reading
| Plot element | What it represents | What to look for |
|---|---|---|
| x-axis | Position in the ranked gene list (not a gene identifier) | Position 1 is the top of your ranking. The same axis is shared by every panel. |
| Running enrichment score curve | The running-sum statistic: it rises when a gene in the set is encountered and falls otherwise | A single sharp rise near one end suggests the set is concentrated at that end of the ranking; a curve that wanders close to zero suggests no concentration. |
| Peak of the curve (dashed vertical line in gseaplot2) | The enrichment score: the maximum deviation from zero | Where the line falls on the x-axis tells you how far down the list the score is reached. |
| Black vertical ticks | Positions of the gene set’s members in the ranked list | Clusters of ticks at one end versus an even scatter across the whole list. |
| Coloured rectangles behind the ticks (gseaplot2) | The hits divided into equal-count bins, red for the top of the list to blue for the bottom | The bins split the hits, not the list; a very narrow rectangle means hits are packed tightly together. |
| Ranked list metric panel | The ranking statistic for every gene, such as log fold change or a signed correlation | Whether set members sit where the metric is large and positive, large and negative, or near zero. |
Leading edge on the plot
The leading-edge subset is the part of the gene set that appears in the ranked list at or before the point of maximum deviation. On the plot that means the ticks to the left of the peak when the curve peaks on the left side. It is the portion of the set that drives the score, which is why the leading-edge genes, and not the whole set, are what you usually carry into follow-up work. The fgsea results table includes a leadingEdge column of gene identifiers for each pathway.
Reading a plot alongside the result table
A plot never replaces the statistics. In the fgsea results table the score and p-values sit in the same row as the pathway, so open the plot for the row you are about to report and confirm that the curve and tick pattern fit the numbers. If you are comparing several sets, use the numbers in the table to rank them and the plots to check each one. The CASRAI GSEA guide covers NES and FDR in detail.
How to install or access it
For R, the two packages below are on Bioconductor. The fgsea page (“Fast Gene Set Enrichment Analysis”) and the enrichplot page (“Visualization of Functional Enrichment Result”) each give the same installation pattern, checked 2026-11-13:
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("fgsea")
BiocManager::install("enrichplot")
enrichplot is designed to pair with clusterProfiler and uses ggplot2 for its graphics. If your GSEA result comes from clusterProfiler, see the CASRAI guide to clusterProfiler.
Step-by-step: make a GSEA plot in R
Option 1: fgsea, one set with plotEnrichment()
- Prepare a named numeric vector of ranking statistics (
stats) and a named list of pathways, each a vector of gene identifiers that match the names ofstats. - Run fgsea. This is the call from the Bioconductor fgsea tutorial, which uses the package’s bundled
examplePathwaysandexampleRanksdata:data(examplePathways) data(exampleRanks) set.seed(42) fgseaRes <- fgsea(pathways = examplePathways, stats = exampleRanks, minSize = 15, maxSize = 500)The tutorial notes that the resulting table contains enrichment scores and p-values, and that setting
eps = 0.0gives more accurate p-values. - Draw the plot for a chosen pathway:
plotEnrichment(examplePathways[["5991130_Programmed_Cell_Death"]], exampleRanks) + labs(title="Programmed Cell Death")
Option 2: fgsea, many sets with plotGseaTable()
To see several pathways together, the tutorial selects the ten most significant sets with a positive ES and the ten with a negative ES, and passes them to plotGseaTable():
topPathwaysUp <- fgseaRes[ES > 0][head(order(pval), n=10), pathway]
topPathwaysDown <- fgseaRes[ES < 0][head(order(pval), n=10), pathway]
topPathways <- c(topPathwaysUp, rev(topPathwaysDown))
plotGseaTable(examplePathways[topPathways], exampleRanks, fgseaRes,
gseaParam=0.5)
Option 3: enrichplot, gseaplot2()
The YuLab Biomedical Knowledge Mining book builds a GSEA result from the geneList bundled with DOSE and then plots it:
library(DOSE)
data(geneList, package = "DOSE")
edo2 <- gseDO(geneList)
gseaplot2(edo2, geneSetID = 1, title = edo2$Description[1])
gseaplot2(edo2, geneSetID = 1:3)
gseaplot2(edo2, geneSetID = 1:3, pvalue_table = TRUE,
color = c("#E495A5", "#86B875", "#7DB0DD"), ES_geom = "dot")
geneSetID picks the set or sets (1 or 1:3); pvalue_table = TRUE adds a p-value table; color takes one colour per set; ES_geom = "dot" draws the enrichment score as dots. To control the table, the book uses pvalue_table_rownames = NULL and pvalue_table_columns = c("ID","NES","p.adjust"). To keep only some panels, subplots = 1 returns just the first panel (subplots = 1:2 the first two), for example p1 <- gseaplot2(edo2, geneSetID = 1:3, subplots = 1), so you can restyle it as a normal ggplot object.
The older gseaplot() and gsearank()
The same book also shows gseaplot(), which draws the running score and the preranked list for one set (by = "runningScore" or by = "preranked" keep one panel), and gsearank(), which plots the ranked list for one gene set; with output = "table" it returns the plotted data with the columns gene, rank in geneList, running ES and core enrichment.
GSEA desktop
The steps for running the GSEA desktop application and opening its results are in the CASRAI GSEA guide. The elements of the enrichment plot it reports follow the algorithm described in the 2005 paper, so the reading guide above (running sum, hit positions, ranked list, maximum deviation, leading edge) applies to it.
Compare the three plotting routes
The R plot functions differ in how many sets one call draws and in which options the documentation describes. The data table at the end of this page sets the plot functions side by side with the package each comes from.
Troubleshooting
- Gene identifiers do not match. The pathways must use the same identifiers as the names of the ranking vector, otherwise sets will be empty or tiny. In the YuLab book,
setReadable(edo2, 'org.Hs.eg.db', 'ENTREZID')converts identifiers to readable symbols before labelling genes on the running-score panel. - Colours differ between tools. In gseaplot2 the coloured rectangles bin the hits, not the ranked list. The YuLab book also notes that the Broad GSEA plots colour the ranked-list panel by the sign of the metric, so the two conventions are not interchangeable when you compare figures from different tools.
- Colour bins look wrong in an older enrichplot. The YuLab book describes an ordering bug in older releases, fixed in the development version it builds against (enrichplot issues 20 and 221). If your version predates the fix, compare with the book’s figure or update the package.
- Too many pathways to read. Use
plotGseaTable()for an overview, thenplotEnrichment()orgseaplot2()for the few sets you will report. - Plot style changes.
plotEnrichment()returns a ggplot object, as the tutorial’s+ labs(title=...)shows, so ggplot2 layers can be added in the usual way.
Free alternatives
The R routes above are open Bioconductor packages, and the data table compares the plot functions they provide. If your input is a plain gene list rather than a full ranking, an over-representation tool such as Enrichr gives a different kind of output, and decoupleR bundles several enrichment methods, including fast GSEA, in one R package.
FAQ
What is a GSEA plot?
It is the enrichment plot for one gene set: a running enrichment score along the ranked gene list, ticks marking set members, and the ranking metric, with the maximum deviation from zero as the enrichment score.
What do GSEA plots show about the leading edge?
The leading edge is the set of genes in the gene set at or before the point of maximum deviation in the ranked list, so on a GSEA plot it is the ticks between the start of the list and the peak of the curve (2005 PNAS paper).
How do I make a GSEA enrichment plot in R?
Use plotEnrichment(pathway, stats) from fgsea for one pathway, or gseaplot2(result, geneSetID = 1) from enrichplot for a result object created by clusterProfiler or DOSE.
Can I show several gene sets on one GSEA enrichment plot?
Yes. gseaplot2(edo2, geneSetID = 1:3) draws three sets together, and plotGseaTable() in fgsea shows many pathways in one table-style figure.
Is the x-axis a gene identifier?
No. It is the position in the ranked gene list.
Sources (read 2026-11-13)
- Subramanian A, et al. Gene set enrichment analysis: a knowledge-based approach for interpreting genome-wide expression profiles. PNAS 2005;102(43):15545-15550. pmc.ncbi.nlm.nih.gov/articles/PMC1239896
- Bioconductor fgsea package page and tutorial: package page, tutorial
- Bioconductor enrichplot package page: bioconductor.org/packages/enrichplot
- Yu G. Biomedical Knowledge Mining using GOSemSim and clusterProfiler, GSEA visualisation chapter: yulab-smu.top
Data: R functions for drawing GSEA enrichment plots: package, output and documented options
Compares five plot functions in the fgsea and enrichplot R packages by what each draws, how many gene sets one call plots and the options shown in the packages' own tutorial and the YuLab GSEA visualisation chapter. Compiled from those two documents, read 2026-11-13.
Period covered: 2026.
| Function | Package | What it draws | Gene sets per call | Options shown in the documentation | Source |
|---|---|---|---|---|---|
| plotEnrichment | fgsea | Enrichment plot for one pathway | One | Pathway vector and ranked statistics; ggplot2 layers such as labs(title=...) can be added | Bioconductor fgsea tutorial |
| plotGseaTable | fgsea | Table-style figure of many pathways | Many (tutorial uses top 10 with ES > 0 and top 10 with ES < 0) | gseaParam (tutorial uses 0.5) | Bioconductor fgsea tutorial |
| gseaplot2 | enrichplot | Three stacked panels: running enrichment score, hit ticks with coloured bins, ranked list metric | One or several (geneSetID = 1 or 1:3) | title, pvalue_table, color, ES_geom, pvalue_table_rownames, pvalue_table_columns, subplots | YuLab Biomedical Knowledge Mining: GSEA visualization |
| gseaplot | enrichplot | Running score and preranked list for one gene set | One | by (runningScore or preranked), color, color.line, color.vline, title | YuLab Biomedical Knowledge Mining: GSEA visualization |
| gsearank | enrichplot | Ranked list for one gene set | One | output = table returns gene, rank in geneList, running ES, core enrichment | YuLab Biomedical Knowledge Mining: GSEA visualization |
Sources
- Bioconductor fgsea tutorial (accessed 2026-11-13)
- YuLab Biomedical Knowledge Mining: GSEA visualization (accessed 2026-11-13)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







