-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding TransmittedSingleton annotation and adding quality threshold a… #8329
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import htsjdk.variant.variantcontext.VariantContext; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.broadinstitute.barclay.argparser.Argument; | ||
import org.broadinstitute.barclay.help.DocumentedFeature; | ||
import org.broadinstitute.hellbender.engine.GATKPath; | ||
import org.broadinstitute.hellbender.engine.ReferenceContext; | ||
|
@@ -39,11 +40,24 @@ public final class PossibleDeNovo extends PedigreeAnnotation implements InfoFiel | |
private final MendelianViolation mendelianViolation; | ||
private Set<Trio> trios; | ||
|
||
@Argument(fullName = "denovo-parent-gq-threshold", doc = "Minimum genotype quality for parents to be considered for de novo calculation (separate from GQ thershold for full trio).", optional = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we have these new arguments can you add a test into the GATKAnnotationPluginDescriptorUnitTest to be really certain that this machinery works reasonably well with the pedigree file + these extra arguments? Sorry to ask this of you but we don't have a lot of examples of annotation arguments and I want to be sure it really works in the engine as expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to add this test, but please take a look and make sure it's doing what you expected. |
||
public int parentGQThreshold = hi_GQ_threshold; | ||
|
||
@Argument(fullName = "denovo-depth-threshold", doc = "Minimum depth (DP) for all trio members to be considered for de novo calculation.", optional = true) | ||
public int depthThreshold = 0; | ||
|
||
@VisibleForTesting | ||
public PossibleDeNovo(final Set<Trio> trios, final double minGenotypeQualityP) { | ||
public PossibleDeNovo(final Set<Trio> trios, final double minGenotypeQualityP, final int parentGQThreshold, final int depthThreshold) { | ||
super((Set<String>) null); | ||
this.trios = Collections.unmodifiableSet(new LinkedHashSet<>(trios)); | ||
mendelianViolation = new MendelianViolation(minGenotypeQualityP); | ||
this.parentGQThreshold = parentGQThreshold; | ||
this.depthThreshold = depthThreshold; | ||
} | ||
|
||
@VisibleForTesting | ||
public PossibleDeNovo(final Set<Trio> trios, final double minGenotypeQualityP) { | ||
this(trios, minGenotypeQualityP, hi_GQ_threshold, 0); | ||
} | ||
|
||
public PossibleDeNovo(final GATKPath pedigreeFile){ | ||
|
@@ -105,15 +119,20 @@ public Map<String, Object> annotate(final ReferenceContext ref, | |
final List<String> lowConfDeNovoChildren = new ArrayList<>(); | ||
for (final Trio trio : trioSet) { | ||
if (vc.isBiallelic() && | ||
PossibleDeNovo.contextHasTrioGQs(vc, trio) && | ||
contextHasTrioGQs(vc, trio) && | ||
mendelianViolation.isViolation(trio.getMother(), trio.getFather(), trio.getChild(), vc) && | ||
mendelianViolation.getParentsRefRefChildHet() > 0) { | ||
|
||
final int childGQ = vc.getGenotype(trio.getChildID()).getGQ(); | ||
final int momGQ = vc.getGenotype(trio.getMaternalID()).getGQ(); | ||
final int dadGQ = vc.getGenotype(trio.getPaternalID()).getGQ(); | ||
|
||
if (childGQ >= hi_GQ_threshold && momGQ >= hi_GQ_threshold && dadGQ >= hi_GQ_threshold) { | ||
final int childDP = vc.getGenotype(trio.getChildID()).getDP(); | ||
final int momDP = vc.getGenotype(trio.getMaternalID()).getDP(); | ||
final int dadDP = vc.getGenotype(trio.getPaternalID()).getDP(); | ||
|
||
if (childGQ >= hi_GQ_threshold && momGQ >= parentGQThreshold && dadGQ >= parentGQThreshold && | ||
childDP >= depthThreshold && momDP >= depthThreshold && dadDP >= depthThreshold) { | ||
highConfDeNovoChildren.add(trio.getChildID()); | ||
} else if (childGQ >= lo_GQ_threshold && momGQ > 0 && dadGQ > 0) { | ||
lowConfDeNovoChildren.add(trio.getChildID()); | ||
|
@@ -135,14 +154,4 @@ public Map<String, Object> annotate(final ReferenceContext ref, | |
return attributeMap; | ||
} | ||
|
||
private static boolean contextHasTrioGQs(final VariantContext vc, final Trio trio) { | ||
final String mom = trio.getMaternalID(); | ||
final String dad = trio.getPaternalID(); | ||
final String kid = trio.getChildID(); | ||
|
||
return (!mom.isEmpty() && vc.hasGenotype(mom) && vc.getGenotype(mom).hasGQ()) | ||
&& (!dad.isEmpty() && vc.hasGenotype(dad) && vc.getGenotype(dad).hasGQ()) | ||
&& (!kid.isEmpty() && vc.hasGenotype(kid) && vc.getGenotype(kid).hasGQ()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package org.broadinstitute.hellbender.tools.walkers.annotator; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import htsjdk.variant.variantcontext.Allele; | ||
import htsjdk.variant.variantcontext.VariantContext; | ||
import htsjdk.variant.vcf.VCFConstants; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.broadinstitute.barclay.argparser.ExperimentalFeature; | ||
import org.broadinstitute.barclay.help.DocumentedFeature; | ||
import org.broadinstitute.hellbender.engine.GATKPath; | ||
import org.broadinstitute.hellbender.engine.ReferenceContext; | ||
import org.broadinstitute.hellbender.utils.Utils; | ||
import org.broadinstitute.hellbender.utils.genotyper.AlleleLikelihoods; | ||
import org.broadinstitute.hellbender.utils.help.HelpConstants; | ||
import org.broadinstitute.hellbender.utils.read.GATKRead; | ||
import org.broadinstitute.hellbender.utils.samples.Trio; | ||
import org.broadinstitute.hellbender.utils.variant.GATKVCFConstants; | ||
|
||
import java.util.*; | ||
|
||
|
||
/** | ||
* Existence of a transmitted or non-transmitted singleton in at least one of the given families | ||
* | ||
* <p>This annotation uses the genotype information from individuals in family trios to identify transmitted and non-transmitted singletons and the sample(s) in which they occur. | ||
* Transmitted singletons occur at sites in a cohort where the allele count is two and these two alleles occur in one parent and the child of a trio. A non-transmitted singleton | ||
* are sites with an allele count of one and this one allele occurs in a parent, but not the child of a trio. In both cases the other parent must have a high quality hom ref call. | ||
* | ||
* <h3>Caveats</h3> | ||
* <ul> | ||
* <li>The calculation assumes that the organism is diploid.</li> | ||
* <li>This annotation requires a valid pedigree file.</li> | ||
* <li>Non transmitted singletons are only valid for trios, not quads or other more complicated family structures.</li> | ||
* <li>Only reports possible singletons for families where each of the three samples has high GQ (>20) and high depth (>20)</li> | ||
* <li>Only reports possible singletons at sites with a Call Rate greater than 90% (meaning less than 10% of the samples at the given site were no-calls)</li> | ||
* </ul> | ||
*/ | ||
@DocumentedFeature(groupName= HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Existence of a transmitted (or non-transmitted) singleton in at least one of the given families (transmittedSingleton, nonTransmittedSingleton)") | ||
public final class TransmittedSingleton extends PedigreeAnnotation implements InfoFieldAnnotation { | ||
protected final Logger warning = LogManager.getLogger(this.getClass()); | ||
private Set<Trio> trios; | ||
private final int HI_GQ_THRESHOLD = 20; | ||
private final int HI_DP_THRESHOLD = 20; | ||
private final double CALL_RATE_THRESHOLD = 0.90; | ||
|
||
@VisibleForTesting | ||
public TransmittedSingleton(final Set<Trio> trios) { | ||
super((Set<String>) null); | ||
this.trios = Collections.unmodifiableSet(new LinkedHashSet<>(trios)); | ||
} | ||
|
||
public TransmittedSingleton(final GATKPath pedigreeFile){ | ||
super(pedigreeFile); | ||
} | ||
|
||
public TransmittedSingleton(){ | ||
super((Set<String>) null); | ||
} | ||
|
||
private Set<Trio> initializeAndGetTrios() { | ||
if (trios == null) { | ||
trios = getTrios(); | ||
} | ||
return trios; | ||
} | ||
|
||
@Override | ||
public List<String> getKeyNames() { | ||
return Arrays.asList(GATKVCFConstants.TRANSMITTED_SINGLETON, GATKVCFConstants.NON_TRANSMITTED_SINGLETON); | ||
} | ||
@Override | ||
public Map<String, Object> annotate(final ReferenceContext ref, | ||
final VariantContext vc, | ||
final AlleleLikelihoods<GATKRead, Allele> likelihoods) { | ||
Utils.nonNull(vc); | ||
Set<Trio> trioSet = initializeAndGetTrios(); | ||
if (!vc.isBiallelic() || trioSet.isEmpty()) { | ||
return Collections.emptyMap(); | ||
} | ||
long highQualCalls = vc.getGenotypes().stream().filter(gt -> gt.getGQ() > HI_GQ_THRESHOLD).count(); | ||
if ((double) highQualCalls / vc.getNSamples() < CALL_RATE_THRESHOLD) { | ||
return Collections.emptyMap(); | ||
} | ||
final List<String> transmittedSingletonParent = new ArrayList<>(); | ||
final List<String> nonTransmittedSingletonParent = new ArrayList<>(); | ||
for (final Trio trio : trioSet) { | ||
if (vc.isBiallelic() && | ||
contextHasTrioGQs(vc, trio)) { | ||
|
||
final boolean oneParentHasAllele = (vc.getGenotype(trio.getMaternalID()).isHet() && vc.getGenotype(trio.getPaternalID()).isHomRef()) || (vc.getGenotype(trio.getMaternalID()).isHomRef() && vc.getGenotype(trio.getPaternalID()).isHet()); | ||
final String matchingParentId = vc.getGenotype(trio.getMaternalID()).isHet() ? trio.getMaternalID() : trio.getPaternalID(); | ||
|
||
final boolean momIsHighGQ = vc.getGenotype(trio.getMaternalID()).getGQ() >= HI_GQ_THRESHOLD; | ||
final boolean dadIsHighGQ = vc.getGenotype(trio.getPaternalID()).getGQ() >= HI_GQ_THRESHOLD; | ||
|
||
final boolean childIsHighGQHet = vc.getGenotype(trio.getChildID()).isHet() && vc.getGenotype(trio.getChildID()).getGQ() >= HI_GQ_THRESHOLD; | ||
final boolean childIsHighGQHomRef = vc.getGenotype(trio.getChildID()).isHomRef() && vc.getGenotype(trio.getChildID()).getGQ() >= HI_GQ_THRESHOLD; | ||
|
||
final boolean childIsHighDepth = vc.getGenotype(trio.getChildID()).getDP() >= HI_DP_THRESHOLD; | ||
final boolean momIsHighDepth = vc.getGenotype(trio.getChildID()).getDP() >= HI_DP_THRESHOLD; | ||
final boolean dadIsHighDepth = vc.getGenotype(trio.getChildID()).getDP() >= HI_DP_THRESHOLD; | ||
|
||
if (childIsHighDepth && momIsHighDepth && dadIsHighDepth && | ||
vc.getAttributeAsInt(VCFConstants.ALLELE_COUNT_KEY, 0) == 2 && | ||
childIsHighGQHet && oneParentHasAllele && momIsHighGQ && dadIsHighGQ) { | ||
transmittedSingletonParent.add(matchingParentId); | ||
} | ||
//TODO: This only works for trios (not quads or other more complicated family structures that would effect number of singletons for parents or transmission to multiple kids) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if the pedigree file has 2 kids in it? Will this clobber one/another? Should we add some defensive behavior to make sure this doesn't break anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have lots of singleton loggers putting warnings out about annotation warnings like this. IF you wanted to add a "detected a quad pedigree this will cause xyz problems" and we should probably at least have some tests codifying the behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made this all clearer and added a warning and a test. |
||
if (childIsHighDepth && momIsHighDepth && dadIsHighDepth && | ||
vc.getAttributeAsInt(VCFConstants.ALLELE_COUNT_KEY, 0) == 1 && | ||
childIsHighGQHomRef && momIsHighGQ && dadIsHighGQ) { | ||
nonTransmittedSingletonParent.add(matchingParentId); | ||
} | ||
} | ||
} | ||
|
||
final Map<String, Object> attributeMap = new LinkedHashMap<>(1); | ||
if (!transmittedSingletonParent.isEmpty()) { | ||
attributeMap.put(GATKVCFConstants.TRANSMITTED_SINGLETON, transmittedSingletonParent); | ||
} | ||
if (!nonTransmittedSingletonParent.isEmpty()) { | ||
attributeMap.put(GATKVCFConstants.NON_TRANSMITTED_SINGLETON, nonTransmittedSingletonParent); | ||
} | ||
return attributeMap; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,8 @@ public final class GATKVCFConstants { | |
public static final String GQ_STDEV_KEY = "GQ_STDDEV"; | ||
public static final String HAPLOTYPE_SCORE_KEY = "HaplotypeScore"; | ||
public static final String HI_CONF_DENOVO_KEY = "hiConfDeNovo"; | ||
public static final String TRANSMITTED_SINGLETON = "transmittedSingleton"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally these are captialized... i don't know if this breaks already run samples however... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to follow the PossibleDeNovo convention which has hiConfDeNovo and loConfDeNovo. Those have been in production a long time (unlike transmittedSingleton), so I'm hesitant to change them. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is low priority and you know better than i do. Feel free to ignore this comment I you like. |
||
public static final String NON_TRANSMITTED_SINGLETON = "nonTransmittedSingleton"; | ||
public static final String INTERVAL_GC_CONTENT_KEY = "IGC"; | ||
public static final String INBREEDING_COEFFICIENT_KEY = "InbreedingCoeff"; | ||
public static final String AS_INBREEDING_COEFFICIENT_KEY = "AS_InbreedingCoeff"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a descriptive comment to this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done