Per-CpG (per-site) differential methylation testing - finding individual CpGs (DMC/DMP) that differ between groups. The decisive first choice is the data object: bisulfite sequencing yields integer (methylated, total) counts whose coverage carries precision, so it routes to a beta-binomial / overdispersion-corrected count model (DSS, methylKit); arrays and any continuous beta matrix have no coverage, so they route to limma moderated-t on M-values. Throughout: test on the M-value scale, report effect on the beta scale (delta-beta), and gate hits on the intersection of FDR and effect size. Also covers scanning for differential VARIABILITY (variance, not mean) with DiffVar/iEVORA.
pip install numpy pandas scipy statsmodels
BiocManager::install(c('limma', 'DSS', 'methylKit', 'missMethyl'))
Conceptual prerequisites and notes: - Input from sequencing is per-CpG (methylated, total) counts (Bismark coverage / cytosine report -> methylation-calling). Input from arrays is a beta-value (or M-value) probe matrix. - The minimum-coverage floor must hold in ALL compared samples; one low-coverage sample makes a CpG unusable for a group test. - Cell-type composition is the dominant confounder in bulk-tissue EWAS - have cell-fraction estimates ready to add to the design matrix. - Region-level questions (DMRs) are a separate, complementary step downstream of per-site testing.
Tell your AI agent what you want to do: - "Test each CpG for differential methylation between my case and control groups" - "I have WGBS counts with replicates - use DSS beta-binomial per-site testing" - "Run limma on M-values for my EPIC array, with cell-fraction covariates" - "Recompute delta-beta from raw betas and gate hits on FDR < 0.05 and |delta-beta| > 0.2" - "Scan for differentially variable CpGs, not just mean differences"
"I have per-CpG methylated and total read counts for 3 control and 3 treated WGBS samples. Run a beta-binomial per-site test with DSS, then keep CpGs with FDR < 0.05 and |delta-beta| >= 0.1."
"Use methylKit to test my RRBS replicates per CpG with overdispersion correction and an F-test, then report hyper- and hypo-methylated sites at 25% difference and q < 0.01."
"I have an EPIC array beta matrix for 6 cases and 6 controls plus estimated cell fractions. Convert to M-values, fit limma with trend and robust empirical Bayes, include the cell fractions as covariates, and report adj.P.Val with delta-beta from the raw betas."
"Run a quick continuous per-CpG Welch test on my high-coverage methylation matrix and apply BH FDR - I understand this loses coverage information."
"Filter my differential methylation results to the intersection of FDR < 0.05 and |delta-beta| >= 0.2, and flag the top discovery effect sizes as upward-biased."
"Scan my methylation data for differentially variable CpGs with DiffVar on M-values, and co-report the mean delta-beta for each hit."
calculateDiffMeth defaults to overdispersion="none" (no correction, over-calls with replicates) and adjust="SLIM" (not BH). Set overdispersion="MN", test="F", adjust="BH".meth.diff are NOT delta-beta - recompute delta-beta from raw betas.scipy.stats.ttest_ind defaults to Student's; pass equal_var=False for Welch. statsmodels multipletests defaults to Holm-Sidak; pass method='fdr_bh'.adj.P.Val, not padj (DESeq2) or FDR.