use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk-protected 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-protected by broadinstitute.
the class OrientationBiasFiltererUnitTest method assertArtifact.
private boolean assertArtifact(double amPreAdapterQ, final Genotype genotypeTumor, final Transition transition) {
final Transition transitionComplement = transition.complement();
boolean result = false;
// Check whether this genotype is reverse complement or actual artifact mode
if (genotypeTumor.getAllele(0).basesMatch(String.valueOf(transition.ref())) && genotypeTumor.getAllele(1).basesMatch(String.valueOf(transition.call()))) {
// not complement (i.e. artifact mode)
Assert.assertTrue(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.PRE_ADAPTER_METRIC_RC_FIELD_NAME).equals(OrientationBiasFilterer.PRE_ADAPTER_METRIC_NOT_ARTIFACT_SCORE));
Assert.assertTrue(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.PRE_ADAPTER_METRIC_FIELD_NAME).equals(amPreAdapterQ));
Assert.assertEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.IS_ORIENTATION_BIAS_ARTIFACT_MODE), String.valueOf(true));
Assert.assertEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.IS_ORIENTATION_BIAS_RC_ARTIFACT_MODE), String.valueOf(false));
result = true;
} else if (genotypeTumor.getAllele(0).basesMatch(String.valueOf(transitionComplement.ref())) && genotypeTumor.getAllele(1).basesMatch(String.valueOf(transitionComplement.call()))) {
//complement
Assert.assertTrue(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.PRE_ADAPTER_METRIC_RC_FIELD_NAME).equals(amPreAdapterQ));
Assert.assertTrue(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.PRE_ADAPTER_METRIC_FIELD_NAME).equals(OrientationBiasFilterer.PRE_ADAPTER_METRIC_NOT_ARTIFACT_SCORE));
Assert.assertEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.IS_ORIENTATION_BIAS_ARTIFACT_MODE), String.valueOf(false));
Assert.assertEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.IS_ORIENTATION_BIAS_RC_ARTIFACT_MODE), String.valueOf(true));
result = true;
}
return result;
}
use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk-protected 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 PreAdapterOrientationScorerUnitTest method testBasicScoring.
/**
* Note that (due to raw data), this test includes collapsing over libraries (not just the contexts).
* @throws IOException
*/
@Test
public void testBasicScoring() throws IOException {
final MetricsFile<SequencingArtifactMetrics.PreAdapterDetailMetrics, Comparable<?>> mf = new MetricsFile<>();
mf.read(new FileReader(testPreAdapterDetailsMetrics));
final Map<Transition, Double> scoreMap = PreAdapterOrientationScorer.scoreOrientationBiasMetricsOverContext(mf.getMetrics());
Assert.assertNotNull(scoreMap);
Assert.assertEquals(scoreMap.keySet().size(), 12);
// Ground truth values painstakingly derived manually
Assert.assertEquals(scoreMap.get(Transition.transitionOf('A', 'C')), 100.0, 1e-6);
Assert.assertEquals(scoreMap.get(Transition.transitionOf('A', 'G')), 50.5788416297570, 1e-6);
Assert.assertEquals(scoreMap.get(Transition.transitionOf('A', 'T')), 100.0, 1e-6);
Assert.assertEquals(scoreMap.get(Transition.transitionOf('C', 'A')), 100.0, 1e-6);
Assert.assertEquals(scoreMap.get(Transition.transitionOf('C', 'G')), 100.0, 1e-6);
Assert.assertEquals(scoreMap.get(Transition.transitionOf('C', 'T')), 58.0641821538479, 1e-6);
}
use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk-protected by broadinstitute.
the class PreAdapterOrientationScorerUnitTest method testBasicCounting.
/**
* Note that (due to raw data), this test includes collapsing over libraries (not just the contexts).
* @throws IOException
*/
@Test
public void testBasicCounting() throws IOException {
final MetricsFile<SequencingArtifactMetrics.PreAdapterDetailMetrics, Comparable<?>> mf = new MetricsFile<>();
mf.read(new FileReader(testPreAdapterDetailsMetrics));
final Map<Transition, RealMatrix> countMap = PreAdapterOrientationScorer.countOrientationBiasMetricsOverContext(mf.getMetrics());
Assert.assertNotNull(countMap);
Assert.assertEquals(countMap.keySet().size(), 12);
// Ground truth values painstakingly derived manually from both libraries (hence four values in the expression instead of two)
// L1 norm can be used since all values are always positive.
Assert.assertEquals(countMap.get(Transition.transitionOf('A', 'C')).getRowVector(0).getL1Norm(), 2836660 + 2631203 + 240 + 246, 1e-1);
Assert.assertEquals(countMap.get(Transition.transitionOf('A', 'C')).getRowVector(1).getL1Norm(), 2852491 + 333 + 2646654 + 297, 1e-1);
Assert.assertEquals(countMap.get(Transition.transitionOf('A', 'G')).getRowVector(0).getL1Norm(), 2631203 + 416 + 2836660 + 481, 1e-1);
Assert.assertEquals(countMap.get(Transition.transitionOf('A', 'G')).getRowVector(1).getL1Norm(), 2852491 + 404 + 2646654 + 397, 1e-1);
}
Aggregations