Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid error due to finite precision error in M2 pon creation #5797

Merged
merged 2 commits into from
Mar 15, 2019

Conversation

davidbenjamin
Copy link
Contributor

@LeeTL1220 for the REBC pon.

@codecov-io
Copy link

codecov-io commented Mar 15, 2019

Codecov Report

Merging #5797 into master will decrease coverage by 0.008%.
The diff coverage is 50%.

@@               Coverage Diff               @@
##              master     #5797       +/-   ##
===============================================
- Coverage     87.005%   86.997%   -0.008%     
- Complexity     32097     32112       +15     
===============================================
  Files           1974      1974               
  Lines         147213    147249       +36     
  Branches       16214     16218        +4     
===============================================
+ Hits          128082    128102       +20     
- Misses         13228     13239       +11     
- Partials        5903      5908        +5
Impacted Files Coverage Δ Complexity Δ
...ls/walkers/mutect/CreateSomaticPanelOfNormals.java 91.429% <50%> (-2.601%) 23 <2> (+1)
...er/tools/walkers/annotator/PedigreeAnnotation.java 89.189% <0%> (-6.463%) 13% <0%> (+5%)
...oadinstitute/hellbender/utils/pairhmm/PairHMM.java 74.82% <0%> (-3.597%) 24% <0%> (ø)
...bender/tools/walkers/annotator/PossibleDeNovo.java 73.214% <0%> (-2.976%) 23% <0%> (+9%)
...hellbender/utils/pairhmm/VectorLoglessPairHMM.java 85.526% <0%> (-1.316%) 12% <0%> (ø)
.../hellbender/tools/walkers/annotator/ExcessHet.java 98.667% <0%> (ø) 23% <0%> (ø) ⬇️
...ers/annotator/VariantAnnotatorIntegrationTest.java 97.576% <0%> (+0.06%) 56% <0%> (+1%) ⬆️
...ine/GATKPlugin/GATKAnnotationPluginDescriptor.java 77.019% <0%> (+0.144%) 57% <0%> (ø) ⬇️

Copy link
Contributor

@LeeTL1220 LeeTL1220 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have already addressed values greater than 1, feel free to merge. Otherwise, please address that and I can re-review.

final double hetPrior = alleleFrequency * (1 - alleleFrequency) * 2;
final double homPrior = MathUtils.square(alleleFrequency);
final double hetLikelihood = MathUtils.binomialProbability(totalCount, altCount, 0.5);
final double homLikelihood = MathUtils.binomialProbability(totalCount, altCount, 0.98);

final double artifactLikelihood = new BetaBinomialDistribution(null, ARTIFACT_ALPHA, ARTIFACT_BETA, totalCount).probability(altCount);

return MathUtils.normalizeFromRealSpace(new double[] {hetPrior * hetLikelihood + homPrior * homLikelihood, ARTIFACT_PRIOR * artifactLikelihood})[0];
final double[] relativeProbsOfHetHomArtifact = {hetPrior * hetLikelihood + homPrior * homLikelihood, ARTIFACT_PRIOR * artifactLikelihood};
if (MathUtils.sum(relativeProbsOfHetHomArtifact) < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return max(..., 0);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (MathUtils.sum(relativeProbsOfHetHomArtifact) < 0) {
return 0;
}
return MathUtils.normalizeFromRealSpace(relativeProbsOfHetHomArtifact)[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indices look like they have special meaning. Can you describe, in a comment, the meaning of the values in [0] and [1]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@davidbenjamin davidbenjamin merged commit 69f4006 into master Mar 15, 2019
@davidbenjamin davidbenjamin deleted the db_m2_pon branch March 15, 2019 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants