Skip to content

fix(deepvariant/postprocessvariants): use .tsv suffix for phased reads input - #13500

Open
awgymer wants to merge 8 commits into
nf-core:masterfrom
awgymer:fix-deepvariant-phasing-path
Open

awgymer wants to merge 8 commits into
nf-core:masterfrom
awgymer:fix-deepvariant-phasing-path

Conversation

@awgymer

@awgymer awgymer commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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 input/output options guidelines.
  • For modules:
    • nf-core modules test deepvariant/postprocessvariants --profile docker
    • nf-core modules test deepvariant/postprocessvariants --profile singularity

This PR fixes the path that DEEPVARIANT_POSTPROCESSVARIANTS gives to --phased_reads_input_path. Before this fix, DeepVariant did not use the read phasing output from DEEPVARIANT_MAKEEXAMPLES.

DEEPVARIANT_MAKEEXAMPLES writes the read phasing files as <prefix>-read-phasing_debug-0000i-of-0000N.tsv. DEEPVARIANT_POSTPROCESSVARIANTS removed the .tsv extension and added .gz, so it gave <prefix>-read-phasing_debug@0000N.gz to DeepVariant.

This doesn't actually cause DeepVariant to fail, but it results in an empty switches file and the phasing information not actually being used.

run_deepvariant gives read-phasing_debug@N.tsv to make_examples and to postprocess_variants. This PR uses the same .tsv suffix.

Changes

  • Use the .tsv suffix in the logical name for --phased_reads_input_path.
  • Add 2 optional outputs, phased_reads_switches and phased_reads_corrected. These files are only created when phase_inputs is given. Before this PR, DeepVariant wrote these files to its default paths in /tmp.
  • Add the test homo_sapiens - ont - phasing. It uses nanopore/bam/test.sorted.bam with the ont_r104 model and with_phasing = true. The test makes sure that the switches file is not empty. The PacBio data did not work for this test.
  • Use sanitizeOutput in the snapshots for this module.

Added after review:

  • The deepvariant subworkflow now emits the 2 phased reads outputs.
  • equality.nf.test has a new ONT phasing test.

…s input

DEEPVARIANT_MAKEEXAMPLES writes the local read phasing files as
<prefix>-read-phasing_debug-0000i-of-0000N.tsv. The module added a .gz
suffix to the sharded path that it gives to --phased_reads_input_path.

The DeepVariant merger then opened files that do not exist and did not
report an error. It loaded 0 reads and wrote an empty switches file.
StitchPhaseSets then used MATCH for every phase set join.

Use the .tsv suffix, as run_deepvariant does.
Write the phased reads switches and corrected reads files to the work
directory and emit them as optional outputs. Before this change,
postprocess_variants wrote them to the default paths in /tmp.

Add an ONT test with phasing. The test asserts that the switches file
is not empty. Without the .tsv suffix fix, this assertion fails.
@awgymer
awgymer marked this pull request as ready for review October 30, 2026 03:47

@pinin4fjords pinin4fjords left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me. Optional, fine as follow-ups:

  • Could the deepvariant subworkflow emit phased_reads_switches / phased_reads_corrected? Otherwise pipelines using it won't get them.
  • An ONT + phasing case in the subworkflow's equality.nf.test would be a nice end-to-end check against rundeepvariant. It may not match exactly, though, since postprocess doesn't get --checkpoint_json like run_deepvariant passes (already the case before this PR).

@pinin4fjords

Copy link
Copy Markdown
Member

One more: module tests should use a single nextflow.config with args coming from params, overridden per test, rather than an extra config file (spec). The existing config predates that, but since you're in here, could you fold ont_phasing.config into it? Something like:

params {
    makeexamples_args = '--checkpoint "/opt/models/wgs" --call_small_model_examples ...'
    callvariants_args = '--checkpoint "/opt/models/wgs"'
}
process {
    withName: "DEEPVARIANT_MAKEEXAMPLES" { ext.args = params.makeexamples_args }
    withName: "DEEPVARIANT_CALLVARIANTS" { ext.args = params.callvariants_args }
}

Then config "./nextflow.config" per test, with the ONT values set in the phasing test's params {} block.

Remove ont_phasing.config. The test nextflow.config now sets ext.args
from params, and the ONT phasing test sets the ONT values in its params
block. The nf-core testing specification requires one config file.
Emit phased_reads_switches and phased_reads_corrected from
DEEPVARIANT_POSTPROCESSVARIANTS. Pipelines that use the subworkflow can
then get these files. The files are only created when with_phasing is
true.
The existing phasing equality test uses Illumina data, so no reads are
phased. The new test uses ONT data with the ONT_R104 model. It compares
the subworkflow output with run_deepvariant, and asserts that the
switches file is not empty.
@awgymer

awgymer commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Robot goes brrrrrr:

Single test config

  • removed ont_phasing.config. The test nextflow.config now gets ext.args from params.
  • The ONT phasing test sets the ONT values in its when { params {} } block. A params {} block in a setup run() does not apply, because nf-test runs the setup and the test in
    one Nextflow run.

Subworkflow outputs

  • The deepvariant subworkflow now emits phased_reads_switches and phased_reads_corrected.
  • The main.nf.test snapshots now include the 2 new outputs. These outputs are empty because those tests do not use phasing. All md5 values are the same as before.

ONT phasing equality test

  • added an ONT test to equality.nf.test. It uses nanopore/bam/test.sorted.bam with the ONT_R104 model and with_phasing = true.
  • The VCF and the gVCF are the same as the run_deepvariant output, so the missing --checkpoint_json does not change the result for this data.
  • The test also makes sure that the switches file is not empty.

The existing equality test with the name "phasing" uses Illumina data with the PacBio model. No reads are phased by that.

@github-actions github-actions Bot added size/l and removed size/m labels Nov 2, 2026
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