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);
|
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) {
|
private static String withSelect(String cmd, String select, String name) {
|
||||||
return String.format("%s -select '%s' -selectName %s", cmd, select, name);
|
return String.format("%s -select '%s' -selectName %s", cmd, select, name);
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ public class VariantEvalWalkerUnitTest extends BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
int i = Integer.valueOf(evalName); // a terrible hack, but we can now provide accessible states
|
||||||
List<Object> states = new ArrayList<Object>();
|
List<Object> states = new ArrayList<Object>();
|
||||||
for ( int state : integers )
|
for ( int state : integers )
|
||||||
|
|
@ -180,12 +180,12 @@ public class VariantEvalWalkerUnitTest extends BaseTest {
|
||||||
final RefMetaDataTracker tracker = new RefMetaDataTracker();
|
final RefMetaDataTracker tracker = new RefMetaDataTracker();
|
||||||
final ReferenceContext ref = null;
|
final ReferenceContext ref = null;
|
||||||
final VariantContext comp = 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
|
// increment eval counts for each stratification of divisors of i from from 1...maxI
|
||||||
for ( int i = 1; i <= cfg.maxI; i++ ) {
|
for ( int i = 1; i <= cfg.maxI; i++ ) {
|
||||||
final String evalName = String.valueOf(i); // terrible hack to stratify by divisor
|
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) {
|
synchronized (nec) {
|
||||||
nec.apply(tracker, ref, null, comp, eval);
|
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.reference.IndexedFastaSequenceFile;
|
||||||
import htsjdk.samtools.util.IntervalTree;
|
import htsjdk.samtools.util.IntervalTree;
|
||||||
import htsjdk.samtools.SAMSequenceRecord;
|
import htsjdk.samtools.SAMSequenceRecord;
|
||||||
|
import oracle.jrockit.jfr.StringConstantPool;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import htsjdk.tribble.Feature;
|
import htsjdk.tribble.Feature;
|
||||||
|
import org.broadinstitute.gatk.engine.samples.Trio;
|
||||||
import org.broadinstitute.gatk.engine.walkers.*;
|
import org.broadinstitute.gatk.engine.walkers.*;
|
||||||
import org.broadinstitute.gatk.tools.walkers.varianteval.evaluators.*;
|
import org.broadinstitute.gatk.tools.walkers.varianteval.evaluators.*;
|
||||||
import org.broadinstitute.gatk.utils.commandline.*;
|
import org.broadinstitute.gatk.utils.commandline.*;
|
||||||
|
|
@ -105,7 +107,7 @@ import java.util.*;
|
||||||
* </pre>
|
* </pre>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <h3>Usage example</h3>
|
* <h3>Usage examples</h3>
|
||||||
* <pre>
|
* <pre>
|
||||||
* java -jar GenomeAnalysisTK.jar \
|
* java -jar GenomeAnalysisTK.jar \
|
||||||
* -T VariantEval \
|
* -T VariantEval \
|
||||||
|
|
@ -116,6 +118,18 @@ import java.util.*;
|
||||||
* [--comp comp.vcf]
|
* [--comp comp.vcf]
|
||||||
* </pre>
|
* </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>
|
* <h3>Caveat</h3>
|
||||||
*
|
*
|
||||||
* <p>Some stratifications and evaluators are incompatible with each other due to their respective memory requirements,
|
* <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 boolean isSubsettingSamples;
|
||||||
private Set<String> sampleNamesForEvaluation = new LinkedHashSet<String>();
|
private Set<String> sampleNamesForEvaluation = new LinkedHashSet<String>();
|
||||||
|
private Set<String> familyNamesForEvaluation = new LinkedHashSet<String>();
|
||||||
private Set<String> sampleNamesForStratification = new LinkedHashSet<String>();
|
private Set<String> sampleNamesForStratification = new LinkedHashSet<String>();
|
||||||
|
private Set<String> familyNamesForStratification = new LinkedHashSet<String>();
|
||||||
|
|
||||||
// important stratifications
|
// important stratifications
|
||||||
private boolean byFilterIsEnabled = false;
|
private boolean byFilterIsEnabled = false;
|
||||||
private boolean perSampleIsEnabled = false;
|
private boolean perSampleIsEnabled = false;
|
||||||
|
private boolean perFamilyIsEnabled = false;
|
||||||
|
|
||||||
// Public constants
|
// 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
|
// the number of processed bp for this walker
|
||||||
long nProcessedLoci = 0;
|
long nProcessedLoci = 0;
|
||||||
|
|
@ -303,12 +321,22 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
||||||
final Set<String> allSampleNames = SampleUtils.getSamplesFromCommandLineInput(vcfSamples);
|
final Set<String> allSampleNames = SampleUtils.getSamplesFromCommandLineInput(vcfSamples);
|
||||||
sampleNamesForEvaluation.addAll(new TreeSet<String>(SampleUtils.getSamplesFromCommandLineInput(vcfSamples, SAMPLE_EXPRESSIONS)));
|
sampleNamesForEvaluation.addAll(new TreeSet<String>(SampleUtils.getSamplesFromCommandLineInput(vcfSamples, SAMPLE_EXPRESSIONS)));
|
||||||
isSubsettingSamples = ! sampleNamesForEvaluation.containsAll(allSampleNames);
|
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);
|
sampleNamesForStratification.addAll(sampleNamesForEvaluation);
|
||||||
}
|
}
|
||||||
|
//...and also a stratification for the sum over all samples
|
||||||
sampleNamesForStratification.add(ALL_SAMPLE_NAME);
|
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
|
// Initialize select expressions
|
||||||
for (VariantContextUtils.JexlVCMatchExp jexl : VariantContextUtils.initializeMatchExps(SELECT_NAMES, SELECT_EXPS)) {
|
for (VariantContextUtils.JexlVCMatchExp jexl : VariantContextUtils.initializeMatchExps(SELECT_NAMES, SELECT_EXPS)) {
|
||||||
SortableJexlVCMatchExp sjexl = new SortableJexlVCMatchExp(jexl.name, jexl.exp);
|
SortableJexlVCMatchExp sjexl = new SortableJexlVCMatchExp(jexl.name, jexl.exp);
|
||||||
|
|
@ -327,8 +355,17 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
||||||
byFilterIsEnabled = true;
|
byFilterIsEnabled = true;
|
||||||
else if ( vs.getName().equals("Sample") )
|
else if ( vs.getName().equals("Sample") )
|
||||||
perSampleIsEnabled = true;
|
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 ) {
|
if ( intervalsFile != null ) {
|
||||||
boolean fail = true;
|
boolean fail = true;
|
||||||
for ( final VariantStratifier vs : stratificationObjects ) {
|
for ( final VariantStratifier vs : stratificationObjects ) {
|
||||||
|
|
@ -420,17 +457,24 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// --------- track --------- sample - VariantContexts -
|
// --------- 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>>> 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);
|
HashMap<RodBinding<VariantContext>, HashMap<String, Collection<VariantContext>>> compVCs = variantEvalUtils.bindVariantContexts(tracker, ref, comps, byFilterIsEnabled, false, false, false, false);
|
||||||
|
|
||||||
// for each eval track
|
// for each eval track
|
||||||
for ( final RodBinding<VariantContext> evalRod : evals ) {
|
for ( final RodBinding<VariantContext> evalRod : evals ) {
|
||||||
final Map<String, Collection<VariantContext>> emptyEvalMap = Collections.emptyMap();
|
final Map<String, Collection<VariantContext>> emptyEvalMap = Collections.emptyMap();
|
||||||
final Map<String, Collection<VariantContext>> evalSet = evalVCs.containsKey(evalRod) ? evalVCs.get(evalRod) : emptyEvalMap;
|
final Map<String, Collection<VariantContext>> evalSet = evalVCs.containsKey(evalRod) ? evalVCs.get(evalRod) : emptyEvalMap;
|
||||||
|
|
||||||
|
Set<String> statificationLevels;
|
||||||
|
|
||||||
// for each sample stratifier
|
// for each sample stratifier
|
||||||
for ( final String sampleName : sampleNamesForStratification ) {
|
if (perFamilyIsEnabled)
|
||||||
Collection<VariantContext> evalSetBySample = evalSet.get(sampleName);
|
statificationLevels = familyNamesForStratification;
|
||||||
|
else
|
||||||
|
statificationLevels = sampleNamesForStratification;
|
||||||
|
for ( final String stratLevelName : statificationLevels ) {
|
||||||
|
Collection<VariantContext> evalSetBySample = evalSet.get(stratLevelName);
|
||||||
|
|
||||||
if ( evalSetBySample == null ) {
|
if ( evalSetBySample == null ) {
|
||||||
evalSetBySample = new HashSet<VariantContext>(1);
|
evalSetBySample = new HashSet<VariantContext>(1);
|
||||||
evalSetBySample.add(null);
|
evalSetBySample.add(null);
|
||||||
|
|
@ -452,7 +496,18 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
||||||
// find the comp
|
// find the comp
|
||||||
final VariantContext comp = findMatchingComp(eval, compSet);
|
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
|
// eval against the comp
|
||||||
synchronized (nec) {
|
synchronized (nec) {
|
||||||
|
|
@ -521,10 +576,11 @@ public class VariantEval extends RodWalker<Integer, Integer> implements TreeRedu
|
||||||
final String evalName,
|
final String evalName,
|
||||||
final VariantContext comp,
|
final VariantContext comp,
|
||||||
final String compName,
|
final String compName,
|
||||||
final String sampleName ) {
|
final String sampleName,
|
||||||
|
final String familyName) {
|
||||||
final List<List<Object>> states = new LinkedList<List<Object>>();
|
final List<List<Object>> states = new LinkedList<List<Object>>();
|
||||||
for ( final VariantStratifier vs : stratManager.getStratifiers() ) {
|
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);
|
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 double getMendelianViolationQualThreshold() { return MENDELIAN_VIOLATION_QUAL_THRESHOLD; }
|
||||||
|
|
||||||
public static String getAllSampleName() { return ALL_SAMPLE_NAME; }
|
public static String getAllSampleName() { return ALL_SAMPLE_NAME; }
|
||||||
|
public static String getAllFamilyName() { return ALL_FAMILY_NAME; }
|
||||||
|
|
||||||
public List<RodBinding<VariantContext>> getKnowns() { return knowns; }
|
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 boolean isSubsettingToSpecificSamples() { return isSubsettingSamples; }
|
||||||
public Set<String> getSampleNamesForEvaluation() { return sampleNamesForEvaluation; }
|
public Set<String> getSampleNamesForEvaluation() { return sampleNamesForEvaluation; }
|
||||||
|
|
||||||
|
public Set<String> getFamilyNamesForEvaluation() { return familyNamesForEvaluation; }
|
||||||
|
|
||||||
public int getNumberOfSamplesForEvaluation() {
|
public int getNumberOfSamplesForEvaluation() {
|
||||||
if (sampleNamesForEvaluation!= null && !sampleNamesForEvaluation.isEmpty())
|
if (sampleNamesForEvaluation!= null && !sampleNamesForEvaluation.isEmpty())
|
||||||
return sampleNamesForEvaluation.size();
|
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> getSampleNamesForStratification() { return sampleNamesForStratification; }
|
||||||
|
|
||||||
|
public Set<String> getFamilyNamesForStratification() { return familyNamesForStratification; }
|
||||||
|
|
||||||
public List<RodBinding<VariantContext>> getComps() { return comps; }
|
public List<RodBinding<VariantContext>> getComps() { return comps; }
|
||||||
|
|
||||||
public Set<SortableJexlVCMatchExp> getJexlExpressions() { return jexlExpressions; }
|
public Set<SortableJexlVCMatchExp> getJexlExpressions() { return jexlExpressions; }
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ public class MendelianViolationEvaluator extends VariantEvaluator {
|
||||||
HomVarHet_inheritedRef += mv.getParentsVarHetInheritedRef();
|
HomVarHet_inheritedRef += mv.getParentsVarHetInheritedRef();
|
||||||
HomVarHet_inheritedVar += mv.getParentsVarHetInheritedVar();
|
HomVarHet_inheritedVar += mv.getParentsVarHetInheritedVar();
|
||||||
|
|
||||||
if(mv.getFamilyCalledCount()>0){
|
if(mv.getFamilyCalledCount()>0 || mv.getFamilyLowQualsCount()>0 || mv.getFamilyCalledCount()>0){
|
||||||
nVariants++;
|
nVariants++;
|
||||||
nFamCalled += mv.getFamilyCalledCount();
|
nFamCalled += mv.getFamilyCalledCount();
|
||||||
nLowQual += mv.getFamilyLowQualsCount();
|
nLowQual += mv.getFamilyLowQualsCount();
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ public class AlleleCount extends VariantStratifier {
|
||||||
getVariantEvalWalker().getLogger().info("AlleleCount using " + nchrom + " chromosomes");
|
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) {
|
if (eval != null) {
|
||||||
int AC = 0; // by default, the site is considered monomorphic
|
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) {
|
if (eval != null) {
|
||||||
try {
|
try {
|
||||||
return Collections.singletonList((Object)String.format("%.3f", (5.0 * MathUtils.round(eval.getAttributeAsDouble("AF", 0.0) / 5.0, 3))));
|
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);
|
return Collections.singletonList((Object)compName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class Contig extends VariantStratifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (eval != null) {
|
||||||
return Arrays.asList((Object)"all", eval.getChr());
|
return Arrays.asList((Object)"all", eval.getChr());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class CpG extends VariantStratifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
boolean isCpG = false;
|
||||||
if (ref != null && ref.getBases() != null) {
|
if (ref != null && ref.getBases() != null) {
|
||||||
String fwRefBases = new String(ref.getBases());
|
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>();
|
ArrayList<Object> relevantStates = new ArrayList<Object>();
|
||||||
|
|
||||||
relevantStates.add("all");
|
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);
|
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");
|
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>();
|
ArrayList<Object> relevantStates = new ArrayList<Object>();
|
||||||
|
|
||||||
relevantStates.add("raw");
|
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>();
|
ArrayList<Object> relevantStates = new ArrayList<Object>();
|
||||||
|
|
||||||
relevantStates.add("all");
|
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()) {
|
if (eval != null && eval.isIndel() && eval.isBiallelic()) {
|
||||||
try {
|
try {
|
||||||
int eventLength = 0;
|
int eventLength = 0;
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ public class IntervalStratification extends VariantStratifier {
|
||||||
states.addAll(Arrays.asList("all", "overlaps.intervals", "outside.intervals"));
|
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) {
|
if (eval != null) {
|
||||||
final GenomeLoc loc = getVariantEvalWalker().getToolkit().getGenomeLocParser().createGenomeLoc(eval);
|
final GenomeLoc loc = getVariantEvalWalker().getToolkit().getGenomeLocParser().createGenomeLoc(eval);
|
||||||
IntervalTree<GenomeLoc> intervalTree = intervalTreeByContig.get(loc.getContig());
|
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>();
|
ArrayList<Object> relevantStates = new ArrayList<Object>();
|
||||||
relevantStates.add("none");
|
relevantStates.add("none");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class Novelty extends VariantStratifier implements StandardStratification
|
||||||
knowns = getVariantEvalWalker().getKnowns();
|
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) {
|
if (tracker != null && eval != null) {
|
||||||
final Collection<VariantContext> knownComps = tracker.getValues(knowns, ref.getLocus());
|
final Collection<VariantContext> knownComps = tracker.getValues(knowns, ref.getLocus());
|
||||||
for ( final VariantContext c : knownComps ) {
|
for ( final VariantContext c : knownComps ) {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class OneBPIndel extends VariantStratifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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()) {
|
if (eval != null && eval.isIndel()) {
|
||||||
for ( int l : eval.getIndelLengths() )
|
for ( int l : eval.getIndelLengths() )
|
||||||
if ( Math.abs(l) > 1 )
|
if ( Math.abs(l) > 1 )
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class Sample extends VariantStratifier {
|
||||||
states.addAll(getVariantEvalWalker().getSampleNamesForStratification());
|
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);
|
return Collections.singletonList((Object) sampleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,8 @@ public class SnpEffPositionModifier extends VariantStratifier {
|
||||||
final String compName,
|
final String compName,
|
||||||
final VariantContext eval,
|
final VariantContext eval,
|
||||||
final String evalName,
|
final String evalName,
|
||||||
final String sampleName)
|
final String sampleName,
|
||||||
|
final String FamilyName)
|
||||||
{
|
{
|
||||||
final List<Object> relevantStates = new ArrayList<Object>();
|
final List<Object> relevantStates = new ArrayList<Object>();
|
||||||
if (eval != null && eval.isVariant() && eval.hasAttribute(InfoFieldKey.EFFECT_KEY.getKeyName())) {
|
if (eval != null && eval.isVariant() && eval.hasAttribute(InfoFieldKey.EFFECT_KEY.getKeyName())) {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class TandemRepeat extends VariantStratifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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() )
|
if ( eval == null || ! eval.isIndel() )
|
||||||
return ALL;
|
return ALL;
|
||||||
else if ( GATKVariantContextUtils.isTandemRepeat(eval, ref.getForwardBases()) ) {
|
else if ( GATKVariantContextUtils.isTandemRepeat(eval, ref.getForwardBases()) ) {
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public abstract class VariantStratifier implements Comparable<VariantStratifier>
|
||||||
|
|
||||||
public abstract void initialize();
|
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());
|
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());
|
return eval == null ? Collections.emptyList() : Collections.singletonList((Object)eval.getType().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
package org.broadinstitute.gatk.tools.walkers.varianteval.util;
|
package org.broadinstitute.gatk.tools.walkers.varianteval.util;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.broadinstitute.gatk.engine.samples.Sample;
|
||||||
import org.broadinstitute.gatk.utils.commandline.RodBinding;
|
import org.broadinstitute.gatk.utils.commandline.RodBinding;
|
||||||
import org.broadinstitute.gatk.utils.contexts.ReferenceContext;
|
import org.broadinstitute.gatk.utils.contexts.ReferenceContext;
|
||||||
import org.broadinstitute.gatk.utils.refdata.RefMetaDataTracker;
|
import org.broadinstitute.gatk.utils.refdata.RefMetaDataTracker;
|
||||||
|
|
@ -255,6 +256,7 @@ public class VariantEvalUtils {
|
||||||
boolean byFilter,
|
boolean byFilter,
|
||||||
boolean subsetBySample,
|
boolean subsetBySample,
|
||||||
boolean trackPerSample,
|
boolean trackPerSample,
|
||||||
|
boolean trackPerFamily,
|
||||||
boolean mergeTracks) {
|
boolean mergeTracks) {
|
||||||
if (tracker == null)
|
if (tracker == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -270,9 +272,10 @@ public class VariantEvalUtils {
|
||||||
// First, filter the VariantContext to represent only the samples for evaluation
|
// First, filter the VariantContext to represent only the samples for evaluation
|
||||||
VariantContext vcsub = vc;
|
VariantContext vcsub = vc;
|
||||||
|
|
||||||
if (subsetBySample && vc.hasGenotypes())
|
if ((subsetBySample) && vc.hasGenotypes())
|
||||||
vcsub = getSubsetOfVariantContext(vc, variantEvalWalker.getSampleNamesForEvaluation());
|
vcsub = getSubsetOfVariantContext(vc, variantEvalWalker.getSampleNamesForEvaluation());
|
||||||
|
|
||||||
|
//always add a mapping for all samples together
|
||||||
if ((byFilter || !vcsub.isFiltered())) {
|
if ((byFilter || !vcsub.isFiltered())) {
|
||||||
addMapping(mapping, VariantEval.getAllSampleName(), vcsub);
|
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)) {
|
if (mergeTracks && bindings.containsKey(firstTrack)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue