Fixes NaN issue in new Qual calculator

Fixes issue #1491
This commit is contained in:
Valentin Ruano Rubio 2016-10-11 11:54:17 -04:00
parent 967b4f4ae8
commit 16417bbf34
2 changed files with 17 additions and 1 deletions

View File

@ -159,8 +159,15 @@ public final class AlleleFrequencyCalculator extends AFCalculator {
pOfNonZeroAltAlleles[alleleIndex] += genotypePosterior); 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++) { 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(); spec.disableShadowBCF();
executeTest("testGenotypingSpanningDeletionAcrossLines", spec); 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);
}
} }