8: Statistical Hypothesis Testing for Biologists
Chapter 8: Statistical Hypothesis Testing for Biologists in R
High-throughput omics experiments measure tens of thousands of features simultaneously, creating severe statistical challenges. This chapter covers parametric vs non-parametric testing, ANOVA across clinical stages, Fisher exact contingency tests, and Benjamini-Hochberg False Discovery Rate (FDR) corrections.
1. Two-Sample Testing: t-test vs. Wilcoxon Rank-Sum
# Parametric: Welch Two-Sample t-test
t_res <- t.test(treated_group, control_group)
cat(sprintf("Welch t-test: t = %.2f | p = %.4e\n", t_res$statistic, t_res$p.value))
# Non-Parametric: Wilcoxon / Mann-Whitney U test (Distribution-free)
w_res <- wilcox.test(treated_group, control_group)
cat(sprintf("Wilcoxon: W = %.1f | p = %.4e\n", w_res$statistic, w_res$p.value))2. Fisher's Exact Test for Mutation Enrichment
Testing whether TP53 somatic mutations are significantly enriched in drug non-responders:
contingency <- matrix(c(18, 6, 4, 22), nrow = 2,
dimnames = list(TP53 = c("Mut", "WT"), Response = c("Res", "NonRes")))
fisher_res <- fisher.test(contingency)
cat(sprintf("Fisher p-value: %.4e | Odds Ratio: %.2f\n", fisher_res$p.value, fisher_res$estimate))3. Multiple Testing Correction: Benjamini-Hochberg FDR
Adjusting genome-wide p-values to control the False Discovery Rate:
# Correcting 10,000 statistical tests
bh_fdr <- p.adjust(raw_pvalues, method = "BH")
cat("Significant Genes (FDR < 0.05):", sum(bh_fdr < 0.05), "\n")