← All tutorials

Enrichment Dot Plot Tutorial: clusterProfiler in R, Python, SPSS and Online

Updated November 7, 2026 · StatFAS Tutorials · Beginner to intermediate

This tutorial shows how to create an enrichment dot plot and run the statistics behind the enrichment dot plot in four ways: SPSS, R, Python and the free Enrichment Dot Plot Maker on statfas.com. Every script is complete and can be copied into the software. For the concepts behind the enrichment dot plot, read the guide Enrichment Dot Plot Explained: GO and KEGG Over-Representation Analysis.

Step 1: Prepare the data

Two inputs: (1) a gene list, one gene per line; (2) gene sets in GMT style, one term per line with tab-separated columns Term, description, gene1, gene2, … (or two columns Term and Gene). Alternatively upload a ready enrichment table with Term, Count and p-value columns.

Example layout:

Response to water deprivation	example	G0012	G0045	G0391
Abscisic acid signalling	example	G0045	G0102	G0777

Step 2: SPSS

SPSS has no GO or KEGG database and no enrichment dot plot, but the hypergeometric function CDF.HYPER computes the over-representation p value for each term in a table of counts.

* One row per term: Term, K (genes in the term), k (input genes in the term); N = background size, n = input gene count.
COMPUTE N = 1000.
COMPUTE n = 53.
COMPUTE p = 1 - CDF.HYPER(k - 1, N, n, K).          * P(X >= k), one-sided hypergeometric test
COMPUTE fold = (k / n) / (K / N).
EXECUTE.
* Benjamini-Hochberg: SORT CASES BY p (D). then rank, q = MIN(1, p * m / rank), running minimum (see the volcano plot syntax).
* Dot plot: Graphs > Chart Builder > Scatter/Dot > Simple Scatter with Term on Y, fold on X, and size by k (Chart Editor).

Step 3: R

The clusterProfiler package performs the over-representation analysis for GO, KEGG or your own gene sets and draws the enrichment dot plot with dotplot().

# Hypergeometric test by hand for one term
N <- 1000; n <- 53; K <- 40; k <- 15                # background, input genes, set size, overlap
phyper(k - 1, K, N - K, n, lower.tail = FALSE)

# Whole analysis with clusterProfiler (own gene sets: data frame with columns term, gene)
library(clusterProfiler); library(ggplot2)
sets  <- read.csv("gene_sets_long.csv")             # columns: term, gene
genes <- readLines("genes.txt")
ora <- enricher(genes, TERM2GENE = sets, pAdjustMethod = "BH",
                pvalueCutoff = 1, qvalueCutoff = 1, minGSSize = 5)
head(as.data.frame(ora))
dotplot(ora, showCategory = 15) + theme_classic()
ggsave("enrichment.png", width = 7, height = 5, dpi = 300)

# GO terms for a model organism, for example Arabidopsis:
# library(org.At.tair.db)
# ego <- enrichGO(genes, OrgDb = org.At.tair.db, keyType = "TAIR", ont = "BP", pAdjustMethod = "BH")

Step 4: Python

SciPy’s hypergeometric distribution gives the p value, statsmodels corrects for multiple testing and Matplotlib draws the enrichment dot plot. The gseapy package offers ready-made enrichment against public libraries.

import numpy as np, pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import hypergeom
from statsmodels.stats.multitest import multipletests

sets = {}                                           # gene sets: term -> set of genes
for line in open("gene_sets.tsv"):
    f = line.rstrip("\n").split("\t")
    sets[f[0]] = set(f[2:])
study = set(open("genes.txt").read().split())       # input gene list
universe = set().union(*sets.values())
study &= universe
N, n = len(universe), len(study)

rows = []
for term, S in sets.items():
    K, k = len(S), len(study & S)
    if k >= 2:
        p = hypergeom.sf(k - 1, N, K, n)            # P(X >= k), one-sided Fisher / hypergeometric
        rows.append((term, K, k, (k / n) / (K / N), p))
res = pd.DataFrame(rows, columns=["term", "K", "k", "fold", "p"])
res["q"] = multipletests(res["p"], method="fdr_bh")[1]
res = res.sort_values("p").head(15).iloc[::-1]
print(res)

plt.figure(figsize=(7, 5))
sc = plt.scatter(res["fold"], res["term"], s=res["k"] * 25, c=-np.log10(res["q"]), cmap="coolwarm", edgecolor="k")
plt.colorbar(sc, label="-log10(FDR)"); plt.xlabel("Fold enrichment")
plt.tight_layout(); plt.savefig("enrichment.png", dpi=300)

Step 5: The easy way on statfas.com

The Enrichment Dot Plot Maker needs no installation and no code. Follow these steps:

  1. Open the tool. Go to the StatFAS Enrichment Dot Plot Maker.
  2. Add data. Click Load example data to see both layouts, then paste your gene list and upload or paste your gene sets.
  3. Set options. Set the background size, the minimum overlap, the FDR cutoff, the number of terms and the axis.
  4. Read the results. The tool runs one-sided Fisher’s exact tests with Benjamini–Hochberg FDR, draws the enrichment dot plot and writes the APA 7 results and a table of terms.
  5. Download. Download the PNG or SVG, or a Word file with the figure, the table and the interpretation.
Try the Enrichment Dot Plot Maker free
Upload or paste data and get the enrichment dot plot, the statistics and an APA 7 write-up in seconds.
Open the free Enrichment Dot Plot Maker

Step 6: Interpret and report in APA 7

Check these points before the enrichment dot plot goes into a manuscript:

Example APA 7 results paragraph:

Over-representation analysis was performed for 53 input genes against 20 gene sets (background N = 1,000) using one-sided Fisher’s exact tests with Benjamini–Hochberg correction. Three terms were significantly enriched (FDR < .05), the strongest being “Response to water deprivation” (overlap = 16 of 40 genes; fold enrichment = 5.37; q < .001; Figure 1).

Avoid these mistakes with the enrichment dot plot:

Frequently asked questions

What does an enrichment dot plot show?

An enrichment dot plot shows enriched GO terms or pathways, with dot position for fold enrichment or gene ratio, dot size for gene count and colour for the adjusted p value.

What is the difference between gene ratio and fold enrichment?

Gene ratio is the share of input genes that fall in the term. Fold enrichment divides that share by the share of background genes in the term.

Which test does over-representation analysis use?

Most tools use a one-sided Fisher’s exact test, which equals the hypergeometric test, followed by Benjamini–Hochberg correction.

What is a good background set?

Use all genes that could have been detected in the experiment, for example all expressed genes, instead of every gene in the genome.

Related guides

How to cite this page: StatFAS. (2026, November 7). Enrichment Dot Plot Tutorial: clusterProfiler in R, Python, SPSS and Online. https://statfas.com/tutorials/enrichment-dot-plot.html