Multiple Testing Correction
A p-value is a tail probability under a specified null model. It is not the probability that the reported result is a false positive. The significance level, alpha, specifies the rejection rule before the data are examined. Under a valid test, a true null has a rejection probability no greater than alpha.
If 20,000 tested hypotheses are all true nulls and each test has a false-positive rate of 0.05, the expected number of false positives is 1,000. Independence is not needed for that expectation. The realized count varies, and an experiment containing real effects has fewer than 20,000 true nulls.
Define the family before selecting results
Section titled “Define the family before selecting results”Specify which hypotheses belong to the analysis, such as all genes in one differential-expression comparison. Apply the correction to that family. Selecting genes because their raw p-values are small and correcting only that selection does not preserve the intended error control.
The family and the error criterion depend on the scientific claim. Bonferroni controls the probability of at least one false rejection in the family. Benjamini-Hochberg controls the expected false discovery proportion under independence or suitable positive dependence. It does not specify the false-positive probability of each selected gene or guarantee a fixed fraction in one experiment.
The CRISPR method lesson defines RRA enrichment and MLE Wald tests as separate gene families. Its comparison preserves each correction and keeps the primary discovery list separate from sensitivity results.
Get the data
Section titled “Get the data”Download pvalues.csv into your working directory. This invented dataset contains 1,000 tests, including 900 nulls and 100 nonzero effects. Its is_true column records the simulation labels; real gene studies do not provide that answer key.
Run each language’s blocks in order. R uses ggplot2, and Python uses pandas, Matplotlib, and statsmodels.
Inspect the p-value distribution
Section titled “Inspect the p-value distribution”For this simulation, continuous valid null p-values have a uniform distribution. Nonzero effects can add small p-values. A histogram is a diagnostic, but it cannot identify which individual results are true effects. Discrete tests, conservative tests, dependence, or model problems can produce other shapes, so investigate the test and study design before attributing a shape to a fault.
library(ggplot2)
data <- read.csv("pvalues.csv")dir.create("outputs", showWarnings = FALSE)histogram <- ggplot(data, aes(pvalue)) + geom_histogram(binwidth = 0.05, boundary = 0, fill = "#3B6DB3", color = "white") + labs(x = "P-value", y = "Number of genes") + theme_minimal(base_size = 12)ggsave("outputs/pval-hist-r.png", histogram, width = 5, height = 4, dpi = 150)
from pathlib import Path
import matplotlib.pyplot as pltimport numpy as npimport pandas as pdfrom statsmodels.stats.multitest import multipletests
data = pd.read_csv("pvalues.csv")output = Path("outputs")output.mkdir(exist_ok=True)figure, axis = plt.subplots(figsize=(5, 4))axis.hist(data["pvalue"], bins=np.linspace(0, 1, 21), color="#3B6DB3", edgecolor="white")axis.set(xlabel="P-value", ylabel="Number of genes")figure.tight_layout()figure.savefig(output / "pval-hist-python.png", dpi=150)plt.close(figure)
Compare the rejection rules
Section titled “Compare the rejection rules”The table reports discoveries and the false discoveries identified by the simulation labels. Its last column is the realized false discovery proportion for this dataset. The false discovery rate is the expectation of that proportion over repeated experiments, with proportion zero when there are no discoveries.
alpha <- 0.05adjusted <- list( Raw = data$pvalue, Bonferroni = p.adjust(data$pvalue, method = "bonferroni"), BH = p.adjust(data$pvalue, method = "BH"))summary_rows <- data.frame()for (method in names(adjusted)) { rejected <- adjusted[[method]] <= alpha discoveries <- sum(rejected) false_discoveries <- sum(rejected & data$is_true == 0) proportion <- false_discoveries / max(discoveries, 1) summary_rows <- rbind(summary_rows, data.frame( method = method, discoveries = discoveries, false_discoveries = false_discoveries, proportion = proportion )) cat(sprintf("%s: discoveries = %d, false = %d, proportion = %.4f\n", method, discoveries, false_discoveries, proportion))}Raw: discoveries = 130, false = 46, proportion = 0.3538Bonferroni: discoveries = 18, false = 0, proportion = 0.0000BH: discoveries = 43, false = 2, proportion = 0.0465alpha = 0.05adjusted = { "Raw": data["pvalue"].to_numpy(), "Bonferroni": multipletests(data["pvalue"], method="bonferroni")[1], "BH": multipletests(data["pvalue"], method="fdr_bh")[1],}summary_rows = []for method, values in adjusted.items(): rejected = values <= alpha discoveries = int(rejected.sum()) false_discoveries = int((rejected & (data["is_true"] == 0)).sum()) proportion = false_discoveries / max(discoveries, 1) summary_rows.append({"method": method, "discoveries": discoveries, "false_discoveries": false_discoveries, "proportion": proportion}) print(f"{method}: discoveries = {discoveries}, " f"false = {false_discoveries}, proportion = {proportion:.4f}")summary_rows = pd.DataFrame(summary_rows)Raw: discoveries = 130, false = 46, proportion = 0.3538Bonferroni: discoveries = 18, false = 0, proportion = 0.0000BH: discoveries = 43, false = 2, proportion = 0.0465Bonferroni rejects fewer hypotheses here because its criterion concerns any false rejection in the family. BH permits more discoveries while controlling a different expected error measure. Neither correction creates biological importance or compensates for invalid individual tests.
summary_rows$method <- factor(summary_rows$method, levels = c("Raw", "Bonferroni", "BH"))discovery_plot <- ggplot(summary_rows, aes(method, discoveries)) + geom_col(fill = "#3B6DB3", width = 0.6) + geom_text(aes(label = discoveries), vjust = -0.4) + labs(x = NULL, y = "Rejected hypotheses") + theme_minimal(base_size = 12)ggsave("outputs/discoveries-r.png", discovery_plot, width = 5, height = 4, dpi = 150)
figure, axis = plt.subplots(figsize=(5, 4))bars = axis.bar(summary_rows["method"], summary_rows["discoveries"], color="#3B6DB3", width=0.6)axis.bar_label(bars)axis.set_ylabel("Rejected hypotheses")figure.tight_layout()figure.savefig(output / "discoveries-python.png", dpi=150)plt.close(figure)
Report the analysis
Section titled “Report the analysis”State the hypothesis family, correction method, and chosen threshold. Report effect estimates and uncertainty alongside adjusted p-values. Describe filtering rules and whether they depend on the test statistic. Use the RNA-seq differential-expression guide for a count-model application.
The paired ATAC-seq lesson defines its hypothesis family over tested genomic regions. Its motif lesson corrects a separate family of enrichment tests and distinguishes those p-values from motif site scores.
The Spatial autocorrelation lesson adjusts eight declared permutation tests with the Benjamini-Hochberg method. Those tests describe one tissue section, so the adjusted p-values say nothing about a difference between donors.
Check your understanding
Section titled “Check your understanding”Does a BH-adjusted p-value below 0.05 mean that this particular gene has a 5% probability of being a false discovery?
It does not. BH controls an expected proportion across the discovery procedure under its assumptions. It does not assign a posterior probability to an individual hypothesis.
Further reading
Section titled “Further reading”The R p-value adjustment reference describes Bonferroni, Holm, Benjamini-Hochberg, and Benjamini-Yekutieli corrections. It distinguishes family-wise error control from false discovery rate control and states the dependence conditions.
The ASA release of March 7, 2016 presents six principles for p-value interpretation. It is the announcement of the statement and explains why a p-value does not measure the probability that a hypothesis is true.