Skip to content

fix: make outputs independent of hash order and --threads - #205

Merged
ewels merged 1 commit into
seqeralabs:mainfrom
rhassaine:fix/determinism-v3
Nov 27, 2026
Merged

ewels merged 1 commit into
seqeralabs:mainfrom
rhassaine:fix/determinism-v3

Conversation

@rhassaine

Copy link
Copy Markdown
Contributor

Some outputs changed between runs or between --threads values because they relied on hash-map order or on how chromosomes were split across workers.

  • inner_distance now keeps the first N pairs in the file, whatever the thread count.
  • dupRadar/featureCounts mate pairing no longer depends on how chromosomes are split. Mates wait in a per-key queue, and a fragment counts as duplicate or multi-mapped if either mate is.
  • The dupRadar density plot draws equal-density points in a fixed order.
  • A chromosome_mapping that sends two GTF names to one alignment name is now rejected when the config loads.
  • The chromosome-mismatch error lists the first 5 GTF chromosomes in GTF order, and Qualimap COLLISION lines come out sorted.

Single-thread output is unchanged on 8 public datasets, and --threads 1/2/6 now give identical files apart from timestamps.

🤖 Generated with Claude Code

Several outputs changed between runs, or between thread counts, because
they depended on HashMap iteration order or on how chromosomes were
split across workers.

Thread count (per-chromosome workers merged in a different order):
- inner_distance: pairs were concatenated in worker order and cut at
  the sample size, and the distance list was cut at the same length as
  the pair list although it has no entries for cross-chromosome pairs.
  Pairs are now merged in chromosome order, cut, and the distances
  rebuilt from the kept pairs. Each worker's chromosome batch is now in
  ascending order so its own cut keeps the right pairs.
- dupRadar/featureCounts mate pairing: the merge took the duplicate and
  multi-mapper flags of whichever mate the first worker held, and a
  repeated mate key (no HI tag, duplicated records) overwrote the
  waiting mate, so reads were dropped differently depending on the
  split. Mates now wait in a per-key FIFO queue that pairs read1 with
  read2 in arrival order, giving the same pairs in one pass or after a
  merge, and a fragment counts as duplicate / multi-mapped if either
  mate is, as featureCounts does (Rsubread readSummary.c, loop over
  both ends in process_pairer_output).

Hash order:
- dupRadar density scatter: pixels with equal density are now drawn in
  pixel order, so the SVG/PNG no longer change from run to run.
- chromosome_mapping: two GTF names mapped to one alignment name made
  the reverse lookup pick one at random. Such a config is now rejected
  at load time with a clear error.
- The chromosome-mismatch error listed 5 random GTF chromosomes; it now
  lists the first 5 in GTF order.
- Qualimap COLLISION debug lines are printed in ascending mean order.
- MergedGeneCoverage::iter yields genes in index order.

The Qualimap unmapped-segment reads are now looked up by their GTF
chromosome name, like every other read.

Single-threaded output is unchanged on the benchmark datasets; the
parallel path now reproduces it byte for byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ewels
ewels merged commit 2c7ce20 into seqeralabs:main Nov 27, 2026
7 checks passed
@rhassaine
rhassaine deleted the fix/determinism-v3 branch November 27, 2026 15:52
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