Skip to content

Only pass --expansion-distance for nuclei-based xeniumranger imports#191

Merged
heylf merged 2 commits into
nf-core:devfrom
rnaidu-seqera:fix/expansion-distance-nuclei-only
Jul 22, 2026
Merged

Only pass --expansion-distance for nuclei-based xeniumranger imports#191
heylf merged 2 commits into
nf-core:devfrom
rnaidu-seqera:fix/expansion-distance-nuclei-only

Conversation

@rnaidu-seqera

@rnaidu-seqera rnaidu-seqera commented Jul 20, 2026

Copy link
Copy Markdown

Problem

xeniumranger import-segmentation fails on transcript-based segmentation methods:

ERROR: --expansion-distance requires --nuclei.
Error executing process > 'NFCORE_SPATIALAXE:SPATIALAXE:PROSEG_PRESET_PROSEG2BAYSOR:XENIUMRANGER_IMPORT_SEGMENTATION (test_run)'

Reproducible with -profile test (which enables transcript_seg_methods = [proseg, segger, baysor]).

Root cause

conf/modules.config applied --expansion-distance to every XENIUMRANGER_IMPORT_SEGMENTATION invocation via withName. But xeniumranger only accepts --expansion-distance for nuclei-based imports — it expands nuclei outward into cell boundaries. The import step runs in two mutually-exclusive modes (enforced by the module itself):

  • nuclei/cells (--nuclei / --cells) — image segmentation
  • transcript assignment (--transcript-assignment + --viz-polygons) — proseg / baysor / segger

The transcript-assignment methods pass nuclei = [], so --expansion-distance is invalid there and xeniumranger rejects it. (The same applies to the cells-only import in xeniumranger_resegment_morphology_ome_tif.)

This isn't exercised by CI because xeniumranger is a licensed tool that CI can't run.

Fix

Gate --expansion-distance on the module's nuclei input, so it is emitted only when a nuclei segmentation is being imported — matching xeniumranger's own rule:

(nuclei && params.expansion_distance != null) ? "--expansion-distance=${params.expansion_distance}" : ""

Config-only; no change to the shared nf-core module. Preserves the flag for the genuine nuclei imports (stardist / cellpose), and removes it where the tool forbids it (transcript-assignment and cells-only imports).

Validation

  • Confirmed an ext.args closure can reference the module's nuclei path input, and that it resolves correctly among the module's other path inputs.
  • Truthiness verified for the real input types: empty input (nextflow.util.BlankSeparatedList, size 0) → flag omitted; staged path (nextflow.processor.TaskPath) → flag emitted.
  • nextflow lint passes.

PR checklist

  • CHANGELOG.md is updated.
  • Documentation update (n/a — no user-facing parameter/behaviour change).
  • nf-test / CI green (please run in nf-core CI; note this path needs the licensed xeniumranger tool to exercise end-to-end).

xeniumranger import-segmentation was given --expansion-distance on every
invocation, but the tool only accepts it for nuclei-based imports
(it expands nuclei into cell boundaries). Transcript-assignment imports
(proseg/baysor/segger) and cells-only imports fail with
`ERROR: --expansion-distance requires --nuclei`.

Gate the flag on the module's `nuclei` input so it is emitted only when a
nuclei segmentation is being imported.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@heylf heylf added this to the 1.1.0 milestone Jul 22, 2026

@heylf heylf 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. Thank you @rnaidu-seqera for your help!

@heylf
heylf merged commit 36f2503 into nf-core:dev Jul 22, 2026
7 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.

2 participants