Skip to content

Add EvolvDx methylation QC subworkflow and supporting modules - #628

Closed
jcjray wants to merge 8 commits into
nf-core:masterfrom
EVolvDx:evolvdx-main
Closed

jcjray wants to merge 8 commits into
nf-core:masterfrom
EVolvDx:evolvdx-main

Conversation

@jcjray

@jcjray jcjray commented Oct 9, 2026

Copy link
Copy Markdown

Description

This PR adds comprehensive methylation QC functionality to nf-core/methylseq through a new EvolvDx subworkflow and supporting modules. The additions enable cohort-level analysis of methylation data including control statistics, read statistics, tiled statistics, and genomic annotations.

Key Changes

New Subworkflow:

  • subworkflows/local/methylqc/main.nf - Orchestrates methylation QC pipeline combining per-sample MethylDackel outputs into cohort-level objects and generating summary statistics

New Processes:

  • COMBINED_METHOBJ - Merges per-sample methylKit files into cohort methylRawList objects
  • COMBINED_HDF5 - Gathers per-sample MethylDackel bedGraph files into single HDF5 file
  • CONTROL_STATS - Calculates mean CpG methylation of spike-in controls (lambda, pUC19)
  • BASIC_READ_STATISTICS - Per-sample CpG depth and methylation statistics
  • TILE_METHYL_COUNTS - Summarizes methylation counts in 1 kb tiles
  • MERGE_TILED_STATS - Merges tiled beta values across samples
  • TWIST_ANNOTATION - Annotates methylation calls with Twist methylome target categories
  • REPEAT_ANNOTATION - Annotates methylation calls with RepeatMasker repeats
  • METH_HISTOGRAM_BY_CHROMOSOME - Per-chromosome CpG counts and methylation percentages
  • MERGE_ANNOTATION_STATS - Aggregates annotation statistics across samples
  • METHYLQC_MULTIQC - Converts methyl_qc outputs into MultiQC custom content
  • BEDTOOLS_INTERSECT_CPG - Intersects alignments with CpG islands
  • BEDTOOLS_PERBASE_GENOMECOV - Per-base coverage reports
  • METHSNSV - Calculates sensitivity/specificity metrics for spike-in controls

Supporting Scripts:

  • Python scripts for statistics generation and data processing
  • R scripts for methylKit object manipulation and annotation
  • Container environment definitions (Dockerfile, conda_environment.yml)

Configuration:

  • EvolvDx-specific profiles and AWS batch configuration
  • Custom genome reference paths
  • Module-specific process configurations

Documentation & Testing:

  • Test samplesheets for NSQCAM529 subsample datasets
  • Example AWS execution script
  • EvolvDx fork documentation (EVOLVDX.md)
  • Updated CHANGELOG.md

Integration Points

  • Integrates with existing nf-core/methylseq MethylDackel outputs
  • Adds optional --run_methylqc parameter to enable the subworkflow
  • Extends nextflow_schema.json with EvolvDx-specific parameters
  • Maintains compatibility with nf-core standards and conventions

Test Plan

The changes include test samplesheets and example scripts for validation. The subworkflow can be tested using the provided test profiles (exo_test) with NSQCAM529 subsample data.

https://claude.ai/code/session_016tFAQKTrNw8mhXkpW3q8Js

jcjray and others added 8 commits October 9, 2026 20:34
Port the EvolvDx QC modules (methylKit/HDF5 merge, control/read/tiled stats,
Twist and repeat annotation, chromosome histograms, CpG-island bedtools,
methsnsv, Picard HS MultiQC), their bin/ scripts, MultiQC headers, container
env definitions, notebooks and test samplesheets from the archived fork.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019uURGxTKSsLgVZ2CwJWMXJ
Add METHYLQC and CPG_COV subworkflows and hook them, METHSNSV and the Picard
HS MultiQC report into workflows/methylseq, all opt-in via --run_methylqc,
--run_cpg_coverage, --run_methsnsv and --run_picardhs_report. Add the evolvdx,
evolvdx_test, evolvdx_aws and evolvdx_aws_500gb profiles, custom S3 genomes,
schema entries, module publish config and EVOLVDX.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019uURGxTKSsLgVZ2CwJWMXJ
Nextflow only puts executable files from bin/ on the task PATH. The
samplesheet is validated by nf-schema in 4.x, so check_samplesheet.py is
no longer used.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019uURGxTKSsLgVZ2CwJWMXJ
- --methyl_kit makes MethylDackel skip bedGraph output, which starved
  METHSNSV, METHYLQC and targeted sequencing. Run a second MethylDackel
  extraction for methylKit files when --run_methylqc is set, and stop
  forcing --methyl_kit in the evolvdx profile.
- Upstream leaves ch_gzi empty, so TARGETED_SEQUENCING never ran
  PICARD_COLLECTHSMETRICS. Pass an empty (meta, path) pair instead.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019uURGxTKSsLgVZ2CwJWMXJ
Found in a local test run of --run_methylqc:

- The versions.yml heredoc in the methyl_qc modules mixed tab and space
  indentation, so the END_VERSIONS terminator never matched and the
  collated versions YAML failed to parse, aborting the whole run.
- BASIC_READ_STATISTICS and METH_HISTOGRAM_BY_CHROMOSOME captured stderr
  (matplotlib cache warnings) into versions.yml, which also broke the YAML.
  METH_HISTOGRAM_BY_CHROMOSOME now reports its pandas version instead of
  calling a script it does not run.
- The input schema dropped the samplesheet group column, so
  make_combined_methobj.R got no treatment vector and methRead failed.
  Carry group into meta, and default to one group when it is absent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Fix methyl_qc steps so --run_methylqc completes
- New METHYLQC_MULTIQC module (bin/methylqc_multiqc.py) converts the
  methyl_qc tables into MultiQC custom content under one "EvolvDx
  methylation QC" section: General Stats columns, CpG read metrics,
  methylation and depth distributions, M-bias, methylation by chromosome,
  Twist annotation and tiled beta values. Wired into the MultiQC inputs
  when --run_methylqc is set.
- meth_histogram_by_chromosome.py: "Methylated CpG Count" no longer
  repeats the CpG count; missing sys import removed with the copied BED
  readers.
- basic_read_statistics.py: metrics now come from read counts. The old
  "% of total reads that are partial" was computed from the bedGraph
  methylation column; replaced by CpGs covered, depth, % low-depth CpGs,
  mean methylation and % partially methylated CpGs.
- merge_tiled_stats.py: reads sample ids from the RDS, leaves uncovered
  tiles empty instead of beta 0, drops the integer strand code from the
  tile id.
- Subworkflow orders cohort inputs by sample id so file and metadata
  lists always match and -resume is stable.
- Modules reformatted with named emits, when: blocks, single container
  string and clean versions.yml.
- env/exo: micromamba 1.5.10 base and a solvable methylkit environment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Clean up methyl_qc and report it in MultiQC
@jcjray
jcjray requested a review from a team as a code owner October 9, 2026 22:35
@jcjray
jcjray requested a review from sateeshperi October 9, 2026 22:35
@jcjray jcjray closed this Oct 9, 2026
@jcjray jcjray reopened this Oct 9, 2026
@jcjray jcjray closed this Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant