moments_ld: default use_genotypes=True to match moments#126
Merged
Conversation
pg_gpu.moments_ld.compute_ld_statistics advertises itself as a drop-in replacement for moments.LD.Parsing.compute_ld_statistics but defaulted use_genotypes=False while moments defaults True. A bare import swap thus silently switched estimators (phased 4-way haplotype counts vs unphased 9-way genotype counts), which agree in expectation but differ on finite data -- producing large, confusing discrepancies that look like a bug. Flip the default to True so it matches moments out of the box, and make the docstring and the moments-integration tutorial state loudly that the flag selects the estimator and must be set identically on both sides of any comparison. The moments parity tests compare pg_gpu against moments' haplotype path, so pin their pg_gpu calls to use_genotypes=False to keep that comparison valid and independent of the moments version.
The lint job set `pixi-version: latest` in setup-pixi. A pixi release
published after the last green main run panics during `pixi install`
while solving the unrelated `moments` environment's pypi source build
on Python 3.14 ("could not initialize build dispatch correctly"),
failing the job before ruff ever runs.
Pin to v0.66.0, which resolves all environments cleanly (verified
locally, including `pixi run -e moments`). This unfloats the lint job
from broken upstream pixi releases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #125.
Problem
pg_gpu.moments_ld.compute_ld_statisticsbills itself as a drop-in replacement formoments.LD.Parsing.compute_ld_statistics, but the two had opposite defaults for the single most behavior-defining argument:use_genotypes=Falseuse_genotypes=TrueA user following our own docstring advice ("switch by changing only the import") silently changed which estimator was computed -- phased 4-way haplotype counts vs. unphased 9-way genotype counts. The two estimators agree in expectation but give different values on finite data, so the result is a large, unexplained mismatch that looks like a pg_gpu bug. This already cost a downstream user real debugging time.
On a real phased window, leaving each library on its own default produced up to ~119% disagreement (worst in the Dz family); aligning the flag brought them to floating-point agreement (max relative diff 3.3e-11).
Change
use_genotypes=Trueso a bare import swap reproduces moments out of the box.Trueto match moments, and must be set identically on both sides of any comparison.use_genotypes=False. This keeps the haplotype-path parity valid and independent of the moments version (the moments 1.5.0 genotype path has a separate, unrelated pi2 sign bug fixed upstream in v1.5.3).Compatibility note
This changes the default behavior for any existing pg_gpu-native caller of the integration layer that relied on the implicit haplotype path. That is the intended, correct-but-breaking part of the fix: the default now matches the function it claims to replace.
Verification
pixi run ruff check pg_gpu/ tests/ examples/-> all checks passed.CUDA_VISIBLE_DEVICES=1 pixi run -e moments pytest tests/test_moments_ld.py-> 25 passed.