Skip to content
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

Adds QD and AS_QD emission from VariantAnnotator on GVS input #8978

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

meganshand
Copy link
Contributor

Previously, AS_QD was ignored by VariantAnnotator since the annotate() function always returned an empty map. Now AS_QD will be added.

Also QD could only use QUAL as part of the calculation, but GVS output only contains the QUALapprox annotation. This change allows QD to be calculated from QUALapprox if QUAL is not present.

Copy link
Collaborator

@jamesemery jamesemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment about an exception that should/shouldn't be there and some minor comments about documentation but otherwise this looks reasonable to me. It looks like you are just bringing the QD annotation into parity with what it was already doing for AS_QD and it seems reasonable to me that it would operate this way

} else if (vc.hasAttribute(GATKVCFConstants.RAW_QUAL_APPROX_KEY)) {
qual = vc.getAttributeAsInt(GATKVCFConstants.RAW_QUAL_APPROX_KEY, 0);
} else {
throw new GATKException("No QUAL or QUAL_approx found in when calculating QD at " + vc.getContig() + ":" + vc.getStart());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exception is a little... messy? It really should never happen based on that check at the top but if it does happen its telling the user something that isn't quite an exception no? If those aren't there we just let the annotation through without issue at the top of this method so why crash here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point, not sure what I was trying to protect from here.

if (vc.hasLog10PError()) {
qual = -10.0 * vc.getLog10PError();
} else if (vc.hasAttribute(GATKVCFConstants.RAW_QUAL_APPROX_KEY)) {
qual = vc.getAttributeAsInt(GATKVCFConstants.RAW_QUAL_APPROX_KEY, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a catch for the NumberFormatException here that points out " + vc.getContig() + ":" + vc.getStart()) to the user for later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -364,6 +361,42 @@ public void testDeNovo() {
Assert.assertEquals(lociWithHighConfidenceDeNovo, new int[] {10130767, 10197999});
}

@Test
public void addQdToGvsVcf() {
final File inputVCF = getTestFile("gvsOutput.vcf");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this to something that gives a little more info about where this is form/why its in the test suite?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -78,7 +76,9 @@ public List<VCFCompoundHeaderLine> getRawDescriptions() {
public Map<String, Object> annotate(final ReferenceContext ref,
final VariantContext vc,
final AlleleLikelihoods<GATKRead, Allele> likelihoods ) {
return Collections.emptyMap();
// first vc is used for the annotation and the second vc here is used just to get the alleles, so in this case we can pass the same vc for both
Map<String, Object> annotation = finalizeRawData(vc, vc);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait so was this just totally broken except in combineGVCFs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, but I'm worried that I'm missing something and this was left unimplemented intentionally for some reason. But the behavior from VariantAnnotator was undesirable in that if you asked for AS_QD it just wouldn't do anything.

@@ -364,6 +361,42 @@ public void testDeNovo() {
Assert.assertEquals(lociWithHighConfidenceDeNovo, new int[] {10130767, 10197999});
}

@Test
public void addQdToGvsVcf() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment explaining that this has QUALapprox but no QUAL and that is what this is testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

@jamesemery jamesemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me from a code/gatk perspective. I'm not 1000% if there wasn't some good reason that these didn't work before but this is about as close to harmless of a change for these annotations as it gets. I think so you are probably good to merge.

@meganshand meganshand merged commit 2ba3a15 into master Sep 12, 2024
20 checks passed
@meganshand meganshand deleted the ms_qd_for_gvs branch September 12, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants