Merge pull request #1492 from broadinstitute/vrr_newqual_nan_fix

Fixes NaN issue in new Qual calculator
This commit is contained in:
Valentin Ruano Rubio 2016-10-11 23:31:19 -04:00 committed by GitHub
commit 2ee0755c35
2 changed files with 17 additions and 1 deletions

View File

@ -159,8 +159,15 @@ public final class AlleleFrequencyCalculator extends AFCalculator {
pOfNonZeroAltAlleles[alleleIndex] += genotypePosterior);
}
// Make sure that we handle appropriately pOfNonZeroAltAlleles that are close to 1; values just over 1.0 due to
// rounding error would result in NaN.
// As every allele is present in at least one genotype, the p-non-zero-count for
// any allele is bound above by 1.0 - minimum genotype posterior because at least one genotype
// does not contain this allele.
final double maximumPNonZeroCount = 1.0 - MathUtils.arrayMin(genotypePosteriors);
for (int allele = 0; allele < numAlleles; allele++) {
log10POfZeroCountsByAllele[allele] += Math.log10(1 - pOfNonZeroAltAlleles[allele]);
log10POfZeroCountsByAllele[allele] += Math.log10(1.0 - Math.min(maximumPNonZeroCount, pOfNonZeroAltAlleles[allele]));
}
}

View File

@ -681,4 +681,13 @@ public class GenotypeGVCFsIntegrationTest extends WalkerTest {
spec.disableShadowBCF();
executeTest("testGenotypingSpanningDeletionAcrossLines", spec);
}
@Test
public void testNewQualNaNBugFix() {
final WalkerTestSpec spec = new WalkerTestSpec(
baseTestString(" -newQual -V " + privateTestDir + "input-newqual-nan-bug-fix.vcf", b37KGReferenceWithDecoy),
Collections.singletonList("503f4193c22fbcc451bd1c425b8b6bf8"));
spec.disableShadowBCF();
executeTest("testNewQualNaNBugFix", spec);
}
}