Reverting Mark's previous commit as per the open discussion. Now the eval modules check isPolymorphic() before accruing stats when appropriate. Fixed the IndelLengthHistogram module not to error out if the indel isn't simple (that would have been bad). Only integration test that needed to be updated was the tranches one based on a separate commit from Mark.
This commit is contained in:
parent
d7e355b4b6
commit
aa9e32f2f1
|
|
@ -75,7 +75,7 @@ public class CompOverlap extends VariantEvaluator implements StandardEval {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String update2(VariantContext eval, VariantContext comp, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public String update2(VariantContext eval, VariantContext comp, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||||
boolean evalIsGood = eval != null && eval.isVariant();
|
boolean evalIsGood = eval != null && eval.isPolymorphic();
|
||||||
boolean compIsGood = comp != null && comp.isNotFiltered() && (eval == null || comp.getType() == eval.getType());
|
boolean compIsGood = comp != null && comp.isNotFiltered() && (eval == null || comp.getType() == eval.getType());
|
||||||
|
|
||||||
if (compIsGood) nCompVariants++; // count the number of comp events
|
if (compIsGood) nCompVariants++; // count the number of comp events
|
||||||
|
|
|
||||||
|
|
@ -100,11 +100,12 @@ public class CountVariants extends VariantEvaluator implements StandardEval {
|
||||||
// So in order to maintain consistency with the previous implementation (and the intention of the original author), I've
|
// So in order to maintain consistency with the previous implementation (and the intention of the original author), I've
|
||||||
// added in a proxy check for monomorphic status here.
|
// added in a proxy check for monomorphic status here.
|
||||||
// Protect against case when vc only as no-calls too - can happen if we strafity by sample and sample as a single no-call.
|
// Protect against case when vc only as no-calls too - can happen if we strafity by sample and sample as a single no-call.
|
||||||
if ( !vc1.isVariant() || (vc1.hasGenotypes() && vc1.getHomRefCount() + vc1.getNoCallCount() == vc1.getNSamples()) ) {
|
if ( vc1.isMonomorphic() ) {
|
||||||
nRefLoci++;
|
nRefLoci++;
|
||||||
} else {
|
} else {
|
||||||
switch (vc1.getType()) {
|
switch (vc1.getType()) {
|
||||||
case NO_VARIATION:
|
case NO_VARIATION:
|
||||||
|
// shouldn't get here
|
||||||
break;
|
break;
|
||||||
case SNP:
|
case SNP:
|
||||||
nVariantLoci++;
|
nVariantLoci++;
|
||||||
|
|
|
||||||
|
|
@ -90,18 +90,19 @@ public class IndelLengthHistogram extends VariantEvaluator {
|
||||||
public int getComparisonOrder() { return 1; } // need only the evals
|
public int getComparisonOrder() { return 1; } // need only the evals
|
||||||
|
|
||||||
public String update1(VariantContext vc1, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public String update1(VariantContext vc1, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||||
if ( ! vc1.isBiallelic() && vc1.isIndel() ) {
|
|
||||||
|
if ( vc1.isIndel() && vc1.isPolymorphic() ) {
|
||||||
|
|
||||||
|
if ( ! vc1.isBiallelic() ) {
|
||||||
//veWalker.getLogger().warn("[IndelLengthHistogram] Non-biallelic indel at "+ref.getLocus()+" ignored.");
|
//veWalker.getLogger().warn("[IndelLengthHistogram] Non-biallelic indel at "+ref.getLocus()+" ignored.");
|
||||||
return vc1.toString(); // biallelic sites are output
|
return vc1.toString(); // biallelic sites are output
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( vc1.isIndel() ) {
|
// only count simple insertions/deletions, not complex indels
|
||||||
if ( vc1.isSimpleInsertion() ) {
|
if ( vc1.isSimpleInsertion() ) {
|
||||||
indelHistogram.update(vc1.getAlternateAllele(0).length());
|
indelHistogram.update(vc1.getAlternateAllele(0).length());
|
||||||
} else if ( vc1.isSimpleDeletion() ) {
|
} else if ( vc1.isSimpleDeletion() ) {
|
||||||
indelHistogram.update(-vc1.getReference().length());
|
indelHistogram.update(-vc1.getReference().length());
|
||||||
} else {
|
|
||||||
throw new ReviewedStingException("Indel type that is not insertion or deletion.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ public class IndelStatistics extends VariantEvaluator {
|
||||||
|
|
||||||
public String update1(VariantContext eval, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public String update1(VariantContext eval, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||||
|
|
||||||
if (eval != null ) {
|
if (eval != null && eval.isPolymorphic()) {
|
||||||
if ( indelStats == null ) {
|
if ( indelStats == null ) {
|
||||||
indelStats = new IndelStats(eval);
|
indelStats = new IndelStats(eval);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ public class SimpleMetricsByAC extends VariantEvaluator implements StandardEval
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( eval.isSNP() && eval.isBiallelic() && metrics != null ) {
|
if ( eval.isSNP() && eval.isBiallelic() && eval.isPolymorphic() && metrics != null ) {
|
||||||
metrics.incrValue(eval);
|
metrics.incrValue(eval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,10 @@ public class ThetaVariantEvaluator extends VariantEvaluator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String update1(VariantContext vc, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public String update1(VariantContext vc, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||||
if (vc == null || !vc.isSNP() || !vc.hasGenotypes()) {
|
if (vc == null || !vc.isSNP() || !vc.hasGenotypes() || vc.isMonomorphic()) {
|
||||||
return null; //no interesting sites
|
return null; //no interesting sites
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vc.hasGenotypes()) {
|
|
||||||
|
|
||||||
//this maps allele to a count
|
//this maps allele to a count
|
||||||
ConcurrentMap<String, Integer> alleleCounts = new ConcurrentHashMap<String, Integer>();
|
ConcurrentMap<String, Integer> alleleCounts = new ConcurrentHashMap<String, Integer>();
|
||||||
|
|
||||||
|
|
@ -109,7 +107,6 @@ public class ThetaVariantEvaluator extends VariantEvaluator {
|
||||||
this.totalAvgDiffs += numDiffs / numPairwise;
|
this.totalAvgDiffs += numDiffs / numPairwise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class TiTvVariantEvaluator extends VariantEvaluator implements StandardEv
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTiTv(VariantContext vc, boolean updateStandard) {
|
public void updateTiTv(VariantContext vc, boolean updateStandard) {
|
||||||
if (vc != null && vc.isSNP() && vc.isBiallelic()) {
|
if (vc != null && vc.isSNP() && vc.isBiallelic() && vc.isPolymorphic()) {
|
||||||
if (VariantContextUtils.isTransition(vc)) {
|
if (VariantContextUtils.isTransition(vc)) {
|
||||||
if (updateStandard) nTiInComp++;
|
if (updateStandard) nTiInComp++;
|
||||||
else nTi++;
|
else nTi++;
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,8 @@ public class ValidationReport extends VariantEvaluator implements StandardEval {
|
||||||
public SiteStatus calcSiteStatus(VariantContext vc) {
|
public SiteStatus calcSiteStatus(VariantContext vc) {
|
||||||
if ( vc == null ) return SiteStatus.NO_CALL;
|
if ( vc == null ) return SiteStatus.NO_CALL;
|
||||||
if ( vc.isFiltered() ) return SiteStatus.FILTERED;
|
if ( vc.isFiltered() ) return SiteStatus.FILTERED;
|
||||||
if ( ! vc.isVariant() ) return SiteStatus.MONO;
|
if ( vc.isMonomorphic() ) return SiteStatus.MONO;
|
||||||
|
if ( vc.hasGenotypes() ) return SiteStatus.POLY; // must be polymorphic if isMonomorphic was false and there are genotypes
|
||||||
|
|
||||||
if ( vc.hasAttribute(VCFConstants.ALLELE_COUNT_KEY) ) {
|
if ( vc.hasAttribute(VCFConstants.ALLELE_COUNT_KEY) ) {
|
||||||
int ac = 0;
|
int ac = 0;
|
||||||
|
|
@ -132,8 +133,6 @@ public class ValidationReport extends VariantEvaluator implements StandardEval {
|
||||||
else
|
else
|
||||||
ac = vc.getAttributeAsInt(VCFConstants.ALLELE_COUNT_KEY);
|
ac = vc.getAttributeAsInt(VCFConstants.ALLELE_COUNT_KEY);
|
||||||
return ac > 0 ? SiteStatus.POLY : SiteStatus.MONO;
|
return ac > 0 ? SiteStatus.POLY : SiteStatus.MONO;
|
||||||
} else if ( vc.hasGenotypes() ) {
|
|
||||||
return vc.isPolymorphic() ? SiteStatus.POLY : SiteStatus.MONO;
|
|
||||||
} else {
|
} else {
|
||||||
return TREAT_ALL_SITES_IN_EVAL_VCF_AS_CALLED ? SiteStatus.POLY : SiteStatus.NO_CALL; // we can't figure out what to do
|
return TREAT_ALL_SITES_IN_EVAL_VCF_AS_CALLED ? SiteStatus.POLY : SiteStatus.NO_CALL; // we can't figure out what to do
|
||||||
//return SiteStatus.NO_CALL; // we can't figure out what to do
|
//return SiteStatus.NO_CALL; // we can't figure out what to do
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ public class VariantQualityScore extends VariantEvaluator {
|
||||||
public String update1(VariantContext eval, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public String update1(VariantContext eval, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||||
final String interesting = null;
|
final String interesting = null;
|
||||||
|
|
||||||
if( eval != null && eval.isSNP() && eval.isBiallelic() ) { //BUGBUG: only counting biallelic sites (revisit what to do with triallelic sites)
|
if( eval != null && eval.isSNP() && eval.isBiallelic() && eval.isPolymorphic() ) { //BUGBUG: only counting biallelic sites (revisit what to do with triallelic sites)
|
||||||
if( titvStats == null ) { titvStats = new TiTvStats(); }
|
if( titvStats == null ) { titvStats = new TiTvStats(); }
|
||||||
titvStats.incrValue(eval.getPhredScaledQual(), VariantContextUtils.isTransition(eval));
|
titvStats.incrValue(eval.getPhredScaledQual(), VariantContextUtils.isTransition(eval));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ public class VariantEvalUtils {
|
||||||
* @return a new VariantContext with just the requested samples
|
* @return a new VariantContext with just the requested samples
|
||||||
*/
|
*/
|
||||||
public VariantContext getSubsetOfVariantContext(VariantContext vc, Collection<String> sampleNames) {
|
public VariantContext getSubsetOfVariantContext(VariantContext vc, Collection<String> sampleNames) {
|
||||||
VariantContext vcsub = vc.subContextFromGenotypes(vc.getGenotypes(sampleNames).values());
|
VariantContext vcsub = vc.subContextFromGenotypes(vc.getGenotypes(sampleNames).values(), vc.getAlleles());
|
||||||
|
|
||||||
HashMap<String, Object> newAts = new HashMap<String, Object>(vcsub.getAttributes());
|
HashMap<String, Object> newAts = new HashMap<String, Object>(vcsub.getAttributes());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ public class VariantEvalIntegrationTest extends WalkerTest {
|
||||||
@Test
|
@Test
|
||||||
public void testTranches() {
|
public void testTranches() {
|
||||||
String extraArgs = "-T VariantEval -R "+ hg18Reference +" --eval " + validationDataLocation + "GA2.WEx.cleaned.ug.snpfiltered.indelfiltered.optimized.vcf -o %s -EV TiTvVariantEvaluator -L chr1 -noEV -ST CpG -tf " + testDir + "tranches.6.txt";
|
String extraArgs = "-T VariantEval -R "+ hg18Reference +" --eval " + validationDataLocation + "GA2.WEx.cleaned.ug.snpfiltered.indelfiltered.optimized.vcf -o %s -EV TiTvVariantEvaluator -L chr1 -noEV -ST CpG -tf " + testDir + "tranches.6.txt";
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(extraArgs,1,Arrays.asList("984df6e94a546294fc7e0846cbac2dfe"));
|
WalkerTestSpec spec = new WalkerTestSpec(extraArgs,1,Arrays.asList("6af2b9959aa1778a5b712536de453952"));
|
||||||
executeTestParallel("testTranches",spec);
|
executeTestParallel("testTranches",spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue