Skip to content

Fix genotype likelihood cardinality for zero-depth diploid calls - #1103

Open
aganezov wants to merge 2 commits into
google:r1.10from
aganezov:fix/zero-depth-likelihoods
Open

aganezov wants to merge 2 commits into
google:r1.10from
aganezov:fix/zero-depth-likelihoods

Conversation

@aganezov

Copy link
Copy Markdown

When sum(AD) == 0, uncall_gt_if_no_ad() sets the genotype to ./., sets GQ to zero, and replaces the genotype likelihoods with exactly two zeros. The likelihood array therefore has the wrong number of entries for the function's existing diploid representation, including an ordinary biallelic record.

This change allocates one neutral likelihood per possible diploid genotype while preserving the existing no-call behavior.

Problem and correction

VCF genotype likelihood fields use Number=G: one value per possible genotype. With n alleles, including REF, a diploid call requires n * (n + 1) / 2 entries.

The zero-depth path currently ignores the allele count:

REF ALT Genotype order Before After
A C AA, AC, CC [0, 0] [0, 0, 0]
A C,G AA, AC, CC, AG, CG, GG [0, 0] [0, 0, 0, 0, 0, 0]

The implementation derives the allele count from REF plus alternate_bases and allocates the corresponding number of zeros. GT remains ./. and GQ remains 0.

The internal genotype_likelihood protobuf field stores doubles. Using 0.0 makes that existing type explicit; the previous integer literals were already converted to doubles on assignment. The VCF writer continues to produce integer PL values.

Regression coverage

The tests use the existing parameterized test framework and variant construction helper:

  • Add biallelic and multiallelic zero-depth cases checking the full likelihood array, no-call genotype, and GQ zero.
  • Strengthen the existing positive-depth case to check that the entire variant remains unchanged.

The expected likelihood counts are specified explicitly as 3 and 6, independently of the implementation's formula.

Validation

Five focused cases were run using an isolated harness with existing compiled dependencies from a pinned runtime:

Source under test Result
Baseline source with the updated tests Three existing cases pass; both new cardinality cases fail
Fixed source with the updated tests All five cases pass

The baseline failures show arrays of length 2 where lengths 3 and 6 are expected. The positive-depth preservation check passes with the fix.

In a synthetic postprocessing check, reprocessing existing CNN outputs with the correction produced VCF and gVCF records with valid Number=G cardinality throughout. The zero-depth site retained its no-call genotype and GQ zero. Its VCF record had three PL values; its gVCF record had six after addition of the symbolic allele.

These checks used the pinned runtime, not a clean Bazel build. The full postprocessing test suite was not run.

Motivation and scope

A zero-depth call should retain a correctly sized likelihood array even when its genotype is unknown. This fix makes the array consistent with the record's allele count and the existing diploid representation, while preserving GT=./. and GQ=0.

The change is limited to zero-depth likelihood allocation and focused regression tests. The demonstrated defect is malformed likelihood-array cardinality; no downstream miscall or accuracy improvement is claimed.

When sum(AD) is zero, the no-call path writes two likelihood entries
regardless of the allele count. Allocate n_alleles * (n_alleles + 1) / 2
entries to match the existing diploid genotype representation.

Preserve GT=./., GQ=0, and neutral likelihoods. Add biallelic and
multiallelic regression coverage and verify positive-depth calls
remain unchanged.
@google-cla

google-cla Bot commented Sep 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Update 22 zero-depth biallelic records from PL=0,0 to PL=0,0,0
to match the diploid likelihood cardinality correction in 28b5477.

Preserve all other fields and headers. This completes the golden
fixture update for the existing production-code fix.

This branch has not been deployed

No deployments
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