Repository navigation
Fit methylKit DMRs on families, not libraries (methylation.replicate_unit) - #15
Merged
Merged
Conversation
…ries CIBNOR2021_HEAT_RRSS assigns its thermal-tolerance phenotype per family: 12 WGBS libraries from 2 resistant and 2 susceptible families. methylKit fitted the 12 libraries as independent. methylation.replicate_unit names a design-sheet column (e.g. family). DMR_METHYLKIT sums each unit's methylated / unmethylated counts per region and tests the units with McCullagh-Nelder overdispersion and an F test. Each unit must lie in one arm, with at least two per arm. Tested with methylKit 1.36.0 on synthetic Bismark reports (4 families x 3 libraries, family-level variation, 380 null + 20 true regions): libraries as independent called 162/380 null regions significant, families called 0/380. Without replicate_unit the DMR table is identical to before, apart from a new n_replicate_units column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two defects found staging CIBNOR2021_HEAT_RRSS, the first real run:
- COVERAGE_FILTER piped through `zcat`, which on macOS reads only .Z files
("can't stat: x.gz.Z"), so every library would fail. Use `gzip -dc`.
- BISMARK_METHYLATION_EXTRACTOR wrote a --CX report (CpG + CHG + CHH):
~193 M rows per M. gigas library against ~24 M CpGs. The DMR step uses
CpG only, and methylKit reads the whole report before filtering by
context. Drop --CX; the output is now *.CpG_report.txt.gz.
Checked: the fixed filter on a gzipped CpG report keeps exactly the rows an
independent awk count does (408/1,000 at coverage >= 30).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bismark_genome_preparation only recognises .fa/.fasta(.gz); NCBI genomes are .fna, so the first real run (CIBNOR2021_HEAT_RRSS) failed with "does not contain any sequence files in FastA format". Copy the genome in as genome.fa (or genome.fa.gz). Checked with Bismark 0.24.2 on a toy .fna: the bisulfite indexes build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lticore The first real alignment (CIBNOR2021_HEAT_RRSS) exited 60: "Specifying --basename in conjuction with --multicore is currently not supported". Keep --multicore, drop --basename, and rename the read-1-named outputs to the declared names. Checked on toy reads with Bismark 0.24.2: align (--multicore 2), rename, deduplicate_bismark and the CpG-only methylation extractor all run and produce the files the next steps consume. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
methylation.bismark_align_args and methylation.extractor_args are passed through as written and recorded in the manifest (both empty by default, so nothing changes for other studies). Bismark's default --score_min L,0,-0.2 is too strict for M. gigas: on 50k trimmed CIBNOR2021_HEAT_RRSS pairs it mapped 15.5% of pairs uniquely, against 53.9% with L,0,-0.6. The full default-scoring run mapped 13.3-14.0% across 6 libraries. Non-directional mode and -X 1000 made no difference. extractor_args is for M-bias trimming (read 2 shows 5% CHH methylation alone, against 0.8% for read 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
#14 (
CIBNOR2021_HEAT_RRSS) is blocked on this. The study's thermal-tolerance phenotype is assigned per family: 12 WGBS libraries from 2 heat-resistant (RR52, RR59) and 2 heat-susceptible (SS05, SS35) families.DMR_METHYLKITfitted RR vs SS on the 12 libraries as independent, so family-to-family variation would have passed for a phenotype effect. This is the methylation counterpart of--replicate_unitfor RNA-seq (#12).methylation.replicate_unitnames a column inmethylation.design_sheet(a TSV withrun_accessionorsample_id; for CIBNOR, its committedsamplesheet.tsvandfamily).DMR_METHYLKITdoes with it:unite, it sums each unit's methylated / unmethylated counts per region into one pseudo-library.overdispersion = "MN",test = "F"), so the error comes from family-to-family variation.replicate_unitanddesign_sheet. The methylKit QC table recordsn_replicate_units,overdispersionandtest. The DMR table gainsn_replicate_units.replicate_unit, nothing changes. A placeholder design sheet (assets/NO_DESIGN_SHEET) is passed, the same pattern as the RNA-seq viral QC.Also: four defects found by the first real run (second to fourth commits), plus alignment options (fifth)
COVERAGE_FILTERusedzcat, which on macOS only reads.Zfiles (can't stat: x.gz.Z), so every library would have failed. Nowgzip -dc. On a gzipped CpG report it keeps exactly the rows an independent count does.BISMARK_METHYLATION_EXTRACTORwrote a--CXreport (CpG + CHG + CHH). For this genome that's about 193 M rows per library against about 24 M CpGs. The DMR step uses CpG only, and methylKit reads the whole file into memory before filtering by context, so 12 libraries would not fit on a 26 GB machine.--CXis dropped, and the output is now*.CpG_report.txt.gz. Non-CpG methylation would need its own path.BISMARK_GENOME_PREPARATIONskipped the genome (third commit). Bismark only recognises.fa/.fasta, and NCBI genomes are.fna, so the first real run stopped with "does not contain any sequence files in FastA format". The genome is now copied in asgenome.fa. Checked with Bismark 0.24.2: the bisulfite indexes build.BISMARK_ALIGNpassed--basenamewith--multicore(fourth commit). Bismark 0.24 rejects that combination (exit 60).--multicoreis kept,--basenameis dropped, and the read-1-named outputs are renamed. On toy reads, alignment, the rename,deduplicate_bismarkand the CpG-only extractor all ran and produced the files each next step consumes.Also: per-study Bismark options (fifth commit)
The first real alignment mapped only 13.3–14.0% of read pairs uniquely across 6 CIBNOR libraries. A diagnostic on 50,000 trimmed pairs of one library:
--score_min L,0,-0.2--score_min L,0,-0.6--non_directional-X 1000--pbat)methylation.bismark_align_argsandmethylation.extractor_argspass options through as written and are recorded in the manifest. Both are empty by default, so other studies don't change. CIBNOR will set--score_min L,0,-0.6.extractor_argsis for M-bias trimming: read 2 alone shows 5% CHH methylation, against 0.8% for read 1.Testing
The R code is not exercised by CI (see below). I extracted the module's methylKit script and ran it with methylKit 1.36.0 (Bioconductor 3.22, R 4.5.1) on synthetic Bismark cytosine reports: 12 libraries in 4 families × 3, 400 tiles × 25 CpGs. The data have real family-to-family variation and no RR-vs-SS difference, except 20 true regions with +30 points.
replicate_unit = family)meth_diff_cutoff. Documented inworkflows/methylation/README.md.replicate_unit, the DMR table is byte-identical tomain's module on the same input, apart from the new column.pytest -q: 270 passed;ruff check src tests scripts: clean.replicate_unitset reachesDMR_METHYLKITwith the design sheet attached.stub:block, so-stub-runexecutes real tools and the raw path can't be stub-tested. That's existing scaffolding, out of scope here.Checklist
pytest -qandruff check src testspassdocs/page updated (workflows/methylation/README.md)Study branches waiting on this
study/PRJNA690951/CIBNOR2021_HEAT_RRSS(#14): setmethylation.replicate_unit = 'family'andmethylation.design_sheetto itssamplesheet.tsv.🤖 Generated with Claude Code