Skip to content

bam_taps_conversion: optional rastair version 2 caller (use_rastair2) - #13641

Merged
eduard-watchmaker merged 9 commits into
masterfrom
bam-taps-conversion-rastair2
Nov 11, 2026
Merged

eduard-watchmaker merged 9 commits into
masterfrom
bam-taps-conversion-rastair2

Conversation

@eduard-watchmaker

@eduard-watchmaker eduard-watchmaker commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds rastair version 2 as an optional caller in bam_taps_conversion, for nf-core/methylseq's TAPS path, with automatic M-bias trimming. rastair 0.8 stays the default.

Depends on #13678 (new rastair2/mbias; rastair2/call takes its cutoffs). That branch is merged in here, so this diff shows its files until #13678 is merged; please merge #13678 first. nf-core/methylseq (taps_v2, nf-core/methylseq#638) already uses this subworkflow from this branch.

  • New input use_rastair2 (boolean).
    • false runs the existing rastair 0.8 chain unchanged: rastair/mbias → rastair/mbiasparser → rastair/call → rastair/methylkit. The existing test's outputs are byte-identical; its snapshot only gains the new, empty channels.
    • true runs rastair version 2:
      • rastair2/mbias on paired-end samples, to find how many bases to ignore at each read end. Its report needs read-pair flags, so single-end samples are called without trimming.
      • rastair2/call with each sample's cutoffs as --nOT/--nOB (methylation/SNV VCF plus a CpG BED).
      • bcftools/stats on the VCF for MultiQC.
  • New input trims (list). [] uses the M-bias estimate (rastair 0.8: rastair/mbias + rastair/mbiasparser; rastair version 2: rastair2/mbias). [ nOT, nOB ] (each r1_start,r1_end,r2_start,r2_end) uses those bases to ignore for both callers and skips the M-bias steps, so pipelines can expose the trims as parameters. Invalid values are an error. If the estimate can't be made (single-end samples for rastair2, or no reads with CpGs in range), nothing is trimmed.
  • Choosing the contig for M-bias: pipelines should restrict RASTAIR2_MBIAS with --region in ext.args (for example a methylated spike-in like lambda), which also keeps memory down on large genomes. If mbias reports several contigs, the subworkflow uses the longest one.
  • Why trim: on in-house human TAPS data, rastair version 2 gives 0.964 pooled CpG methylation on the fully methylated lambda control without trimming and 0.982 with the mbias cutoffs, matching rastair 0.8 with its M-bias trimming.
  • New outputs: vcf, vcf_tbi, bed, bed_tbi, bcftools_stats, mbias_html and mbias_cutoffs. Whichever caller isn't run leaves its outputs empty.
  • Shared reference: with rastair2, all samples share one reference, whether the pipeline passes it once (value channel) or once per sample (as methylseq does).
  • Interface change: these are new fifth and sixth inputs. No other component in this repo calls bam_taps_conversion; nf-core/methylseq will pass false or its --taps_caller choice.
  • Licence: rastair version 2 is free for non-commercial use only (University of Oxford). The meta.yml says so; pipelines should gate it behind an explicit opt-in.

Tests: the existing rastair 0.8 test; rastair2 with two samples and one reference as a value channel (checks the cutoffs reach call); a paired-end plus a single-end sample (only the paired-end one is trimmed); manual trims for each caller (no M-bias steps, trims reach call); invalid trims fails; and a rastair2 stub with a per-sample reference.

Generated by Claude Code

PR checklist

  • This comment contains a description of changes (with reason).
  • If you've fixed a bug or added code that should be tested, add tests!
  • Follow the naming conventions.
  • Follow the input/output options guidelines.
  • Ensure that the test works with either Docker / Singularity. Conda CI tests can be quite flaky:
    • For subworkflows:
      • nf-core subworkflows test bam_taps_conversion --profile docker (7 tests)
      • nf-core subworkflows test bam_taps_conversion --profile singularity (CI)
      • nf-core subworkflows test bam_taps_conversion --profile conda (CI)

Lint: 0 failures, 0 warnings.

🤖 Generated with Claude Code

New boolean input `use_rastair2`. false keeps the rastair 0.8 chain
(mbias -> mbiasparser -> call -> methylkit) unchanged; true runs
rastair2/call (VCF + CpG BED) and bcftools/stats on the VCF instead. One
reference is shared by all samples, whether it is passed once or per sample.
New outputs: vcf, vcf_tbi, bed, bed_tbi, bcftools_stats (empty when rastair
0.8 runs; the rastair 0.8 outputs are empty when rastair2 runs).

Generated by Claude Code
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@adamrtalbot adamrtalbot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, these are fairly minor nits, tbh:

  • Blocking: use lowercase channel and named closure parameters in the new tests.
  • Not blocking: put a bare assert workflow.success before assertAll(...), and write grouped inputs in test names as [ bam, bai ].
  • The subworkflow logic looks good. combine(...).first() handles both reference styles, and the rastair 0.8 path is unchanged.

While you are here (not blocking):

  • tests/main.nf.test:28-40 also uses Channel.

rastair2/mbias runs `rastair per-read` and `rastair mbias` on paired-end
TAPS reads and writes an HTML M-bias report plus, per contig, the bases to
ignore at each read end (line 1 for --nOT, line 2 for --nOB).

