Skip to content

Commit

Permalink
handle contamination==1 in M2 filtering (#5853)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbenjamin authored Apr 1, 2019
1 parent ea3032d commit b5259e0
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public class ContaminationFilter extends Mutect2VariantFilter {
private final Map<String, Double> contaminationBySample;
private final double defaultContamination;
private final double EPSILON = 1.0e-10;

public ContaminationFilter(final List<File> contaminationTables, final double contaminationEstimate) {
contaminationBySample = contaminationTables.stream()
Expand All @@ -38,8 +39,8 @@ public double calculateErrorProbability(final VariantContext vc, final Mutect2Fi
continue;
}

final double contamination = contaminationBySample.getOrDefault(tumorGenotype.getSampleName(), defaultContamination);

final double contaminationFromFile = contaminationBySample.getOrDefault(tumorGenotype.getSampleName(), defaultContamination);
final double contamination = Math.max(0, Math.min(contaminationFromFile, 1 - EPSILON)); // handle file with contamination == 1
final double[] alleleFractions = GATKProtectedVariantContextUtils.getAttributeAsDoubleArray(tumorGenotype, VCFConstants.ALLELE_FREQUENCY_KEY,
() -> new double[] {1.0}, 1.0);
final int maxFractionIndex = MathUtils.maxElementIndex(alleleFractions);
Expand Down

0 comments on commit b5259e0

Please sign in to comment.