-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding hard filter to M2 for polymorphic NuMTs and low VAF sites (#5842)
- Loading branch information
1 parent
21da1c0
commit ea3032d
Showing
11 changed files
with
115 additions
and
111 deletions.
There are no files selected for viewing
85 changes: 0 additions & 85 deletions
85
src/main/java/org/broadinstitute/hellbender/tools/walkers/annotator/PolymorphicNuMT.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...org/broadinstitute/hellbender/tools/walkers/mutect/filtering/MinAlleleFractionFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.broadinstitute.hellbender.tools.walkers.mutect.filtering; | ||
|
||
import htsjdk.variant.variantcontext.VariantContext; | ||
import org.apache.commons.lang.mutable.MutableBoolean; | ||
import org.broadinstitute.hellbender.utils.GATKProtectedVariantContextUtils; | ||
import org.broadinstitute.hellbender.utils.variant.GATKVCFConstants; | ||
|
||
import java.util.*; | ||
import java.util.stream.IntStream; | ||
|
||
public class MinAlleleFractionFilter extends HardFilter { | ||
private final double minAf; | ||
|
||
public MinAlleleFractionFilter(final double minAf) { | ||
this.minAf = minAf; | ||
} | ||
|
||
@Override | ||
public ErrorType errorType() { return ErrorType.ARTIFACT; } | ||
|
||
@Override | ||
public boolean isArtifact(final VariantContext vc, final Mutect2FilteringEngine filteringEngine) { | ||
return vc.getGenotypes().stream().filter(filteringEngine::isTumor) | ||
.filter(g -> g.hasExtendedAttribute(GATKVCFConstants.ALLELE_FRACTION_KEY)) | ||
.anyMatch(g -> { | ||
final double[] alleleFractions = GATKProtectedVariantContextUtils.getAttributeAsDoubleArray(g, GATKVCFConstants.ALLELE_FRACTION_KEY, () -> null, 1.0); | ||
final int numRealAlleles = vc.hasSymbolicAlleles() ? alleleFractions.length - 1 : alleleFractions.length; | ||
final OptionalDouble max = IntStream.range(0, numRealAlleles).mapToDouble(a -> alleleFractions[a]).max(); | ||
return max.getAsDouble() < minAf; | ||
}); | ||
} | ||
|
||
@Override | ||
public String filterName() { | ||
return GATKVCFConstants.ALLELE_FRACTION_FILTER_NAME; | ||
} | ||
|
||
@Override | ||
protected List<String> requiredAnnotations() { return Collections.emptyList(); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...a/org/broadinstitute/hellbender/tools/walkers/mutect/filtering/PolymorphicNuMTFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.broadinstitute.hellbender.tools.walkers.mutect.filtering; | ||
|
||
import htsjdk.variant.variantcontext.Genotype; | ||
import htsjdk.variant.variantcontext.VariantContext; | ||
import org.apache.commons.lang.mutable.MutableBoolean; | ||
import org.apache.commons.math3.distribution.PoissonDistribution; | ||
import org.broadinstitute.hellbender.utils.variant.GATKVCFConstants; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.OptionalInt; | ||
import java.util.stream.IntStream; | ||
|
||
public class PolymorphicNuMTFilter extends HardFilter { | ||
private static final double LOWER_BOUND_PROB = .01; | ||
private static final double MULTIPLE_COPIES_MULTIPLIER = 1.5; | ||
private final int maxAltDepthCutoff; | ||
|
||
public PolymorphicNuMTFilter(final double medianAutosomalCoverage){ | ||
if (medianAutosomalCoverage != 0) { | ||
final PoissonDistribution autosomalCoverage = new PoissonDistribution(medianAutosomalCoverage * MULTIPLE_COPIES_MULTIPLIER); | ||
maxAltDepthCutoff = autosomalCoverage.inverseCumulativeProbability(1 - LOWER_BOUND_PROB); | ||
} else { | ||
maxAltDepthCutoff = 0; | ||
} | ||
} | ||
|
||
@Override | ||
public ErrorType errorType() { return ErrorType.NON_SOMATIC; } | ||
|
||
@Override | ||
public boolean isArtifact(final VariantContext vc, final Mutect2FilteringEngine filteringEngine) { | ||
return vc.getGenotypes().stream().filter(filteringEngine::isTumor) | ||
.filter(Genotype::hasAD) | ||
.anyMatch(g -> { | ||
final int[] alleleDepths = g.getAD(); | ||
final int numRealAlleles = vc.hasSymbolicAlleles() ? alleleDepths.length - 1 : alleleDepths.length; | ||
//Start at first alternate allele depth (the ref allele is first) | ||
final OptionalInt max = IntStream.range(1, numRealAlleles).map(a -> alleleDepths[a]).max(); | ||
return max.getAsInt() < maxAltDepthCutoff; | ||
}); | ||
} | ||
|
||
@Override | ||
public String filterName() { | ||
return GATKVCFConstants.POTENTIAL_POLYMORPHIC_NUMT_FILTER_NAME; | ||
} | ||
|
||
@Override | ||
protected List<String> requiredAnnotations() { return Collections.emptyList(); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.