Merge pull request #1168 from broadinstitute/knoblett

Implemented MetricsCollection evaluation module
This commit is contained in:
Geraldine Van der Auwera 2015-10-01 14:14:07 -04:00
commit 071dbf29dd
4 changed files with 105 additions and 6 deletions

View File

@ -335,7 +335,7 @@ public class VariantEvalIntegrationTest extends WalkerTest {
" --eval " + validationDataLocation + "yri.trio.gatk_glftrio.intersection.annotated.filtered.chr1.vcf" +
" --comp:comp_genotypes " + privateTestDir + "yri.trio.gatk.ug.head.vcf";
WalkerTestSpec spec = new WalkerTestSpec(withSelect(tests, "DP < 50", "DP50") + " " + extraArgs + " -ST CpG -o %s",
1, Arrays.asList("4b9dcbce0717285e3c0c736c1bed744c"));
1, Arrays.asList("eaa3708d9db22fca0844a652bb73b82f"));
executeTestParallel("testSelect1", spec);
}
@ -377,7 +377,7 @@ public class VariantEvalIntegrationTest extends WalkerTest {
" --dbsnp " + b37dbSNP132 +
" --eval:evalBI " + variantEvalTestDataRoot + "ALL.20100201.chr20.bi.sites.vcf" +
" -noST -ST Novelty -o %s";
WalkerTestSpec spec = new WalkerTestSpec(extraArgs,1,Arrays.asList("112bb3221688acad83f29542bfb33151"));
WalkerTestSpec spec = new WalkerTestSpec(extraArgs,1,Arrays.asList("fe9dcf4933a645f55be1cb0e33497e49"));
executeTestParallel("testEvalTrackWithoutGenotypes",spec);
}
@ -404,7 +404,7 @@ public class VariantEvalIntegrationTest extends WalkerTest {
" --eval:evalBI " + variantEvalTestDataRoot + "ALL.20100201.chr20.bi.sites.vcf" +
" --eval:evalBC " + variantEvalTestDataRoot + "ALL.20100201.chr20.bc.sites.vcf" +
" -noST -ST Novelty -o %s";
WalkerTestSpec spec = new WalkerTestSpec(extraArgs,1,Arrays.asList("81dcdde458c1ebb9aa35289ea8f12bc8"));
WalkerTestSpec spec = new WalkerTestSpec(extraArgs,1,Arrays.asList("8dfdec264fcff9472bdee7d223fdb3ca"));
executeTestParallel("testMultipleEvalTracksWithoutGenotypes",spec);
}
@ -586,7 +586,7 @@ public class VariantEvalIntegrationTest extends WalkerTest {
"-o %s"
),
1,
Arrays.asList("f8460af997436a5ce4407fefb0e2724d")
Arrays.asList("af317f1ea1b80e5d4bc4f2d8523ef73d")
);
executeTest("testModernVCFWithLargeIndels", spec);
}

View File

