use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk by broadinstitute.
the class PreAdapterOrientationScorer method countOrientationBiasMetricsOverContext.
/**
* Gets PreAdapterQ collapsed over contexts.
*
* rows {PRO, CON} x cols {ref, alt}
* @param metrics metrics usually read from a picard preadapter detail file.
* @return mapping to score all orientation bias artifact modes to a PreAdapterQ score. This score can be used as a bam-file level score for level of artifacts.
*/
@VisibleForTesting
static Map<Transition, RealMatrix> countOrientationBiasMetricsOverContext(final List<SequencingArtifactMetrics.PreAdapterDetailMetrics> metrics) {
Utils.nonNull(metrics, "Input metrics cannot be null");
// Artifact mode to a matrix
final Map<Transition, RealMatrix> result = new HashMap<>();
// Collapse over context
for (SequencingArtifactMetrics.PreAdapterDetailMetrics metric : metrics) {
final Transition key = Transition.transitionOf(metric.REF_BASE, metric.ALT_BASE);
result.putIfAbsent(key, new Array2DRowRealMatrix(2, 2));
final RealMatrix preAdapterCountMatrix = result.get(key);
preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.PRO, PreAdapterOrientationScorer.ALT, metric.PRO_ALT_BASES);
preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.CON, PreAdapterOrientationScorer.ALT, metric.CON_ALT_BASES);
preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.PRO, PreAdapterOrientationScorer.REF, metric.PRO_REF_BASES);
preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.CON, PreAdapterOrientationScorer.REF, metric.CON_REF_BASES);
}
return result;
}
use of org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition in project gatk-protected by broadinstitute.
the class FilterByOrientationBias method onTraversalSuccess.
@Override
public Object onTraversalSuccess() {
logger.info("Tagging whether genotypes are in one of the artifact modes.");
// Calculate how many artifacts need to be cut
double fdrThreshold = 0.01;
final List<VariantContext> finalVariants = OrientationBiasFilterer.annotateVariantContextsWithFilterResults(fdrThreshold, relevantTransitions, firstPassVariants, transitionToPreAdapterScoreMap);
logger.info("Writing variants to VCF...");
finalVariants.forEach(vcfWriter::add);
logger.info("Writing a simple summary table...");
List<String> sampleNames = new ArrayList<>();
if (finalVariants.size() != 0) {
sampleNames = finalVariants.get(0).getSampleNamesOrderedByName();
}
final List<Pair<String, Transition>> sampleTransitionCombinations = new ArrayList<>();
for (Transition relevantTransition : relevantTransitions) {
for (String sampleName : sampleNames) {
sampleTransitionCombinations.add(Pair.of(sampleName, relevantTransition));
}
}
OrientationBiasUtils.writeOrientationBiasSummaryTable(sampleTransitionCombinations, finalVariants, transitionToPreAdapterScoreMap, new File(outputFile.getAbsolutePath() + SUMMARY_FILE_SUFFIX));
return null;
}
Aggregations