use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk by broadinstitute.
the class OrientationBiasFiltererUnitTest method testAnnotateVariantContextWithFilterValuesMultiArtifact.
@Test
public void testAnnotateVariantContextWithFilterValuesMultiArtifact() {
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2VcfMore));
SortedSet<Transition> relevantTransitions = new TreeSet<>();
relevantTransitions.add(Transition.transitionOf('G', 'T'));
relevantTransitions.add(Transition.transitionOf('C', 'T'));
final Map<Transition, Double> preAdapterQFakeScoreMap = new HashMap<>();
final double amGTPreAdapterQ = 20.0;
final double amCTPreAdapterQ = 25.0;
// preAdapterQ suppression will do nothing.
preAdapterQFakeScoreMap.put(relevantTransitions.first(), amGTPreAdapterQ);
// preAdapterQ suppression will do nothing.
preAdapterQFakeScoreMap.put(relevantTransitions.last(), amCTPreAdapterQ);
final List<VariantContext> updatedVariants = new ArrayList<>();
for (final VariantContext vc : featureDataSource) {
final VariantContext updatedVariantContext = OrientationBiasFilterer.annotateVariantContextWithPreprocessingValues(vc, relevantTransitions, preAdapterQFakeScoreMap);
updatedVariants.add(updatedVariantContext);
}
final List<String> sampleNames = updatedVariants.get(0).getSampleNamesOrderedByName();
// Create a mapping from sample name to a genotype->variant context map
final Map<String, SortedMap<Genotype, VariantContext>> sampleNameToVariants = OrientationBiasFilterer.createSampleToGenotypeVariantContextSortedMap(sampleNames, updatedVariants);
}
use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk by broadinstitute.
the class OrientationBiasFiltererUnitTest method testAnnotateVariantContextWithPreprocessingValues.
@Test
public void testAnnotateVariantContextWithPreprocessingValues() {
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2Vcf));
SortedSet<Transition> relevantTransitions = new TreeSet<>();
relevantTransitions.add(Transition.transitionOf('G', 'T'));
final Map<Transition, Double> preAdapterQFakeScoreMap = new HashMap<>();
final double amGTPreAdapterQ = 20.0;
// preAdapterQ suppression will do nothing.
preAdapterQFakeScoreMap.put(Transition.transitionOf('G', 'T'), amGTPreAdapterQ);
for (final VariantContext vc : featureDataSource) {
final VariantContext updatedVariantContext = OrientationBiasFilterer.annotateVariantContextWithPreprocessingValues(vc, relevantTransitions, preAdapterQFakeScoreMap);
final Genotype genotypeTumor = updatedVariantContext.getGenotype("TUMOR");
final Genotype genotypeNormal = updatedVariantContext.getGenotype("NORMAL");
Assert.assertNotEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.FOB, VCFConstants.EMPTY_ALLELE), VCFConstants.EMPTY_ALLELE);
Assert.assertNotEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.P_ARTIFACT_FIELD_NAME, VCFConstants.EMPTY_ALLELE), VCFConstants.EMPTY_ALLELE);
assertArtifact(amGTPreAdapterQ, genotypeTumor, Transition.transitionOf('G', 'T'));
// The NORMAL is always ref/ref in the example file.
assertNormal(genotypeNormal);
}
}
use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk by broadinstitute.
the class OrientationBiasUtilsUnitTest method testCountNumTransition.
@Test
public void testCountNumTransition() {
// Setup the test
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2VcfMore));
SortedSet<Transition> relevantTransitions = new TreeSet<>();
relevantTransitions.add(Transition.transitionOf('T', 'A'));
final List<VariantContext> variantContexts = getVariantContexts(featureDataSource);
// Should be one, since one of the variants was filtered.
Assert.assertEquals(OrientationBiasUtils.calculateNumTransition("TUMOR", variantContexts, relevantTransitions.first()), 1);
Assert.assertEquals(OrientationBiasUtils.calculateNumTransition("NORMAL", variantContexts, relevantTransitions.first()), 0);
}
use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk-protected by broadinstitute.
the class OrientationBiasFiltererUnitTest method testCreateSampleToGenotypeVCMap.
@Test
public void testCreateSampleToGenotypeVCMap() {
// Setup the test
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2VcfMore));
SortedSet<Transition> relevantTransitions = new TreeSet<>();
relevantTransitions.add(Transition.transitionOf('G', 'T'));
relevantTransitions.add(Transition.transitionOf('C', 'T'));
final Map<Transition, Double> preAdapterQFakeScoreMap = new HashMap<>();
final double amGTPreAdapterQ = 20.0;
final double amCTPreAdapterQ = 25.0;
// preAdapterQ suppression will do nothing.
preAdapterQFakeScoreMap.put(relevantTransitions.first(), amGTPreAdapterQ);
// preAdapterQ suppression will do nothing.
preAdapterQFakeScoreMap.put(relevantTransitions.last(), amCTPreAdapterQ);
final List<VariantContext> updatedVariants = new ArrayList<>();
for (final VariantContext vc : featureDataSource) {
final VariantContext updatedVariantContext = OrientationBiasFilterer.annotateVariantContextWithPreprocessingValues(vc, relevantTransitions, preAdapterQFakeScoreMap);
updatedVariants.add(updatedVariantContext);
}
final List<String> sampleNames = updatedVariants.get(0).getSampleNamesOrderedByName();
// Do the test
// Create a mapping from sample name to a genotype->variant context map with the second map sorted by p_artifact (i.e. OrientationBiasFilterConstants.P_ARTIFACT_FIELD_NAME)
final Map<String, SortedMap<Genotype, VariantContext>> sampleNameToVariants = OrientationBiasFilterer.createSampleToGenotypeVariantContextSortedMap(sampleNames, updatedVariants);
Assert.assertEquals(sampleNameToVariants.keySet().size(), 2);
Assert.assertTrue(sampleNameToVariants.keySet().contains("TUMOR"));
Assert.assertTrue(sampleNameToVariants.keySet().contains("NORMAL"));
Assert.assertEquals(sampleNameToVariants.get("TUMOR").keySet().size(), 8);
// None of the normal genotypes should have a pvalue, so cannot/shouldn't be added to the sorted map
Assert.assertEquals(sampleNameToVariants.get("NORMAL").keySet().size(), 0);
// Check that the sorted map is getting smaller (or same) values of p_artifact and not staying put.
double previousPArtifact = Double.POSITIVE_INFINITY;
for (final Genotype genotypeTumor : sampleNameToVariants.get("TUMOR").keySet()) {
final Double pArtifact = OrientationBiasUtils.getGenotypeDouble(genotypeTumor, OrientationBiasFilterConstants.P_ARTIFACT_FIELD_NAME, Double.POSITIVE_INFINITY);
Assert.assertNotNull(pArtifact);
Assert.assertTrue(pArtifact <= previousPArtifact);
Assert.assertNotEquals(pArtifact, Double.POSITIVE_INFINITY);
}
}
use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk-protected by broadinstitute.
the class OrientationBiasFiltererUnitTest method testHighPloidy.
@Test(description = "This test just confirms that the OB filterer does not throw an exception if confronted with high ploidy call. Also test that it is a superset of the original variant context.")
public void testHighPloidy() {
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2HighPloidy));
// Dummy values for relevant transitions and preAdapter Map
SortedSet<Transition> relevantTransitions = new TreeSet<>();
relevantTransitions.add(Transition.transitionOf('G', 'T'));
relevantTransitions.add(Transition.transitionOf('C', 'T'));
final Map<Transition, Double> preAdapterQFakeScoreMap = new HashMap<>();
final double amGTPreAdapterQ = 20.0;
final double amCTPreAdapterQ = 25.0;
// preAdapterQ suppression will do nothing.
preAdapterQFakeScoreMap.put(relevantTransitions.first(), amGTPreAdapterQ);
// preAdapterQ suppression will do nothing.
preAdapterQFakeScoreMap.put(relevantTransitions.last(), amCTPreAdapterQ);
for (final VariantContext vc : featureDataSource) {
final VariantContext updatedVariantContext = OrientationBiasFilterer.annotateVariantContextWithPreprocessingValues(vc, relevantTransitions, preAdapterQFakeScoreMap);
final Set<String> originalGenotypeAttributes = vc.getGenotype("TUMOR1").getExtendedAttributes().keySet();
final Set<String> newGenotypeAttributes = updatedVariantContext.getGenotype("TUMOR1").getExtendedAttributes().keySet();
Assert.assertTrue(newGenotypeAttributes.containsAll(originalGenotypeAttributes));
Assert.assertTrue(newGenotypeAttributes.size() == (originalGenotypeAttributes.size() + 2));
for (final String ga : originalGenotypeAttributes) {
Assert.assertEquals(updatedVariantContext.getGenotype("TUMOR1").getExtendedAttributes().get(ga), vc.getGenotype("TUMOR1").getExtendedAttributes().get(ga));
}
}
}
Aggregations