Merge pull request #1187 from broadinstitute/ldg_variantEval_famStrat
Enable family-level stratification (if a ped file is provided)
This commit is contained in:
commit
54ab65a340
|
|
@ -350,6 +350,17 @@ public class VariantEvalIntegrationTest extends WalkerTest {
|
|||
executeTestParallel("testVEMendelianViolationEvaluator" + vcfFile, spec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMVEvalFamilyStrat() {
|
||||
String vcfFile = "/PhaseByTransmission/PhaseByTransmission.IntegrationTest.TP.vcf";
|
||||
String pedFile = "/PhaseByTransmission/PhaseByTransmission.IntegrationTest.goodFamilies.ped";
|
||||
|
||||
WalkerTestSpec spec = new WalkerTestSpec("-R "+b37KGReference+ " -T VariantEval -ped " + privateTestDir + pedFile + " -eval " + privateTestDir + vcfFile + " -noEV -noST -ST Family -EV MendelianViolationEvaluator -o %s",
|
||||
1,
|
||||
Arrays.asList("d599d3e6b308ac06b2c2e003cf596328"));
|
||||
executeTestParallel("testMVEvalFamilyStrat", spec);
|
||||
}
|
||||
|
||||
|
||||
private static String withSelect(String cmd, String select, String name) {
|
||||
return String.format("%s -select '%s' -selectName %s", cmd, select, name);
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public class VariantEvalWalkerUnitTest extends BaseTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRelevantStates(final ReferenceContext ref, final RefMetaDataTracker tracker, final VariantContext comp, final String compName, final VariantContext eval, final String evalName, final String sampleName) {
|
||||
public List<Object> getRelevantStates(final ReferenceContext ref, final RefMetaDataTracker tracker, final VariantContext comp, final String compName, final VariantContext eval, final String evalName, final String sampleName, final String familyName) {
|
||||
int i = Integer.valueOf(evalName); // a terrible hack, but we can now provide accessible states
|
||||
List<Object> states = new ArrayList<Object>();
|
||||
for ( int state : integers )
|
||||
|
|
@ -180,12 +180,12 @@ public class VariantEvalWalkerUnitTest extends BaseTest {
|
|||
final RefMetaDataTracker tracker = new RefMetaDataTracker();
|
||||
final ReferenceContext ref = null;
|
||||
final VariantContext comp = null;
|
||||
final String compName = null, sampleName = null;
|
||||
final String compName = null, sampleName = null, familyName = null;
|
||||
|
||||
// increment eval counts for each stratification of divisors of i from from 1...maxI
|
||||
for ( int i = 1; i <= cfg.maxI; i++ ) {
|
||||
final String evalName = String.valueOf(i); // terrible hack to stratify by divisor
|
||||
for ( EvaluationContext nec : VEwalker.getEvaluationContexts(tracker, ref, eval, evalName, comp, compName, sampleName) ) {
|
||||
for ( EvaluationContext nec : VEwalker.getEvaluationContexts(tracker, ref, eval, evalName, comp, compName, sampleName, familyName) ) {
|
||||
synchronized (nec) {
|
||||
nec.apply(tracker, ref, null, comp, eval);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,10 @@ import com.google.java.contract.Requires;
|
|||
import htsjdk.samtools.reference.IndexedFastaSequenceFile;
|
||||
import htsjdk.samtools.util.IntervalTree;
|
||||
import htsjdk.samtools.SAMSequenceRecord;
|
||||
import oracle.jrockit.jfr.StringConstantPool;
|
||||
import org.apache.log4j.Logger;
|
||||
import htsjdk.tribble.Feature;
|
||||
import org.broadinstitute.gatk.engine.samples.Trio;
|
||||
import org.broadinstitute.gatk.engine.walkers.*;
|
||||
import org.broadinstitute.gatk.tools.walkers.varianteval.evaluators.*;
|
||||
import org.broadinstitute.gatk.utils.commandline.*;
|
||||
|
|
@ -105,7 +107,7 @@ import java.util.*;
|
|||
* </pre>
|
||||
* </p>
|
||||
*
|
||||
* <h3>Usage example</h3>
|
||||
* <h3>Usage examples</h3>
|
||||
* <pre>
|
||||
* java -jar GenomeAnalysisTK.jar \
|
||||
* -T VariantEval \
|
||||
|
|
@ -116,6 +118,18 @@ import java.util.*;
|
|||
* [--comp comp.vcf]
|
||||
* </pre>
|
||||
*
|
||||
* Count Mendelian violations for each family in a callset with multiple families (and provided pedigree)
|
||||
* <pre>
|
||||
* Java -jar GenomeAnalysisTK.jar \
|
||||
* -T VariantEval \
|
||||
* -R reference.fasta \
|
||||
* -o output.MVs.byFamily.table \
|
||||
* --eval multiFamilyCallset.vcf \
|
||||
* -noEV -noST \
|
||||
* -ST Family \
|
||||
* -EV MendelianViolationEvaluator
|
||||
* </pre>
|
||||
*
|
||||
* <h3>Caveat</h3>
|
||||
*
|
||||
* <p>Some stratifications and evaluators are incompatible with each other due to their respective memory requirements,
|
||||
|
|
@ -249,14 +263,18 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
|||
|
||||
private boolean isSubsettingSamples;
|
||||
private Set<String> sampleNamesForEvaluation = new LinkedHashSet<String>();
|
||||
private Set<String> familyNamesForEvaluation = new LinkedHashSet<String>();
|
||||
private Set<String> sampleNamesForStratification = new LinkedHashSet<String>();
|
||||
private Set<String> familyNamesForStratification = new LinkedHashSet<String>();
|
||||
|
||||
// important stratifications
|
||||
private boolean byFilterIsEnabled = false;
|
||||
private boolean perSampleIsEnabled = false;
|
||||
private boolean perFamilyIsEnabled = false;
|
||||
|
||||
// Public constants
|
||||
private static String ALL_SAMPLE_NAME = "all";
|
||||
final private static String ALL_SAMPLE_NAME = "all";
|
||||
final private static String ALL_FAMILY_NAME = "all";
|
||||
|
||||
// the number of processed bp for this walker
|
||||
long nProcessedLoci = 0;
|
||||
|
|
@ -303,12 +321,22 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
|||
final Set<String> allSampleNames = SampleUtils.getSamplesFromCommandLineInput(vcfSamples);
|
||||
sampleNamesForEvaluation.addAll(new TreeSet<String>(SampleUtils.getSamplesFromCommandLineInput(vcfSamples, SAMPLE_EXPRESSIONS)));
|
||||
isSubsettingSamples = ! sampleNamesForEvaluation.containsAll(allSampleNames);
|
||||
familyNamesForEvaluation.addAll(getSampleDB().getFamilyIDs());
|
||||
|
||||
if (Arrays.asList(STRATIFICATIONS_TO_USE).contains("Sample")) {
|
||||
//If stratifying by sample name, assign a stratification for each sample we're evaluating (based on commandline args)...
|
||||
if (Arrays.asList(STRATIFICATIONS_TO_USE).contains("Sample") ) {
|
||||
sampleNamesForStratification.addAll(sampleNamesForEvaluation);
|
||||
}
|
||||
//...and also a stratification for the sum over all samples
|
||||
sampleNamesForStratification.add(ALL_SAMPLE_NAME);
|
||||
|
||||
//If stratifying by sample name, assign a stratification for each family...
|
||||
if ( Arrays.asList(STRATIFICATIONS_TO_USE).contains("Family") ) {
|
||||
familyNamesForStratification.addAll(familyNamesForEvaluation);
|
||||
}
|
||||
//...and also a stratification for the sum over all families
|
||||
familyNamesForStratification.add(ALL_FAMILY_NAME);
|
||||
|
||||
// Initialize select expressions
|
||||
for (VariantContextUtils.JexlVCMatchExp jexl : VariantContextUtils.initializeMatchExps(SELECT_NAMES, SELECT_EXPS)) {
|
||||
SortableJexlVCMatchExp sjexl = new SortableJexlVCMatchExp(jexl.name, jexl.exp);
|
||||
|
|
@ -327,8 +355,17 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
|||
byFilterIsEnabled = true;
|
||||
else if ( vs.getName().equals("Sample") )
|
||||
perSampleIsEnabled = true;
|
||||
else if ( vs.getName().equals("Family"))
|
||||
perFamilyIsEnabled = true;
|
||||
}
|
||||
|
||||
if (perSampleIsEnabled && perFamilyIsEnabled)
|
||||
throw new UserException.BadArgumentValue("ST", "Variants cannot be stratified by sample and family at the same time");
|
||||
|
||||
if (perFamilyIsEnabled && getSampleDB().getTrios().isEmpty())
|
||||
throw new UserException.BadArgumentValue("ST", "Cannot stratify by family without *.ped file");
|
||||
|
||||
|
||||
if ( intervalsFile != null ) {
|
||||
boolean fail = true;
|
||||
for ( final VariantStratifier vs : stratificationObjects ) {
|
||||
|
|
@ -420,17 +457,24 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
|||
// }
|
||||
|
||||
// --------- track --------- sample - VariantContexts -
|
||||
HashMap<RodBinding<VariantContext>, HashMap<String, Collection<VariantContext>>> evalVCs = variantEvalUtils.bindVariantContexts(tracker, ref, evals, byFilterIsEnabled, true, perSampleIsEnabled, mergeEvals);
|
||||
HashMap<RodBinding<VariantContext>, HashMap<String, Collection<VariantContext>>> compVCs = variantEvalUtils.bindVariantContexts(tracker, ref, comps, byFilterIsEnabled, false, false, false);
|
||||
HashMap<RodBinding<VariantContext>, HashMap<String, Collection<VariantContext>>> evalVCs = variantEvalUtils.bindVariantContexts(tracker, ref, evals, byFilterIsEnabled, true, perSampleIsEnabled, perFamilyIsEnabled, mergeEvals);
|
||||
HashMap<RodBinding<VariantContext>, HashMap<String, Collection<VariantContext>>> compVCs = variantEvalUtils.bindVariantContexts(tracker, ref, comps, byFilterIsEnabled, false, false, false, false);
|
||||
|
||||
// for each eval track
|
||||
for ( final RodBinding<VariantContext> evalRod : evals ) {
|
||||
final Map<String, Collection<VariantContext>> emptyEvalMap = Collections.emptyMap();
|
||||
final Map<String, Collection<VariantContext>> evalSet = evalVCs.containsKey(evalRod) ? evalVCs.get(evalRod) : emptyEvalMap;
|
||||
|
||||
Set<String> statificationLevels;
|
||||
|
||||
// for each sample stratifier
|
||||
for ( final String sampleName : sampleNamesForStratification ) {
|
||||
Collection<VariantContext> evalSetBySample = evalSet.get(sampleName);
|
||||
if (perFamilyIsEnabled)
|
||||
statificationLevels = familyNamesForStratification;
|
||||
else
|
||||
statificationLevels = sampleNamesForStratification;
|
||||
for ( final String stratLevelName : statificationLevels ) {
|
||||
Collection<VariantContext> evalSetBySample = evalSet.get(stratLevelName);
|
||||
|
||||
if ( evalSetBySample == null ) {
|
||||
evalSetBySample = new HashSet<VariantContext>(1);
|
||||
evalSetBySample.add(null);
|
||||
|
|
@ -452,7 +496,18 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
|||
// find the comp
|
||||
final VariantContext comp = findMatchingComp(eval, compSet);
|
||||
|
||||
for ( EvaluationContext nec : getEvaluationContexts(tracker, ref, eval, evalRod.getName(), comp, compRod.getName(), sampleName) ) {
|
||||
Collection<EvaluationContext> contextsForStratification;
|
||||
if (perFamilyIsEnabled)
|
||||
contextsForStratification = getEvaluationContexts(tracker, ref, eval, evalRod.getName(), comp, compRod.getName(), null, stratLevelName);
|
||||
else {
|
||||
String familyID;
|
||||
if (stratLevelName.equals("all"))
|
||||
familyID = "all";
|
||||
else
|
||||
familyID = getSampleDB().getSample(stratLevelName).getFamilyID();
|
||||
contextsForStratification = getEvaluationContexts(tracker, ref, eval, evalRod.getName(), comp, compRod.getName(), stratLevelName, familyID);
|
||||
}
|
||||
for ( EvaluationContext nec : contextsForStratification ) {
|
||||
|
||||
// eval against the comp
|
||||
synchronized (nec) {
|
||||
|
|
@ -521,10 +576,11 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
|||
final String evalName,
|
||||
final VariantContext comp,
|
||||
final String compName,
|
||||
final String sampleName ) {
|
||||
final String sampleName,
|
||||
final String familyName) {
|
||||
final List<List<Object>> states = new LinkedList<List<Object>>();
|
||||
for ( final VariantStratifier vs : stratManager.getStratifiers() ) {
|
||||
states.add(vs.getRelevantStates(ref, tracker, comp, compName, eval, evalName, sampleName));
|
||||
states.add(vs.getRelevantStates(ref, tracker, comp, compName, eval, evalName, sampleName, familyName));
|
||||
}
|
||||
return stratManager.values(states);
|
||||
}
|
||||
|
|
@ -649,6 +705,7 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
|||
public double getMendelianViolationQualThreshold() { return MENDELIAN_VIOLATION_QUAL_THRESHOLD; }
|
||||
|
||||
public static String getAllSampleName() { return ALL_SAMPLE_NAME; }
|
||||
public static String getAllFamilyName() { return ALL_FAMILY_NAME; }
|
||||
|
||||
public List<RodBinding<VariantContext>> getKnowns() { return knowns; }
|
||||
|
||||
|
|
@ -657,6 +714,8 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
|||
public boolean isSubsettingToSpecificSamples() { return isSubsettingSamples; }
|
||||
public Set<String> getSampleNamesForEvaluation() { return sampleNamesForEvaluation; }
|
||||
|
||||
public Set<String> getFamilyNamesForEvaluation() { return familyNamesForEvaluation; }
|
||||
|
||||
public int getNumberOfSamplesForEvaluation() {
|
||||
if (sampleNamesForEvaluation!= null && !sampleNamesForEvaluation.isEmpty())
|
||||
return sampleNamesForEvaluation.size();
|
||||
|
|
@ -667,6 +726,8 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
|||
}
|
||||
public Set<String> getSampleNamesForStratification() { return sampleNamesForStratification; }
|
||||
|
||||
public Set<String> getFamilyNamesForStratification() { return familyNamesForStratification; }
|
||||
|
||||
public List<RodBinding<VariantContext>> getComps() { return comps; }
|
||||
|
||||
public Set<SortableJexlVCMatchExp> getJexlExpressions() { return jexlExpressions; }
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ public class MendelianViolationEvaluator extends VariantEvaluator {
|
|||
HomVarHet_inheritedRef += mv.getParentsVarHetInheritedRef();
|
||||
HomVarHet_inheritedVar += mv.getParentsVarHetInheritedVar();
|
||||
|
||||
if(mv.getFamilyCalledCount()>0){
|
||||
if(mv.getFamilyCalledCount()>0 || mv.getFamilyLowQualsCount()>0 || mv.getFamilyCalledCount()>0){
|
||||
nVariants++;
|
||||
nFamCalled += mv.getFamilyCalledCount();
|
||||
nLowQual += mv.getFamilyLowQualsCount();
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class AlleleCount extends VariantStratifier {
|
|||
getVariantEvalWalker().getLogger().info("AlleleCount using " + nchrom + " chromosomes");
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String familyName) {
|
||||
if (eval != null) {
|
||||
int AC = 0; // by default, the site is considered monomorphic
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class AlleleFrequency extends VariantStratifier {
|
|||
}
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
if (eval != null) {
|
||||
try {
|
||||
return Collections.singletonList((Object)String.format("%.3f", (5.0 * MathUtils.round(eval.getAttributeAsDouble("AF", 0.0) / 5.0, 3))));
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class CompRod extends VariantStratifier implements RequiredStratification
|
|||
}
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
return Collections.singletonList((Object)compName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class Contig extends VariantStratifier {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
if (eval != null) {
|
||||
return Arrays.asList((Object)"all", eval.getChr());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class CpG extends VariantStratifier {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
boolean isCpG = false;
|
||||
if (ref != null && ref.getBases() != null) {
|
||||
String fwRefBases = new String(ref.getBases());
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class Degeneracy extends VariantStratifier {
|
|||
}
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
ArrayList<Object> relevantStates = new ArrayList<Object>();
|
||||
|
||||
relevantStates.add("all");
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class EvalRod extends VariantStratifier implements RequiredStratification
|
|||
}
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
return Arrays.asList((Object)evalName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* 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.stratifications;
|
||||
|
||||
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.evaluators.VariantSummary;
|
||||
import htsjdk.variant.variantcontext.VariantContext;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Stratifies the eval RODs by each family in the eval ROD, as described by the pedigree.
|
||||
*
|
||||
* This allows the system to analyze each family separately. This is particularly useful for the MendelianViolationEvaluator module.
|
||||
*/
|
||||
public class Family extends VariantStratifier {
|
||||
@Override
|
||||
public void initialize() {
|
||||
states.addAll(getVariantEvalWalker().getFamilyNamesForStratification());
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String familyName) {
|
||||
return Collections.singletonList((Object) familyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Class<? extends VariantEvaluator>> getIncompatibleEvaluators() {
|
||||
return new HashSet<Class<? extends VariantEvaluator>>(Arrays.asList(VariantSummary.class));
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ public class Filter extends VariantStratifier {
|
|||
states.add("raw");
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
ArrayList<Object> relevantStates = new ArrayList<Object>();
|
||||
|
||||
relevantStates.add("raw");
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class FunctionalClass extends VariantStratifier {
|
|||
}
|
||||
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
ArrayList<Object> relevantStates = new ArrayList<Object>();
|
||||
|
||||
relevantStates.add("all");
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class IndelSize extends VariantStratifier {
|
|||
}
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
if (eval != null && eval.isIndel() && eval.isBiallelic()) {
|
||||
try {
|
||||
int eventLength = 0;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class IntervalStratification extends VariantStratifier {
|
|||
states.addAll(Arrays.asList("all", "overlaps.intervals", "outside.intervals"));
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
if (eval != null) {
|
||||
final GenomeLoc loc = getVariantEvalWalker().getToolkit().getGenomeLocParser().createGenomeLoc(eval);
|
||||
IntervalTree<GenomeLoc> intervalTree = intervalTreeByContig.get(loc.getContig());
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class JexlExpression extends VariantStratifier implements StandardStratif
|
|||
}
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
ArrayList<Object> relevantStates = new ArrayList<Object>();
|
||||
relevantStates.add("none");
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class Novelty extends VariantStratifier implements StandardStratification
|
|||
knowns = getVariantEvalWalker().getKnowns();
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
if (tracker != null && eval != null) {
|
||||
final Collection<VariantContext> knownComps = tracker.getValues(knowns, ref.getLocus());
|
||||
for ( final VariantContext c : knownComps ) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class OneBPIndel extends VariantStratifier {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
if (eval != null && eval.isIndel()) {
|
||||
for ( int l : eval.getIndelLengths() )
|
||||
if ( Math.abs(l) > 1 )
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class Sample extends VariantStratifier {
|
|||
states.addAll(getVariantEvalWalker().getSampleNamesForStratification());
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
return Collections.singletonList((Object) sampleName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ public class SnpEffPositionModifier extends VariantStratifier {
|
|||
final String compName,
|
||||
final VariantContext eval,
|
||||
final String evalName,
|
||||
final String sampleName)
|
||||
final String sampleName,
|
||||
final String FamilyName)
|
||||
{
|
||||
final List<Object> relevantStates = new ArrayList<Object>();
|
||||
if (eval != null && eval.isVariant() && eval.hasAttribute(InfoFieldKey.EFFECT_KEY.getKeyName())) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class TandemRepeat extends VariantStratifier {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
if ( eval == null || ! eval.isIndel() )
|
||||
return ALL;
|
||||
else if ( GATKVariantContextUtils.isTandemRepeat(eval, ref.getForwardBases()) ) {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public abstract class VariantStratifier implements Comparable<VariantStratifier>
|
|||
|
||||
public abstract void initialize();
|
||||
|
||||
public abstract List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName);
|
||||
public abstract List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String familyName);
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class VariantType extends VariantStratifier {
|
|||
states.add(t.toString());
|
||||
}
|
||||
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
|
||||
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) {
|
||||
return eval == null ? Collections.emptyList() : Collections.singletonList((Object)eval.getType().toString());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
package org.broadinstitute.gatk.tools.walkers.varianteval.util;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.broadinstitute.gatk.engine.samples.Sample;
|
||||
import org.broadinstitute.gatk.utils.commandline.RodBinding;
|
||||
import org.broadinstitute.gatk.utils.contexts.ReferenceContext;
|
||||
import org.broadinstitute.gatk.utils.refdata.RefMetaDataTracker;
|
||||
|
|
@ -255,6 +256,7 @@ public class VariantEvalUtils {
|
|||
boolean byFilter,
|
||||
boolean subsetBySample,
|
||||
boolean trackPerSample,
|
||||
boolean trackPerFamily,
|
||||
boolean mergeTracks) {
|
||||
if (tracker == null)
|
||||
return null;
|
||||
|
|
@ -270,9 +272,10 @@ public class VariantEvalUtils {
|
|||
// First, filter the VariantContext to represent only the samples for evaluation
|
||||
VariantContext vcsub = vc;
|
||||
|
||||
if (subsetBySample && vc.hasGenotypes())
|
||||
if ((subsetBySample) && vc.hasGenotypes())
|
||||
vcsub = getSubsetOfVariantContext(vc, variantEvalWalker.getSampleNamesForEvaluation());
|
||||
|
||||
//always add a mapping for all samples together
|
||||
if ((byFilter || !vcsub.isFiltered())) {
|
||||
addMapping(mapping, VariantEval.getAllSampleName(), vcsub);
|
||||
}
|
||||
|
|
@ -287,6 +290,26 @@ public class VariantEvalUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (vc.hasGenotypes() && trackPerFamily) {
|
||||
for (final String familyName : variantEvalWalker.getFamilyNamesForEvaluation()) {
|
||||
Set<String> familyMemberNames = new HashSet<>();
|
||||
//if the current stratification family name is "all", then add all the families to the VC for evaluation here
|
||||
if (familyName.equals(VariantEval.getAllFamilyName())) {
|
||||
familyMemberNames = variantEvalWalker.getSampleNamesForEvaluation();
|
||||
}
|
||||
else {
|
||||
Set<Sample> familyMembers = variantEvalWalker.getToolkit().getSampleDB().getFamily(familyName);
|
||||
for (final Sample s : familyMembers) {
|
||||
familyMemberNames.add(s.getID());
|
||||
}
|
||||
}
|
||||
VariantContext samplevc = getSubsetOfVariantContext(vc, familyMemberNames);
|
||||
|
||||
if (byFilter || !samplevc.isFiltered()) {
|
||||
addMapping(mapping, familyName, samplevc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mergeTracks && bindings.containsKey(firstTrack)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue