8: Statistical Hypothesis Testing for Biologists
Tested Stacks:
GATK 4.6.1
Samtools 1.21
Nextflow 24.10
Seurat v5.1
Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 8 of 13
0% Course Completed
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")
⚠️
Common Pitfalls & Troubleshooting Checklist
- Java Heap Exhaustion (GATK / Picard): If processes terminate with
java.lang.OutOfMemoryError, set your environment variable explicitly:export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp". - Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with
samtools index -@ 4 sample.bam. - Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority:
conda config --set channel_priority strict. - Chromosome Naming Contamination: Always verify whether reference FASTA headers use
chr1or1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.