Enrichment Significance Test Calculator — Hypergeometric Distribution / Fisher's Exact Test
After differential expression analysis, you end up with a list of genes. The next question is always: is the enrichment of a particular pathway in this list real, or could it arise by chance?
The answer comes from the hypergeometric distribution. Define:
N = total background gene count
K = number of pathway genes in the background
n = length of your gene list
k = number of genes in your list that fall in the pathway (overlap)
The probability of drawing exactly i pathway genes when randomly sampling n genes from the background is:
P(X = i) = C(K, i) × C(N−K, n−i) / C(N, n)
The p-value is the probability of observing at least this many, summing i from k upward: P(X ≥ k).
Expected overlap is n × K / N; fold enrichment is the observed overlap divided by the expected overlap.
Fold enrichment tells you the effect size; the p-value only tells you how unlikely the result is under random sampling — you need both.
The one-tailed Fisher’s exact test (alternative = greater) gives exactly the same result as the hypergeometric p-value; they are two ways of describing the same distribution. The tool reports both so you can match whichever notation your paper uses.
Choosing the wrong background gene count is the most common mistake
N is not “roughly 20,000 human genes.” It is the number of genes actually detected in your experiment that also have pathway annotations.
- If you used a microarray covering 12,000 genes, set
Nto 12,000, not 20,000. - In RNA-seq, if you filtered out low-expression genes,
Nis the count after filtering. - Genes with no annotation in the pathway database should strictly not be counted.
Inflating N systematically overstates significance — a larger denominator lowers the chance of a random overlap, making p-values look better than they are. This is the most common point reviewers flag in enrichment analyses.
Two more things to keep in mind
One pathway is not enough. You typically test hundreds or thousands of pathways at once, so multiple-testing correction is required. The multiple-testing correction tool on this site converts a column of p-values into BH-adjusted q-values in bulk.
P-values are unstable when the overlap is very small. When the overlap is only 1–2 genes, adding or removing one gene can shift the p-value by an order of magnitude. Do not highlight such results in isolation.
FAQ
How should I choose the background gene count N?
Use the number of genes actually detected in your experiment that also have annotations in the pathway database. If your microarray covers 12,000 genes, enter 12,000; if you filtered low-expression genes in RNA-seq, enter the post-filter count. Using 'approximately 20,000 human genes' will systematically overstate significance.
What is the difference between the hypergeometric test and Fisher's exact test?
In the one-tailed case there is no difference — they produce the same number, because they describe the same distribution. The two-tailed Fisher's test also includes the other tail, testing whether the overlap is either unusually high or unusually low.
Does a small p-value mean the pathway is important?
Not necessarily. The p-value only says the result is unlikely under random sampling; fold enrichment tells you the effect size. With a large background, even a 1.2-fold enrichment can produce a very small p-value. Consider both numbers together.
Why does my result differ from DAVID / clusterProfiler?
Most likely the backgrounds differ. Those tools default to using the full database as background, whereas your experiment measured only a subset of it. They also typically report BH-corrected q-values by default, not raw p-values.
Related tools
qPCR Amplification Efficiency Calculator — Standard Curve Slope to E, Pfaffl Relative Quantification
Fit a standard curve from serial dilutions to calculate amplification efficiency E and R²; apply the Pfaffl method for efficiency-corrected relative quantification.
RNA-seq Expression Normalization Calculator: RPKM / FPKM / TPM Converter
Paste gene read counts and lengths to compute RPKM / FPKM and TPM at once — and see directly that TPM sums to 1,000,000 while RPKM does not.
Online t-Test Calculator: Independent Samples / Paired Samples / One-Sample (with Welch Correction)
Paste two data sets to get the t-statistic, degrees of freedom, two-tailed p-value, mean-difference confidence interval, and Cohen's d — Welch correction on by default.
Buy me a coffee