rastair2/call takes an optional cutoffs file in its main input tuple
(`[]` for none) and passes it as --nOT/--nOB.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eduard-watchmaker and others added 4 commits November 10, 2026 11:08
With use_rastair2, paired-end samples now run rastair2/mbias and their
cutoffs are passed to rastair2/call as --nOT/--nOB; single-end samples
are called untrimmed. If mbias reports several contigs, the longest one
is used. New emits: mbias_html, mbias_cutoffs.

Tests: lowercase `channel`, named closure parameters, bare
`assert workflow.success`, and `[ bam, bai ]` in test names (review).
New test with a paired-end and a single-end sample.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eters in tests

Same test conventions as requested on #13641: lowercase `channel`, named
closure parameters, and a bare `assert process.success` before assertAll.
Shorter comment on why rastair2/mbias runs per-read itself.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size/xl and removed size/m labels Nov 10, 2026
@github-actions

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@eduard-watchmaker

Copy link
Copy Markdown
Contributor Author

Thanks! All points applied: bare assert workflow.success before assertAll, and [ bam, bai ] in the test names. This update also adds automatic M-bias trimming for rastair2, using the new rastair2/mbias from nf-core/modules#13678 · rastair2/mbias: new module….

eduard-watchmaker and others added 3 commits November 10, 2026 12:03
rastair's M-bias report fails on an empty table (for example a --region
without reads). Write a short report and no cutoffs files instead, so
callers fall back to no trimming.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New sixth input `trims`: [] (estimate trims with rastair mbias/mbiasparser or
rastair2/mbias, as before) or [ nOT, nOB ] to use those bases to ignore for
both callers and skip the M-bias steps. Lets pipelines expose the trims as
parameters. Invalid values are an error.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eduard-watchmaker added a commit to nf-core/methylseq that referenced this pull request Nov 10, 2026
…verride

- Run both TAPS callers through BAM_TAPS_CONVERSION (nf-core/modules#13641,
  installed from its branch until it is merged). rastair version 2 now
  estimates trims with rastair2/mbias (#13678), like rastair 0.8 does with
  mbias + mbiasparser. When they can't be estimated, nothing is trimmed.
- --trim_OT/--trim_OB (default unset) replace the estimate for both callers.
- --rastair2_mbias_region: region for the rastair2 M-bias estimate, by
  default the first 10 Mb of the longest contig.
- Warn when rastair 0.8 gets single-end samples: it only calls properly
  paired reads, so they get no methylation calls.
- rastair 0.8 modules updated to nf-core master (version topics); the
  mbiasparser patch is no longer needed.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Lukecele

Copy link
Copy Markdown
Contributor

Hi @eduard-watchmaker! 👋

Just reviewed the updated test suite following @adamrtalbot's feedback:

  • ✅ All channel declarations in tests/main.nf.test are now lowercase channel.of and channel.value.
  • ✅ Named closure parameters (meta, vcf -> ...) are properly used throughout.
  • ✅ All 35 CI matrix checks across Conda, Docker, and Singularity are completely green.

Both the subworkflow logic and the accompanying test suite look clean, robust, and ready for merge! 🚀

@eduard-watchmaker

Copy link
Copy Markdown
Contributor Author

Hi @Lukecele thanks for the review in here too, any chance you can approve the PR so I can merge?

@Lukecele Lukecele left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Verified that all feedback points from @adamrtalbot are addressed (lowercase channel.of, clean assertions, descriptive test names). Tests and snapshots are 100% green. 🚀

@eduard-watchmaker

Copy link
Copy Markdown
Contributor Author

@adamrtalbot can you approve too? Thanks!

@Lukecele

Lukecele commented Nov 11, 2026 via email

Copy link
Copy Markdown
Contributor

@eduard-watchmaker
eduard-watchmaker added this pull request to the merge queue Nov 11, 2026
Merged via the queue into master with commit 9b7485d Nov 11, 2026
79 checks passed
@eduard-watchmaker
eduard-watchmaker deleted the bam-taps-conversion-rastair2 branch November 11, 2026 17:22
giuliaroeth pushed a commit to saezlab/modules that referenced this pull request Nov 11, 2026
…re#13678)

* rastair2/mbias: new module; rastair2/call: take M-bias cutoffs

rastair2/mbias runs `rastair per-read` and `rastair mbias` on paired-end
TAPS reads and writes an HTML M-bias report plus, per contig, the bases to
ignore at each read end (line 1 for --nOT, line 2 for --nOB).

rastair2/call takes an optional cutoffs file in its main input tuple
(`[]` for none) and passes it as --nOT/--nOB.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* rastair2/mbias, rastair2/call: lowercase channel, named closure parameters in tests

Same test conventions as requested on nf-core#13641: lowercase `channel`, named
closure parameters, and a bare `assert process.success` before assertAll.
Shorter comment on why rastair2/mbias runs per-read itself.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* rastair2/mbias: no estimate instead of an error when no read has a CpG

rastair's M-bias report fails on an empty table (for example a --region
without reads). Write a short report and no cutoffs files instead, so
callers fall back to no trimming.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
eduard-watchmaker added a commit to nf-core/methylseq that referenced this pull request Nov 11, 2026
… bwameth/align from nf-core master

bam_taps_conversion (nf-core/modules#13641) and rastair2/call and
rastair2/mbias (nf-core/modules#13678) are unchanged from the PR branch;
modules.json now points at master. bwameth/align is updated to
nf-core/modules#13642, which is the same code as the local patch, so the
patch is dropped.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants