Repository navigation
adding phased property to HaplotypeMatrix - #354
Closed
mufernando wants to merge 2 commits into
Closed
mufernando wants to merge 2 commits into
mufernando wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The streaming constructor breaks existing callers by requiring a new argument, and the quickstart contains inaccuracies about VCF ploidy, haplotype values, and dosage conversion.
4 open issues
What changed in this PR
Adds informational phasing metadata to eager and streaming haplotype matrices, preparing the codebase for future phase-aware warnings without changing statistical results.
Changes:
- Adds
phasedandset_phased(), with loader-specific defaults. - Preserves phasing through subsets, filtering, streaming chunks, and windowed matrices.
- Adds tests, updates documentation, and outlines future warning behavior.
| File | Description |
|---|---|
| tests/test_streaming.py | Supplies phasing explicitly in streaming construction. |
| tests/test_phasing.py | Tests defaults, overrides, propagation, and conversions. |
| tests/test_gpu_genotype_prep.py | Updates builder calls with explicit phasing. |
| PHASING_PLAN.md | Outlines future phase-dependent warnings and follow-ups. |
| pg_gpu/windowed_analysis.py | Preserves phasing in per-window matrices. |
| pg_gpu/streaming_matrix.py | Adds streaming phasing metadata and chunk propagation. |
| pg_gpu/haplotype_matrix.py | Adds the flag, loader defaults, and propagation. |
| pg_gpu/genotype_matrix.py | Marks reconstructed haplotypes as unphased. |
| pg_gpu/_utils.py | Preserves phasing in population subsets. |
| pg_gpu/_gpu_genotype_prep.py | Requires and forwards explicit phasing. |
| docs/source/quickstart.rst | Explains phasing flags and matrix conversions. |
| docs/source/changelog.rst | Announces informational phasing support. |
| docs/source/api.rst | Exposes streaming phasing members in API documentation. |
Review effort: Balanced
| """ | ||
|
|
||
| def __init__(self, source, fetcher, chunk_bp, prefetch, *, | ||
| phased, accessible_mask=None, n_total_sites=None): |
Comment on lines
+11
to
+12
| per haplotype, with variants as columns). When loaded from a diploid | ||
| (or n-ploid) VCF, the two haploid copies of each sample become 2 (or n) rows. |
Comment on lines
+542
to
+543
| ``HaplotypeMatrix`` rows are gametes (0/1 per allele, two rows per | ||
| individual). ``GenotypeMatrix`` rows are individuals (0/1/2 dosage). |
Comment on lines
+551
to
+553
| # Convert from haploid (pairs consecutive haplotypes). | ||
| # The result is always phased=False: heterozygotes are assigned as | ||
| # (0, 1), which is a pseudo-phasing. |
Comment on lines
+546
to
+548
| (0/1/2 dosage). Use ``GenotypeMatrix`` only for statistics which need | ||
| dosage encoding. Many functions auto-dispatch on input type, so the same | ||
| call works on either a ``HaplotypeMatrix`` or a ``GenotypeMatrix``. |
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.


WIP