Skip to content

Fix/featurecounts mixed se pe on448 - #2

Closed
NicoDeVeaux wants to merge 6 commits into
nf-core-modules-updatefrom
fix/featurecounts-mixed-se-pe-on448
Closed

Fix/featurecounts mixed se pe on448#2
NicoDeVeaux wants to merge 6 commits into
nf-core-modules-updatefrom
fix/featurecounts-mixed-se-pe-on448

Conversation

@NicoDeVeaux

Copy link
Copy Markdown
Owner

copy of nf-core#452, with the benefit of stacking to minimize changed lines

NicoDeVeaux and others added 6 commits July 26, 2026 04:37
Restore subread to the registry version and drop the nf-core patch record.
The pin was the stopgap for mixed single-end/paired-end consensus counting;
the following commits handle mixed cohorts explicitly, so it is no longer
needed. Reverts the pin introduced in nf-core#448.
…ing subread

featureCounts (subread >=2.1.0) applies -p to a whole invocation and aborts
when single-end and paired-end BAMs are mixed in one call, which broke consensus
quantification for mixed cohorts. Rather than rolling subread back to 2.0.1,
split the consensus BAMs by library type, count each homogeneous batch with the
correct pairing flag (from meta.single_end), then column-bind the per-batch
matrices back into one table for DESeq2 and MultiQC.

- subworkflows/local/bed_consensus_...: branch consensus BAMs by single_end,
  run SUBREAD_FEATURECOUNTS per batch, merge via new FEATURECOUNTS_MERGE
- modules/local/featurecounts_merge.nf + bin/featurecounts_merge.sh: cbind
  featureCounts tables on Geneid, preserving the 6-col annotation + comment
  header layout expected by deseq2_qc.r (count_col 7, skip=1)
- conf/modules.config: per-batch featureCounts prefixes (.SE/.PE) to avoid
  output collisions; publish merged matrix under the canonical consensus prefix

Keeps subread at 2.1.1 (no rollback). subread bump therefore stays consistent
with modules.json.
The mixed SE/PE rewrite destructured ch_bams.join(ch_peaks) with a fixed
3-arg closure ({ meta, _bam, _peak -> }), but the merged-library caller
passes [ meta, bam, control ], so the joined tuple is 4 elements
([ meta, bam, control, peak ]) and .branch/.map aborted with
'Invalid method invocation doCall ... on _closure' before featureCounts
ever ran. The merged-replicate caller passes [ meta, bams ] (3 after join),
so arities differ between the two instantiations of this shared subworkflow.

Access meta/bam positionally (item[0]/item[1]) so the split tolerates both
shapes, matching the arity-tolerant item[1] indexing the pre-split code used.
Add nf-test for FEATURECOUNTS_MERGE and a pure-bash unit test for
bin/featurecounts_merge.sh, pinning the consensus-peak quantification
merge logic that fix B relies on:

- mixed SE+PE column-bind keyed on Geneid (not row position)
- single-file pass-through for homogeneous (all-SE / all-PE) cohorts
- usage error on missing input tables
- stub

nf-test: 3 passed; bash unit test: 4 passed.
Extend the pipeline-level coverage of the mixed single-end/paired-end
consensus-peak quantification fix, complementing the FEATURECOUNTS_MERGE
unit + module tests:

- default.nf.test: assert the merged consensus matrix carries every SE and
  PE sample column exactly once (no duplicates) — the actual failure-B
  regression, validated against a real -profile test run (3 SE + 3 PE cols).
- consensus_all_se / consensus_all_pe: homogeneous cohorts that exercise the
  empty-branch -> single featureCounts invocation -> pass-through merge path,
  asserting the merged matrix carries only the expected library type.

Subset samplesheets for the edge cases live in tests/csv/.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The SE/PE split replaced the single sorted BAM list from nf-core#448 with two
per-endedness batches plus a merge step, each assembled from an unordered
channel collect. Sort all three by filename so the featureCounts column order,
the merged count matrix and its snapshot md5 stay reproducible across runs and
hosts, preserving the guarantee nf-core#448 established.
@NicoDeVeaux
NicoDeVeaux deleted the fix/featurecounts-mixed-se-pe-on448 branch July 26, 2026 02:58
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.

1 participant