Skip to content

Fix per-locus allele decoding consistently in getal and getal.b - #83

Open
thierrygosselin wants to merge 5 commits into
jgx65:masterfrom
thierrygosselin:fix-per-locus-allele-decoding
Open

thierrygosselin wants to merge 5 commits into
jgx65:masterfrom
thierrygosselin:fix-per-locus-allele-decoding

Conversation

@thierrygosselin

Copy link
Copy Markdown
Collaborator

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 8882 as alleles 8/882 when another locus uses three-digit alleles, instead of the intended 88/82.

Changes

  • Infer allele width separately for each locus in getal.b().
  • Reuse that decoder in getal() so allele counts and heterozygosity calculations use consistent allele assignments.
  • Preserve missing calls and handle entirely missing loci.
  • Retain the current median-based inference heuristic.
  • Reject encodings at or above the unsupported six-digit boundary of 1000000.

Updating both decoding paths matters because allele counts use getal(), while heterozygosity calculations also use getal.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 gtrunchier results for the allele array, getal(), WC FST, and basic.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.

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.
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.

1 participant