[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EEEWQS06H2RA9R136NGHBN":3,"skill-same:01M7EEEWQS06H2RA9R136NGHBN":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7EEEWQS06H2RA9R136NGHBN","bio-methylation-methylkit",null,"Imports Bismark coverage or cytosine-report files into the methylKit object model, then runs the import-to-results spine - filterByCoverage, normalizeCoverage, unite\u002Fdestrand, calculateDiffMeth, getMethylDiff - for both per-CpG (DMC) and fixed-tile (DMR) differential methylation, plus tileMethylCounts, PCA\u002Fcorrelation\u002Fclustering QC, and assocComp\u002FremoveComp batch handling. Covers the silent default traps that shape the false-positive rate: overdispersion='none' does no correction while 'MN' forces the F-test (ignoring test='Chisq'), adjust defaults to SLIM not BH, getMethylDiff defaults difference=25\u002Fqvalue=0.01, cov.bases=0 admits single-CpG tiles, and pool destroys biological replication. Use when importing bisulfite count tables, filtering\u002Fnormalizing\u002Funiting methylation samples, running methylKit differential testing, or QC-ing methylomes. For per-site test-choice (count vs continuous) see differential-cpg-testing; for selection-aware region FDR (dmrseq\u002FDSS) see dmr-detection.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-methylation-methylkit\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-methylation-methylkit\ndescription: >-\n  Imports Bismark coverage or cytosine-report files into the methylKit object model, then runs the import-to-results spine - filterByCoverage, normalizeCoverage, unite\u002Fdestrand, calculateDiffMeth, getMethylDiff - for both per-CpG (DMC) and fixed-tile (DMR) differential methylation, plus tileMethylCounts, PCA\u002Fcorrelation\u002Fclustering QC, and assocComp\u002FremoveComp batch handling. Covers the silent default traps that shape the false-positive rate: overdispersion='none' does no correction while 'MN' forces the F-test (ignoring test='Chisq'), adjust defaults to SLIM not BH, getMethylDiff defaults difference=25\u002Fqvalue=0.01, cov.bases=0 admits single-CpG tiles, and pool destroys biological replication. Use when importing bisulfite count tables, filtering\u002Fnormalizing\u002Funiting methylation samples, running methylKit differential testing, or QC-ing methylomes. For per-site test-choice (count vs continuous) see differential-cpg-testing; for selection-aware region FDR (dmrseq\u002FDSS) see dmr-detection.\ntool_type: r\nprimary_tool: methylKit\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"methylation-analysis\u002Fmethylkit-analysis\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n## Version Compatibility\n\nReference examples tested with: methylKit 1.28+, GenomicRanges 1.54+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- R: `packageVersion('\u003Cpkg>')` then `?function_name` to verify parameters\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\nThe `assembly=` string (e.g. `hg38`) is metadata only - methylKit never checks it. The genome build is real elsewhere: coordinates must match the alignment genome, and annotation packages (`TxDb.Hsapiens.UCSC.hg38.knownGene`, annotatr `build_annotations(genome='hg38')`) are genome-build-specific. methylKit's `overdispersion`, `test`, and `adjust` defaults have shifted across Bioconductor releases - run `?calculateDiffMeth` on the installed build before trusting any default.\n\n# methylKit Analysis\n\n**\"Analyze methylation across my samples\"** -> Import per-cytosine counts into a methylRawList, then filter, normalize, unite, and test - because each of those steps is a modeling decision that sets which CpGs survive and how many false positives the test emits, not boilerplate.\n- R: `methRead(pipeline='bismarkCoverage')` -> `filterByCoverage()` -> `normalizeCoverage()` -> `unite(destrand=)` -> `calculateDiffMeth(overdispersion='MN')` -> `getMethylDiff()`\n\nScope: the methylKit OBJECT MODEL and the short-read bisulfite import-to-results workflow, for BOTH per-CpG (DMC) and fixed-tile (DMR) results. Which per-site test to use (count vs continuous, beta vs M) -> differential-cpg-testing. Selection-aware region callers (dmrseq\u002FDSS\u002Fmetilene) and region FDR -> dmr-detection. Long-read MM\u002FML modBAM input -> long-read-sequencing\u002Fnanopore-methylation (its counts pipe back into this object model).\n\n## The Single Most Important Modern Insight -- The Object Model Is the Analysis\n\nCoverage filtering, normalization, destranding, and the overdispersion model are not setup before the \"real\" test - they ARE the test. Each silently changes which CpGs exist and what the p-value means, and methylKit's defaults are tuned for nothing in particular. Three corollaries every misuse violates:\n\n1. **The defaults offer no protection.** `calculateDiffMeth` defaults to `overdispersion='none'` - a plain logistic LRT that assumes binomial-only variance and over-calls under biological replication. Two healthy replicates differ at a CpG far more than coin-flip sampling predicts; only `overdispersion='MN'` adds the between-replicate (beta-binomial) layer. The paper discusses overdispersion; the function does not apply it unless told.\n2. **The knobs interact and several are silent.** `overdispersion='MN'` automatically switches to the F-test, so a passed `test='Chisq'` is ignored with no warning. `adjust` defaults to SLIM (methylKit's own q-method), not BH, so counts are not comparable to a DSS\u002Flimma BH analysis. `tileMethylCounts(cov.bases=0)` lets a one-CpG window become a \"region.\" None of these throw an error; the result just quietly changes.\n3. **Coverage is the substrate, not the answer.** A single CpG's methylation percentage is a count ratio; below ~10x it is a coin flip. Filtering the low tail (noise) and the high tail (PCR\u002Frepeat artifacts) before testing decides the result more than the test does.\n\nOrganize the workflow around defending these, not around calling functions in order.\n\n## The Import-to-Results Spine\n\nRun these in order. Skipping or reordering them changes the result silently.\n\n### 1. Import: methRead with the pipeline matching the input\n\n**Goal:** Load per-cytosine counts into a methylRawList, choosing the parser that matches the Bismark output format.\n\n**Approach:** `pipeline='bismarkCoverage'` reads `.cov`\u002F`.cov.gz` (chr\u002Fstart\u002Fend\u002F%meth\u002FnumC\u002FnumT - NO strand, so destranding is limited); `pipeline='bismarkCytosineReport'` reads the CX\u002FCpG report (carries strand + context, enables proper destranding). `treatment` is an integer vector (0\u002F1, or 0\u002F1\u002F2 for multi-group). `context='CpG'` only - never destrand CHG\u002FCHH downstream.\n\n```r\nlibrary(methylKit)\nfile_list \u003C- list('ctrl1.cov.gz', 'ctrl2.cov.gz', 'treat1.cov.gz', 'treat2.cov.gz')\nsample_ids \u003C- list('ctrl_1', 'ctrl_2', 'treat_1', 'treat_2')\nmeth_obj \u003C- methRead(file_list, sample.id=sample_ids, treatment=c(0,0,1,1),\n                     assembly='hg38', context='CpG', pipeline='bismarkCoverage')\n# dbtype='tabix', save.db=TRUE gives disk-backed methylRawDB objects for large WGBS\n```\n\n### 2. Filter and normalize BEFORE uniting (and before tiling)\n\n**Goal:** Drop unreliable and artifactual CpGs per sample, then remove library-size-driven coverage differences so a deeper sample does not look more \"confident.\"\n\n**Approach:** `filterByCoverage(lo.count, hi.perc)` removes the noisy low tail and the artifactual high tail; `normalizeCoverage` scales coverage between samples. Both are per-sample and must precede `unite` and `tileMethylCounts`.\n\n```r\nmeth_filt \u003C- filterByCoverage(meth_obj, lo.count=10, lo.perc=NULL, hi.count=NULL, hi.perc=99.9)\nmeth_norm \u003C- normalizeCoverage(meth_filt, method='median')\n```\n\n### 3. Unite: destrand only for CpG, only with strand info\n\n**Goal:** Build the per-base table of CpGs covered across samples for testing.\n\n**Approach:** `unite` keeps CpGs covered in ALL samples; `min.per.group=2L` relaxes that to >=2 per group (keeps more sites, allows missingness). `destrand=TRUE` merges the + and - strand counts of a CpG dyad - valid ONLY for symmetric CpG context AND only meaningful when strand is present (cytosine report). On `.cov` (bismarkCoverage, no strand) destranding is limited; on CHG\u002FCHH it is wrong.\n\n```r\nmeth_united \u003C- unite(meth_norm, destrand=TRUE)            # destrand only if strand info present\nmeth_united \u003C- unite(meth_norm, min.per.group=2L)         # allow missingness across replicates\n```\n\n### 4. QC the united object before testing\n\n**Goal:** Confirm samples cluster by biology, not by batch, before believing any DMC.\n\n**Approach:** Run correlation, PCA, and clustering on the united (% methylation) object. A control clustering with the treated group, or PC1 tracking sequencing batch, means the contrast is confounded.\n\n```r\ngetCorrelation(meth_united, plot=TRUE)\nPCASamples(meth_united)\nclusterSamples(meth_united, dist='correlation', method='ward.D', plot=TRUE)\n```\n\n### 5. Test: calculateDiffMeth with overdispersion correction\n\n**Goal:** Test each CpG for a group difference using a model that accounts for between-replicate overdispersion.\n\n**Approach:** With replicates, set `overdispersion='MN'`, which automatically uses the F-test (the `test=` argument is then ignored - passing `test='Chisq'` alongside MN does not produce a chi-square test). Set `adjust='BH'` if the q-values must be comparable to other tools; the default SLIM is methylKit-specific. `getMethylDiff` filters by effect size AND q.\n\n```r\ndiff_meth \u003C- calculateDiffMeth(meth_united, overdispersion='MN', adjust='BH', mc.cores=4)\ndmcs \u003C- getMethylDiff(diff_meth, difference=25, qvalue=0.01)             # all DMCs\ndmcs_hyper \u003C- getMethylDiff(diff_meth, difference=25, qvalue=0.01, type='hyper')\n# positive meth.diff = hyper in the higher-treatment group\n```\n\n## Tile-Based Regions (a fast screen, not selection-corrected inference)\n\n**Goal:** Aggregate CpGs into fixed windows for a quick region-level scan.\n\n**Approach:** Tile AFTER filter\u002Fnormalize, raise `cov.bases` so a window needs real CpG support, then flow through the same unite -> calculateDiffMeth -> getMethylDiff path. The same `getMethylDiff` returns DMCs on a per-base object and (window) DMRs on a tiled object.\n\n```r\ntiles \u003C- tileMethylCounts(meth_norm, win.size=1000, step.size=1000, cov.bases=3)  # cov.bases>=3\ntiles_united \u003C- unite(tiles, destrand=FALSE)              # tiles are not strand objects\ndiff_tiles \u003C- calculateDiffMeth(tiles_united, overdispersion='MN', adjust='BH', mc.cores=4)\ndmrs \u003C- getMethylDiff(diff_tiles, difference=25, qvalue=0.01)\n```\n\nThe per-tile q is a per-test SLIM\u002FBH value: it does NOT model correlation between tiles and is NOT corrected for the region-selection step. Fixed windows also split or merge true DMRs at arbitrary boundaries. Treat methylKit tiles as a defensible screen; for rigorous region FDR (a permutation null that survives region selection) go to dmr-detection (dmrseq).\n\n## Batch, Multi-Group, and the Single-Factor Limit\n\nmethylKit's `calculateDiffMeth` is a single-factor 2-group test. For known batch, remove the associated principal components before testing; for >2 groups, subset to pairwise contrasts. Complex designs (covariates, multi-factor) exceed what methylKit models - move to dmr-detection (DSS multiFactor \u002F dmrseq covariates) or a continuous limma-on-M path (differential-cpg-testing).\n\n```r\nsample_anno \u003C- data.frame(batch=c('a','a','b','b'))\nas_comp \u003C- assocComp(meth_united, sample_anno)            # which PCs track the covariate\nmeth_corrected \u003C- removeComp(meth_united, comp=1)         # drop the batch PC, then test\nmeth_AB \u003C- reorganize(meth_united, sample.ids=c('ctrl_1','ctrl_2','treat_1','treat_2'),\n                      treatment=c(0,0,1,1))               # subset\u002Frelabel for a pairwise contrast\n```\n\n`pool(meth_united, sample.ids=...)` sums replicate counts into one pseudo-sample per group. This DESTROYS biological replication - the test then has no within-group variance estimate and its p-values are meaningless for inference. Use it only for no-replicate exploratory visualization, never for the reported test.\n\n## Per-Method Failure Modes\n\n### Overdispersion left at the default\n**Trigger:** `calculateDiffMeth` with replicates and no `overdispersion=` argument. **Mechanism:** the default `'none'` is a binomial-only logistic LRT that ignores between-replicate variance. **Symptom:** implausibly many significant CpGs; q-values far smaller than a beta-binomial tool gives on the same data. **Fix:** `overdispersion='MN'` (which uses the F-test) whenever replicates exist.\n\n### MN plus test='Chisq'\n**Trigger:** passing both `overdispersion='MN'` and `test='Chisq'`. **Mechanism:** MN forces the F-test; `test=` is silently ignored. **Symptom:** the reported \"chi-square test\" was never run. **Fix:** drop `test=` when using MN; `test=` is honored only with `overdispersion='none'`.\n\n### SLIM read as BH\n**Trigger:** comparing methylKit q-value counts to a DSS\u002Flimma BH analysis. **Mechanism:** `adjust` defaults to SLIM, methylKit's own sliding-linear-model q-method. **Symptom:** DMC counts disagree with another tool's BH results at the \"same\" q. **Fix:** set `adjust='BH'` for cross-tool comparability and state the method used.\n\n### cov.bases=0 tiles\n**Trigger:** `tileMethylCounts` at the default `cov.bases=0`. **Mechanism:** a window with one covered CpG becomes a \"region.\" **Symptom:** thousands of single-CpG \"DMRs,\" many noisy. **Fix:** raise `cov.bases` to >=3.\n\n### Tiling or testing the raw object\n**Trigger:** `tileMethylCounts(meth_obj, ...)` or uniting before filtering\u002Fnormalizing. **Mechanism:** low-coverage and library-size artifacts propagate into the tiles and the test. **Symptom:** artifactual regions; deeper samples look hyper-confident. **Fix:** `filterByCoverage` then `normalizeCoverage` BEFORE tiling\u002Funiting.\n\n### Destranding the wrong context or input\n**Trigger:** `unite(destrand=TRUE)` on `.cov` input or on CHG\u002FCHH context. **Mechanism:** `.cov` carries no strand; non-CpG dyads are not symmetric. **Symptom:** double-counting or wrong merges. **Fix:** destrand CpG only, ideally from the cytosine report.\n\n### pool() then test\n**Trigger:** `pool()` followed by `calculateDiffMeth`. **Mechanism:** pooling removes within-group variance. **Symptom:** tiny p-values with no biological meaning. **Fix:** never pool for the reported test; keep replicates separate.\n\n## Quantitative Thresholds\n\n| Threshold | Source | Rationale |\n|-----------|--------|-----------|\n| `lo.count` = 10 | convention (methylKit tutorial) | below ~10x a single-CpG percentage is a coin flip; not a derived value |\n| `hi.perc` = 99.9 | convention | drops the top 0.1% coverage (PCR\u002Frepeat artifacts) |\n| `overdispersion` = 'MN' with replicates | Akalin 2012 *Genome Biol* 13:R87 | adds the beta-binomial between-replicate layer; default 'none' over-calls |\n| `adjust` = 'BH' (default SLIM) | Akalin 2012 *Genome Biol* 13:R87 | BH for comparability; SLIM is methylKit-specific |\n| `getMethylDiff` difference=25, qvalue=0.01 | methylKit defaults | 25% is tutorial convention, NOT derived; justify per feature\u002Fcoverage\u002Fpurity and report it |\n| `tileMethylCounts` cov.bases >= 3 | nuance | default 0 admits single-CpG tiles; require real CpG support |\n| `win.size`=`step.size`=1000 (default) | methylKit defaults | `step \u003C win` gives overlapping (sliding) tiles |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Implausibly many DMCs | `overdispersion='none'` under replication | set `overdispersion='MN'` |\n| Reported chi-square never ran | `test='Chisq'` with MN | MN forces F; drop `test=` |\n| Counts disagree with another tool at same q | default `adjust='SLIM'` | set `adjust='BH'`, state the method |\n| Thousands of single-CpG \"regions\" | `cov.bases=0` | raise `cov.bases` to >=3 |\n| Destrand error \u002F double counts | destrand on `.cov` or non-CpG | destrand CpG only, from cytosine report |\n| Meaningless tiny p-values | `pool()` before testing | keep replicates; never pool for inference |\n| Deeper sample looks more confident | no `normalizeCoverage` | normalize before unite\u002Ftest |\n\n## References\n\n- Akalin A, Kormaksson M, Li S, Garrett-Bakelman FE, Figueroa ME, Melnick A, Mason CE. 2012. methylKit: a comprehensive R package for the analysis of genome-wide DNA methylation profiles. *Genome Biol* 13:R87.\n- Krueger F, Andrews SR. 2011. Bismark: a flexible aligner and methylation caller for Bisulfite-Seq applications. *Bioinformatics* 27:1571-1572.\n- Robinson MD, Kahraman A, Law CW, Lindsay H, Nowicka M, Weber LM, Zhou X. 2014. Statistical methods for detecting differentially methylated loci and regions. *Front Genet* 5:324.\n\n## Related Skills\n\n- methylation-calling - Produces the coverage\u002Fcytosine reports read here\n- differential-cpg-testing - Per-site statistical model choice (count vs continuous)\n- dmr-detection - Selection-aware region callers (dmrseq\u002FDSS) beyond methylKit tiles\n- pathway-analysis\u002Fgo-enrichment - Functional annotation of differentially methylated genes\n- long-read-sequencing\u002Fnanopore-methylation - Long-read MM\u002FML calling; pipe counts into this object model\n- workflows\u002Fmethylation-pipeline - End-to-end bisulfite pipeline\n","## Version Compatibility\n\nReference examples tested with: methylKit 1.28+, GenomicRanges 1.54+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- R: `packageVersion('\u003Cpkg>')` then `?function_name` to verify parameters\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\nThe `assembly=` string (e.g. `hg38`) is metadata only - methylKit never checks it. The genome build is real elsewhere: coordinates must match the alignment genome, and annotation packages (`TxDb.Hsapiens.UCSC.hg38.knownGene`, annotatr `build_annotations(genome='hg38')`) are genome-build-specific. methylKit's `overdispersion`, `test`, and `adjust` defaults have shifted across Bioconductor releases - run `?calculateDiffMeth` on the installed build before trusting any default.\n\n# methylKit Analysis\n\n**\"Analyze methylation across my samples\"** -> Import per-cytosine counts into a methylRawList, then filter, normalize, unite, and test - because each of those steps is a modeling decision that sets which CpGs survive and how many false positives the test emits, not boilerplate.\n- R: `methRead(pipeline='bismarkCoverage')` -> `filterByCoverage()` -> `normalizeCoverage()` -> `unite(destrand=)` -> `calculateDiffMeth(overdispersion='MN')` -> `getMethylDiff()`\n\nScope: the methylKit OBJECT MODEL and the short-read bisulfite import-to-results workflow, for BOTH per-CpG (DMC) and fixed-tile (DMR) results. Which per-site test to use (count vs continuous, beta vs M) -> differential-cpg-testing. Selection-aware region callers (dmrseq\u002FDSS\u002Fmetilene) and region FDR -> dmr-detection. Long-read MM\u002FML modBAM input -> long-read-sequencing\u002Fnanopore-methylation (its counts pipe back into this object model).\n\n## The Single Most Important Modern Insight -- The Object Model Is the Analysis\n\nCoverage filtering, normalization, destranding, and the overdispersion model are not setup before the \"real\" test - they ARE the test. Each silently changes which CpGs exist and what the p-value means, and methylKit's defaults are tuned for nothing in particular. Three corollaries every misuse violates:\n\n1. **The defaults offer no protection.** `calculateDiffMeth` defaults to `overdispersion='none'` - a plain logistic LRT that assumes binomial-only variance and over-calls under biological replication. Two healthy replicates differ at a CpG far more than coin-flip sampling predicts; only `overdispersion='MN'` adds the between-replicate (beta-binomial) layer. The paper discusses overdispersion; the function does not apply it unless told.\n2. **The knobs interact and several are silent.** `overdispersion='MN'` automatically switches to the F-test, so a passed `test='Chisq'` is ignored with no warning. `adjust` defaults to SLIM (methylKit's own q-method), not BH, so counts are not comparable to a DSS\u002Flimma BH analysis. `tileMethylCounts(cov.bases=0)` lets a one-CpG window become a \"region.\" None of these throw an error; the result just quietly changes.\n3. **Coverage is the substrate, not the answer.** A single CpG's methylation percentage is a count ratio; below ~10x it is a coin flip. Filtering the low tail (noise) and the high tail (PCR\u002Frepeat artifacts) before testing decides the result more than the test does.\n\nOrganize the workflow around defending these, not around calling functions in order.\n\n## The Import-to-Results Spine\n\nRun these in order. Skipping or reordering them changes the result silently.\n\n### 1. Import: methRead with the pipeline matching the input\n\n**Goal:** Load per-cytosine counts into a methylRawList, choosing the parser that matches the Bismark output format.\n\n**Approach:** `pipeline='bismarkCoverage'` reads `.cov`\u002F`.cov.gz` (chr\u002Fstart\u002Fend\u002F%meth\u002FnumC\u002FnumT - NO strand, so destranding is limited); `pipeline='bismarkCytosineReport'` reads the CX\u002FCpG report (carries strand + context, enables proper destranding). `treatment` is an integer vector (0\u002F1, or 0\u002F1\u002F2 for multi-group). `context='CpG'` only - never destrand CHG\u002FCHH downstream.\n\n```r\nlibrary(methylKit)\nfile_list \u003C- list('ctrl1.cov.gz', 'ctrl2.cov.gz', 'treat1.cov.gz', 'treat2.cov.gz')\nsample_ids \u003C- list('ctrl_1', 'ctrl_2', 'treat_1', 'treat_2')\nmeth_obj \u003C- methRead(file_list, sample.id=sample_ids, treatment=c(0,0,1,1),\n                     assembly='hg38', context='CpG', pipeline='bismarkCoverage')\n# dbtype='tabix', save.db=TRUE gives disk-backed methylRawDB objects for large WGBS\n```\n\n### 2. Filter and normalize BEFORE uniting (and before tiling)\n\n**Goal:** Drop unreliable and artifactual CpGs per sample, then remove library-size-driven coverage differences so a deeper sample does not look more \"confident.\"\n\n**Approach:** `filterByCoverage(lo.count, hi.perc)` removes the noisy low tail and the artifactual high tail; `normalizeCoverage` scales coverage between samples. Both are per-sample and must precede `unite` and `tileMethylCounts`.\n\n```r\nmeth_filt \u003C- filterByCoverage(meth_obj, lo.count=10, lo.perc=NULL, hi.count=NULL, hi.perc=99.9)\nmeth_norm \u003C- normalizeCoverage(meth_filt, method='median')\n```\n\n### 3. Unite: destrand only for CpG, only with strand info\n\n**Goal:** Build the per-base table of CpGs covered across samples for testing.\n\n**Approach:** `unite` keeps CpGs covered in ALL samples; `min.per.group=2L` relaxes that to >=2 per group (keeps more sites, allows missingness). `destrand=TRUE` merges the + and - strand counts of a CpG dyad - valid ONLY for symmetric CpG context AND only meaningful when strand is present (cytosine report). On `.cov` (bismarkCoverage, no strand) destranding is limited; on CHG\u002FCHH it is wrong.\n\n```r\nmeth_united \u003C- unite(meth_norm, destrand=TRUE)            # destrand only if strand info present\nmeth_united \u003C- unite(meth_norm, min.per.group=2L)         # allow missingness across replicates\n```\n\n### 4. QC the united object before testing\n\n**Goal:** Confirm samples cluster by biology, not by batch, before believing any DMC.\n\n**Approach:** Run correlation, PCA, and clustering on the united (% methylation) object. A control clustering with the treated group, or PC1 tracking sequencing batch, means the contrast is confounded.\n\n```r\ngetCorrelation(meth_united, plot=TRUE)\nPCASamples(meth_united)\nclusterSamples(meth_united, dist='correlation', method='ward.D', plot=TRUE)\n```\n\n### 5. Test: calculateDiffMeth with overdispersion correction\n\n**Goal:** Test each CpG for a group difference using a model that accounts for between-replicate overdispersion.\n\n**Approach:** With replicates, set `overdispersion='MN'`, which automatically uses the F-test (the `test=` argument is then ignored - passing `test='Chisq'` alongside MN does not produce a chi-square test). Set `adjust='BH'` if the q-values must be comparable to other tools; the default SLIM is methylKit-specific. `getMethylDiff` filters by effect size AND q.\n\n```r\ndiff_meth \u003C- calculateDiffMeth(meth_united, overdispersion='MN', adjust='BH', mc.cores=4)\ndmcs \u003C- getMethylDiff(diff_meth, difference=25, qvalue=0.01)             # all DMCs\ndmcs_hyper \u003C- getMethylDiff(diff_meth, difference=25, qvalue=0.01, type='hyper')\n# positive meth.diff = hyper in the higher-treatment group\n```\n\n## Tile-Based Regions (a fast screen, not selection-corrected inference)\n\n**Goal:** Aggregate CpGs into fixed windows for a quick region-level scan.\n\n**Approach:** Tile AFTER filter\u002Fnormalize, raise `cov.bases` so a window needs real CpG support, then flow through the same unite -> calculateDiffMeth -> getMethylDiff path. The same `getMethylDiff` returns DMCs on a per-base object and (window) DMRs on a tiled object.\n\n```r\ntiles \u003C- tileMethylCounts(meth_norm, win.size=1000, step.size=1000, cov.bases=3)  # cov.bases>=3\ntiles_united \u003C- unite(tiles, destrand=FALSE)              # tiles are not strand objects\ndiff_tiles \u003C- calculateDiffMeth(tiles_united, overdispersion='MN', adjust='BH', mc.cores=4)\ndmrs \u003C- getMethylDiff(diff_tiles, difference=25, qvalue=0.01)\n```\n\nThe per-tile q is a per-test SLIM\u002FBH value: it does NOT model correlation between tiles and is NOT corrected for the region-selection step. Fixed windows also split or merge true DMRs at arbitrary boundaries. Treat methylKit tiles as a defensible screen; for rigorous region FDR (a permutation null that survives region selection) go to dmr-detection (dmrseq).\n\n## Batch, Multi-Group, and the Single-Factor Limit\n\nmethylKit's `calculateDiffMeth` is a single-factor 2-group test. For known batch, remove the associated principal components before testing; for >2 groups, subset to pairwise contrasts. Complex designs (covariates, multi-factor) exceed what methylKit models - move to dmr-detection (DSS multiFactor \u002F dmrseq covariates) or a continuous limma-on-M path (differential-cpg-testing).\n\n```r\nsample_anno \u003C- data.frame(batch=c('a','a','b','b'))\nas_comp \u003C- assocComp(meth_united, sample_anno)            # which PCs track the covariate\nmeth_corrected \u003C- removeComp(meth_united, comp=1)         # drop the batch PC, then test\nmeth_AB \u003C- reorganize(meth_united, sample.ids=c('ctrl_1','ctrl_2','treat_1','treat_2'),\n                      treatment=c(0,0,1,1))               # subset\u002Frelabel for a pairwise contrast\n```\n\n`pool(meth_united, sample.ids=...)` sums replicate counts into one pseudo-sample per group. This DESTROYS biological replication - the test then has no within-group variance estimate and its p-values are meaningless for inference. Use it only for no-replicate exploratory visualization, never for the reported test.\n\n## Per-Method Failure Modes\n\n### Overdispersion left at the default\n**Trigger:** `calculateDiffMeth` with replicates and no `overdispersion=` argument. **Mechanism:** the default `'none'` is a binomial-only logistic LRT that ignores between-replicate variance. **Symptom:** implausibly many significant CpGs; q-values far smaller than a beta-binomial tool gives on the same data. **Fix:** `overdispersion='MN'` (which uses the F-test) whenever replicates exist.\n\n### MN plus test='Chisq'\n**Trigger:** passing both `overdispersion='MN'` and `test='Chisq'`. **Mechanism:** MN forces the F-test; `test=` is silently ignored. **Symptom:** the reported \"chi-square test\" was never run. **Fix:** drop `test=` when using MN; `test=` is honored only with `overdispersion='none'`.\n\n### SLIM read as BH\n**Trigger:** comparing methylKit q-value counts to a DSS\u002Flimma BH analysis. **Mechanism:** `adjust` defaults to SLIM, methylKit's own sliding-linear-model q-method. **Symptom:** DMC counts disagree with another tool's BH results at the \"same\" q. **Fix:** set `adjust='BH'` for cross-tool comparability and state the method used.\n\n### cov.bases=0 tiles\n**Trigger:** `tileMethylCounts` at the default `cov.bases=0`. **Mechanism:** a window with one covered CpG becomes a \"region.\" **Symptom:** thousands of single-CpG \"DMRs,\" many noisy. **Fix:** raise `cov.bases` to >=3.\n\n### Tiling or testing the raw object\n**Trigger:** `tileMethylCounts(meth_obj, ...)` or uniting before filtering\u002Fnormalizing. **Mechanism:** low-coverage and library-size artifacts propagate into the tiles and the test. **Symptom:** artifactual regions; deeper samples look hyper-confident. **Fix:** `filterByCoverage` then `normalizeCoverage` BEFORE tiling\u002Funiting.\n\n### Destranding the wrong context or input\n**Trigger:** `unite(destrand=TRUE)` on `.cov` input or on CHG\u002FCHH context. **Mechanism:** `.cov` carries no strand; non-CpG dyads are not symmetric. **Symptom:** double-counting or wrong merges. **Fix:** destrand CpG only, ideally from the cytosine report.\n\n### pool() then test\n**Trigger:** `pool()` followed by `calculateDiffMeth`. **Mechanism:** pooling removes within-group variance. **Symptom:** tiny p-values with no biological meaning. **Fix:** never pool for the reported test; keep replicates separate.\n\n## Quantitative Thresholds\n\n| Threshold | Source | Rationale |\n|-----------|--------|-----------|\n| `lo.count` = 10 | convention (methylKit tutorial) | below ~10x a single-CpG percentage is a coin flip; not a derived value |\n| `hi.perc` = 99.9 | convention | drops the top 0.1% coverage (PCR\u002Frepeat artifacts) |\n| `overdispersion` = 'MN' with replicates | Akalin 2012 *Genome Biol* 13:R87 | adds the beta-binomial between-replicate layer; default 'none' over-calls |\n| `adjust` = 'BH' (default SLIM) | Akalin 2012 *Genome Biol* 13:R87 | BH for comparability; SLIM is methylKit-specific |\n| `getMethylDiff` difference=25, qvalue=0.01 | methylKit defaults | 25% is tutorial convention, NOT derived; justify per feature\u002Fcoverage\u002Fpurity and report it |\n| `tileMethylCounts` cov.bases >= 3 | nuance | default 0 admits single-CpG tiles; require real CpG support |\n| `win.size`=`step.size`=1000 (default) | methylKit defaults | `step \u003C win` gives overlapping (sliding) tiles |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Implausibly many DMCs | `overdispersion='none'` under replication | set `overdispersion='MN'` |\n| Reported chi-square never ran | `test='Chisq'` with MN | MN forces F; drop `test=` |\n| Counts disagree with another tool at same q | default `adjust='SLIM'` | set `adjust='BH'`, state the method |\n| Thousands of single-CpG \"regions\" | `cov.bases=0` | raise `cov.bases` to >=3 |\n| Destrand error \u002F double counts | destrand on `.cov` or non-CpG | destrand CpG only, from cytosine report |\n| Meaningless tiny p-values | `pool()` before testing | keep replicates; never pool for inference |\n| Deeper sample looks more confident | no `normalizeCoverage` | normalize before unite\u002Ftest |\n\n## References\n\n- Akalin A, Kormaksson M, Li S, Garrett-Bakelman FE, Figueroa ME, Melnick A, Mason CE. 2012. methylKit: a comprehensive R package for the analysis of genome-wide DNA methylation profiles. *Genome Biol* 13:R87.\n- Krueger F, Andrews SR. 2011. Bismark: a flexible aligner and methylation caller for Bisulfite-Seq applications. *Bioinformatics* 27:1571-1572.\n- Robinson MD, Kahraman A, Law CW, Lindsay H, Nowicka M, Weber LM, Zhou X. 2014. Statistical methods for detecting differentially methylated loci and regions. *Front Genet* 5:324.\n\n## Related Skills\n\n- methylation-calling - Produces the coverage\u002Fcytosine reports read here\n- differential-cpg-testing - Per-site statistical model choice (count vs continuous)\n- dmr-detection - Selection-aware region callers (dmrseq\u002FDSS) beyond methylKit tiles\n- pathway-analysis\u002Fgo-enrichment - Functional annotation of differentially methylated genes\n- long-read-sequencing\u002Fnanopore-methylation - Long-read MM\u002FML calling; pipe counts into this object model\n- workflows\u002Fmethylation-pipeline - End-to-end bisulfite pipeline\n",{"name":5,"source":24,"license":15,"tool_type":25,"description":7,"imported_at":26,"source_path":27,"primary_tool":28,"source_repository":29},"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills","r","2026-09-20","methylation-analysis\u002Fmethylkit-analysis\u002FSKILL.md","methylKit","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fbiology\u002Fbio-methylation-methylkit","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-methylation-methylkit",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-methylation-methylkit",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-methylation-methylkit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-methylation-methylkit\u002FSKILL.md",true,[50,56],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Fmethylkit_analysis.R","OTHER","其他",3075,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-methylation-methylkit\u002Fexamples\u002Fmethylkit_analysis.R",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"usage-guide.md","REFERENCE","参考文档",5963,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-methylation-methylkit\u002Fusage-guide.md",[63,71,78,85,92,99],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":70},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":70},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":70},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":70},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":70},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":70},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]