Skip to content

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

Merged
eduard-watchmaker merged 3 commits into
masterfrom
rastair2-mbias
Nov 11, 2026
Merged

eduard-watchmaker merged 3 commits into
masterfrom
rastair2-mbias

Conversation

@eduard-watchmaker

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

Copy link
Copy Markdown
Contributor

Description of the PR

Adds rastair2/mbias and lets rastair2/call use its output, so rastair version 2 can work out and apply M-bias trimming automatically, as rastair/mbias + rastair/mbiasparser + rastair/call do for rastair 0.8.

  • New module rastair2/mbias. Runs rastair per-read (ext.args, e.g. --region), then rastair mbias on the per-read BED (ext.args2). Outputs:

    • html: the M-bias report, with the suggested cutoffs drawn on the plots.
    • cutoffs: one <prefix>.<contig>.cutoffs.txt per contig with enough data. Line 1 is the value for --nOT, line 2 for --nOB (r1_start,r1_end,r2_start,r2_end).

    rastair 2 calculates the cutoffs itself (the M-bias report scans outwards from the middle of the read for positions that differ from the middle), so no separate parser module is needed.

  • rastair2/call. The main input is now [ meta, bam, index, mbias_cutoffs ], with [] for no trimming. A cutoffs file is passed as --nOT/--nOB. Existing snapshots are unchanged.

Notes:

  • rastair mbias --bam resolves symlinks in R, so it looks for the .bai and .fai next to the original files and fails with Nextflow's staging. The module runs per-read itself instead and turns off the V-bias plots (they read the FASTA from R) and GC plots (they need a VCF).
  • The bioconda build doesn't find its own R scripts, so the module passes --r-script-dir.
  • The report needs read-pair flags to tell read 1 from read 2 and OT from OB, so single-end input is an error.
  • If no read in range has a CpG (for example a --region without reads), rastair mbias fails on the empty table, so the module writes a short report and no cutoffs files instead. Callers then fall back to no trimming.
  • The report loads every read in range into memory, so for large genomes restrict it with --region (for example a methylated spike-in like lambda, or part of one chromosome). That also gives a single cutoffs file.
  • Same environment and containers as rastair2/call. Lint's bioconda_latest warning (htslib 1.24 -> 1.25) is expected: the cap comes from bcftools 1.24.

Why: on in-house human TAPS data (hg38 + lambda), rastair 2 without trimming gives 0.964 pooled CpG methylation on the fully methylated lambda control. With the cutoffs from rastair2/mbias (OT 2,0,6,0, OB 4,0,4,0) it gives 0.982, matching rastair 0.8 with its M-bias trimming. The unmethylated control stays at 0.005.

bam_taps_conversion uses these to trim automatically in #13641, which has this branch merged in, so this PR should be merged first. nf-core/methylseq (taps_v2, nf-core/methylseq#638) already runs them from that branch.

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!
  • If you've added a new tool - have you followed the module conventions in the contribution docs
  • Remove all TODO statements.
  • Emit the versions.yml file.
  • Follow the naming conventions.
  • Follow the parameters requirements.
  • Follow the input/output options guidelines.
  • Add a resource label
  • Use BioConda and BioContainers if possible to fulfil software requirements.
  • Ensure that the test works with either Docker / Singularity. Conda CI tests can be quite flaky:
    • For modules:
      • nf-core modules test rastair2/mbias --profile docker and rastair2/call (10/10 passed locally, also with docker,arm64)
      • nf-core modules test <MODULE> --profile singularity (CI)
      • nf-core modules test <MODULE> --profile conda (CI)

🤖 Generated with Claude Code

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
eduard-watchmaker marked this pull request as ready for review November 10, 2026 18:10
…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>
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>
@Lukecele

Copy link
Copy Markdown
Contributor

Hi @eduard-watchmaker! 👋

Excellent work on rastair2/mbias and the M-bias cutoff integration in rastair2/call!

A few highlights from reviewing the PR:

  • Clean backward compatibility: rastair2/call gracefully handles both the empty [] and populated mbias_cutoffs cases, with clear error messaging if multiple cutoff files are passed.
  • Robust test suite: Setup-chained testing with RASTAIR2_MBIAS feeding into RASTAIR2_CALL ensures integration between the two modules is verified in CI.
  • Wave / Conda lockfiles: Both linux_amd64 and linux_arm64 lockfiles and Seqera container hashes are properly generated according to the new standards.
  • 100% Green CI: All checks across Conda, Docker, and Singularity passed without issue.

Ready to merge from my perspective! 🚀

@eduard-watchmaker

Copy link
Copy Markdown
Contributor Author

Hi @Lukecele thanks for the nice review! Any chance you can approve my PR?

@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 the rastair2/mbias module and the optional cutoff passing in rastair2/call. CI tests and lockfiles are 100% green. 🚀

@eduard-watchmaker
eduard-watchmaker added this pull request to the merge queue Nov 11, 2026
Merged via the queue into master with commit 0f22965 Nov 11, 2026
61 checks passed
@eduard-watchmaker
eduard-watchmaker deleted the rastair2-mbias branch November 11, 2026 16:21
@Lukecele

Copy link
Copy Markdown
Contributor

Congrats on the merge @eduard-watchmaker! Glad to have helped out! 🎉

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.

2 participants