-
Notifications
You must be signed in to change notification settings - Fork 593
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
...main/java/org/broadinstitute/hellbender/tools/walkers/annotator/TransmittedSingleton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
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.logging.OneShotLogger; | ||
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>This annotation is 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 final OneShotLogger oneShotLogger = new OneShotLogger(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(); | ||
} | ||
final long numOfTrios = trios.stream().map(trio -> trio.getMother().getFamilyID()).count(); | ||
if (numOfTrios == 0) { | ||
oneShotLogger.warn("Submitted pedigree has no trios. TransmittedSingleton annotation will not be calculated."); | ||
} else if (numOfTrios != trios.stream().map(trio -> trio.getMother().getFamilyID()).distinct().count()) { | ||
oneShotLogger.warn("Submitted pedigree has non-trio families. TransmittedSingleton annotation is only valid for trios. Non-trio families (such as quads) will be ignored."); | ||
} | ||
return trios; | ||
} | ||
|
||
@Override | ||
void validateArguments(Collection<String> founderIds, GATKPath pedigreeFile) { | ||
String warningString = validateArgumentsWhenPedigreeRequired(founderIds, pedigreeFile); | ||
if (warningString != null) { | ||
warning.warn(warningString); | ||
} | ||
} | ||
|
||
@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; | ||
|
||
//TODO: This only works for trios (not quads or other more complicated family structures that would make the AC>2) | ||
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 make the AC>1) | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 comment
The 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 comment
The 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.