Skip to content

Mwu biasz int64 - #2598

Merged
pd3 merged 2 commits into
samtools:developfrom
jkbonfield:mwu-biasz-int64
Sep 30, 2026
Merged

pd3 merged 2 commits into
samtools:developfrom
jkbonfield:mwu-biasz-int64

Conversation

@jkbonfield

Copy link
Copy Markdown
Contributor

A replacement for #2595. Fixes #2594

This has the same commit as 2595 but with an additional refactoring. The two commits are left in place to reflect the same authorship (although by author we mostly mean Claude!), but also because the earlier commit is perhaps easier to understand as an interim solution top the original problem.

Cindy Krafft and others added 2 commits September 23, 2026 19:51
calc_mwu_biasZ() summed the tie adjustment (p*p-1)*p, the pair counts
and the group sizes in `int`. The tie term is cubic in the number of
reads sharing one quality or position bin and exceeds INT_MAX once a bin
holds 1291 reads. That happens at a single deep site (-d raised for
amplicon, mitochondrial or viral data) and, under the default -d 250,
across the samples of a multi-sample call: the histograms are pooled
over all samples, so ~45 samples at 30x with MAPQ 60 are enough. The
wrapped tie term inflated the variance and shrank INFO/MQBZ, BQBZ,
RPBZ, SCBZ, MQSBZ and NMBZ towards zero (for example MQBZ -7.9 where
the tie-corrected Z is -36.6 for 1300 MAPQ-60 reference reads and 40
MAPQ-30 alternate reads).

Accumulate in int64_t. Adds a regression test with 1340 20-bp reads
where the MAPQ-60 bin holds 1300 reads, and a NEWS entry.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Cindy Krafft <cynthiacondra@gmail.com>
The previous commit avoids overflow by switching to 64-bit, but it
moves overflow from ~2^10 to ~2^21.  While high (approx 2 million
depth) this commit refactors it to remove the cube entirely.

Also shrunk the test data a little by using a higher compression level.

Assisted-by: Claude:claude-opus-5-5 high
Signed-off-by: James Bonfield <jkb@sanger.ac.uk>
@pd3

pd3 commented Sep 30, 2026

Copy link
Copy Markdown
Member

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants