Skip to content

fix: sort BAM/BAI inputs to Manta for deterministic sample order#815

Merged
ramprasadn merged 2 commits into
nf-core:devfrom
benstory:fix/manta-sample-sort
Apr 22, 2026
Merged

fix: sort BAM/BAI inputs to Manta for deterministic sample order#815
ramprasadn merged 2 commits into
nf-core:devfrom
benstory:fix/manta-sample-sort

Conversation

@benstory

Copy link
Copy Markdown

Closes #814

Description of changes

In subworkflows/local/call_sv_manta/main.nf, the BAM and BAI channels were being collected with .collect{ _meta, bam -> bam }, which gathers the files into a list but doesn't guarantee a stable ordering. Since Manta emits sample columns in the order BAMs are provided on the command line, this caused non-deterministic sample column ordering in the output VCF across otherwise identical runs.

This PR sorts the collected BAM/BAI files by filename before passing them to Manta, using .collect(sort: { a, b -> a.getName() <=> b.getName() }). Consistent with other tools in the pipeline (see #814 for breakdown).

Two files changed:

  • subworkflows/local/call_sv_manta/main.nf — the actual fix
  • CHANGELOG.md — entry under ### Fixed

No functional change to variant calling itself; only the ordering of inputs.

Notes for reviewers

  • If this needs to be backported to an upcoming release branch in addition to dev, let me know and I'll open a second PR.

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 pipeline conventions in the contribution docs
  • If necessary, also make a PR on the nf-core/raredisease branch on the nf-core/test-datasets repository.
  • Make sure your code lints (nf-core pipelines lint).
  • Ensure the test suite passes (nextflow run . -profile test,docker --outdir <OUTDIR>).
  • Ensure the test suite passes (nextflow run . -profile test_singleton,docker --outdir <OUTDIR>).
  • Check for unexpected warnings in debug mode (nextflow run . -profile debug,test,docker --outdir <OUTDIR>).
  • Usage Documentation in docs/usage.md is updated.
  • Output Documentation in docs/output.md is updated.
  • CHANGELOG.md is updated.
  • README.md is updated (including new tool citations and authors/contributors).

@nf-core-bot

Copy link
Copy Markdown
Member

Warning

Newer version of the nf-core template is available.

Your pipeline is using an old version of the nf-core template: 3.5.1.
Please update your pipeline to the latest version.

For more documentation on how to update your pipeline, please see the nf-core documentation and Synchronisation documentation.

@benstory benstory force-pushed the fix/manta-sample-sort branch from 4da6289 to 490b687 Compare April 18, 2026 13:06
Comment on lines +19 to 21
ch_bam.map{ _meta, bam -> bam }
.collect(sort: { a, b -> a.getName() <=> b.getName() })
.toList()

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.

Nice! Good that you found this issue. Previously I've sorted the inputs within the module for these kinds of issues (e.g. https://github.com/nf-core/modules/blob/5d4a8ab3aeed5b759ca0a38b57b6153e9b55deab/modules/nf-core/bcftools/merge/main.nf#L26). But maybe this works since it's converted to a list before it's combined into manta_input? @ramprasadn, what's the reason for having .toList() here in the first place?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Without toList(), the combine operation downstream doesn't work. Instead of [meta, [bam1, bam2], [bai1, bai2]] you get [meta, bam1, bam2, bai1, bai2]

@ramprasadn ramprasadn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Thanks for the fix @benstory

@ramprasadn ramprasadn merged commit cebd9db into nf-core:dev Apr 22, 2026
11 of 12 checks passed
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.

4 participants