Fix per-locus allele decoding consistently in getal and getal.b - #83
Open
thierrygosselin wants to merge 5 commits into
Open
thierrygosselin wants to merge 5 commits into
thierrygosselin wants to merge 5 commits into
Conversation
Clarify that confidence-interval row names identify the populations and that single-population input supports numeric, character, and factor identifiers.
Remove the leftover documentation change from master so future branches start without unrelated changes.
Build on Timothée Flutre’s per-locus decoding approach from PR jgx65#34. Infer allele width separately for each locus in getal.b(), and reuse that decoder in getal() so allele-count and heterozygosity calculations use consistent allele assignments. Preserve missing calls, handle entirely missing loci, and reject encodings beyond the supported three-digit allele range. Retain the current median-based inference heuristic. Automatic width inference remains ambiguous where numeric encoding has discarded leading zeros. Related to jgx65#33 and jgx65#34.
Test mixed-width loci, locus reordering and subsetting, missing calls, entirely missing loci, and single-row inputs. Check consistency between getal() and getal.b(), including allele counts, WC FST/FIS, and observed heterozygosity for equivalent genotype encodings. All 24 assertions pass locally.
This was referenced Sep 5, 2026
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.
Background
This builds on Timothée Flutre’s per-locus decoding approach in #34, addressing the mixed-width genotype encoding problem reported in #33.
The current global divisor can decode
8882as alleles8/882when another locus uses three-digit alleles, instead of the intended88/82.Changes
getal.b().getal()so allele counts and heterozygosity calculations use consistent allele assignments.Updating both decoding paths matters because allele counts use
getal(), while heterozygosity calculations also usegetal.b().Validation
All 24 regression assertions pass locally, with no warnings. Tests cover mixed-width loci, reordering, subsetting, missing values, single-row inputs, and consistency of downstream allele counts, WC FST/FIS, and observed heterozygosity.
Additional local comparisons confirmed unchanged
gtrunchierresults for the allele array,getal(), WC FST, andbasic.stats().Remaining limitation
Automatic width inference remains heuristic: once leading zeros are discarded, some numeric encodings are inherently ambiguous. This patch does not claim to resolve those cases or introduce an explicit allele-width argument.
Related to #33 and #34. Credit to Timothée Flutre for the original per-locus approach.