@ -32,6 +32,7 @@ import htsjdk.samtools.SAMSequenceRecord;
import org.apache.log4j.Logger;
import htsjdk.tribble.Feature;
import org.broadinstitute.gatk.engine.walkers.*;
import org.broadinstitute.gatk.tools.walkers.varianteval.evaluators.*;
import org.broadinstitute.gatk.utils.commandline.*;
import org.broadinstitute.gatk.engine.CommandLineGATK;
import org.broadinstitute.gatk.engine.GenomeAnalysisEngine;
@ -39,7 +40,6 @@ import org.broadinstitute.gatk.engine.arguments.DbsnpArgumentCollection;
import org.broadinstitute.gatk.utils.contexts.AlignmentContext;
import org.broadinstitute.gatk.utils.contexts.ReferenceContext;
import org.broadinstitute.gatk.utils.refdata.RefMetaDataTracker;
import org.broadinstitute.gatk.tools.walkers.varianteval.evaluators.VariantEvaluator;
import org.broadinstitute.gatk.tools.walkers.varianteval.stratifications.IntervalStratification;
import org.broadinstitute.gatk.tools.walkers.varianteval.stratifications.VariantStratifier;
import org.broadinstitute.gatk.tools.walkers.varianteval.stratifications.manager.StratificationManager;
@ -609,7 +609,34 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
for ( final EvaluationContext nec : stratManager.values() )
for ( final VariantEvaluator ve : nec.getVariantEvaluators() )
ve.finalizeEvaluation();
//send data to MetricsCollection
CompOverlap compOverlap = null;
IndelSummary indelSummary = null;
CountVariants countVariants = null;
MultiallelicSummary multiallelicSummary = null;
TiTvVariantEvaluator tiTvVariantEvaluator = null;
MetricsCollection metricsCollection = null;
for(final EvaluationContext nec: stratManager.values()) {
for(final VariantEvaluator ve : nec.getVariantEvaluators()) {
if (ve instanceof CompOverlap)
compOverlap = (CompOverlap) ve;
else if (ve instanceof IndelSummary)
indelSummary = (IndelSummary) ve;
else if (ve instanceof CountVariants)
countVariants = (CountVariants) ve;
else if (ve instanceof MultiallelicSummary)
multiallelicSummary = (MultiallelicSummary) ve;
else if (ve instanceof TiTvVariantEvaluator)
tiTvVariantEvaluator = (TiTvVariantEvaluator) ve;
else if (ve instanceof MetricsCollection)
metricsCollection = (MetricsCollection) ve;
}
if(metricsCollection != null)
metricsCollection.setData(compOverlap.concordantRate, indelSummary.n_SNPs, countVariants.nSNPs, indelSummary.n_indels, multiallelicSummary.nIndels, indelSummary.insertion_to_deletion_ratio, countVariants.insertionDeletionRatio, tiTvVariantEvaluator.tiTvRatio);
}
VariantEvalReportWriter.writeReport(out, stratManager, stratManager.getStratifiers(), stratManager.get(0).getVariantEvaluators());
}

View File

@ -0,0 +1,67 @@
/*
* Copyright 2012-2015 Broad Institute, Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.gatk.tools.walkers.varianteval.evaluators;
import org.broadinstitute.gatk.tools.walkers.varianteval.util.Analysis;
import org.broadinstitute.gatk.tools.walkers.varianteval.util.DataPoint;
/**
* Created by knoblett on 9/15/15.
*/
@Analysis(description = "Metrics Collection")
public class MetricsCollection extends VariantEvaluator {
@DataPoint(description = "The concordance rate from CompOverlap", format = "%.2f")
public double concordantRate;
@DataPoint(description = "Number of SNPs from IndelSummary", format = "%d")
public int nSNPs;
@DataPoint(description = "Number of SNP loci from CountVariants", format = "%d")
public long nSNPloci;
@DataPoint(description = "Number of indels from IndelSummary", format = "%d")
public int nIndels;
@DataPoint(description = "Number of indel loci from MultiallelicSummary", format = "%d")
public int nIndelLoci;
@DataPoint(description = "Insertion to deletion ratio from IndelSummary")
public String indelRatio;
@DataPoint(description = "Insertion to deletion ratio from CountVariants", format = "%.2f")
public double indelRatioLociBased;
@DataPoint(description = "The transition to transversion ratio from TiTvVariantEvaluator", format = "%.2f")
public double tiTvRatio;
public int getComparisonOrder() {return 2;}
public void setData(double concordantRate, int nSNPs, long nSNPloci, int nIndels, int nIndelLoci, String indelRatio, double indelRatioLociBased, double tiTvRatio){
this.concordantRate = concordantRate;
this.nSNPs = nSNPs;
this.nSNPloci = nSNPloci;
this.nIndels = nIndels;
this.nIndelLoci = nIndelLoci;
this.indelRatio = indelRatio;
this.indelRatioLociBased = indelRatioLociBased;
this.tiTvRatio = tiTvRatio;
}
}

View File

@ -176,6 +176,11 @@ public class VariantEvalUtils {
}
}
//add MetricsCollection if required modules are included
if(evals.contains(classMap.get("CompOverlap")) && evals.contains(classMap.get("IndelSummary")) && evals.contains(classMap.get("TiTvVariantEvaluator")) && evals.contains(classMap.get("CountVariants")) && evals.contains(classMap.get("MultiallelicSummary")) )
evals.add(classMap.get("MetricsCollection"));
return evals;
}