Skip to content

Commit

Permalink
Adding argument to keep site level filters in ReblockGVCFs (#8304)
Browse files Browse the repository at this point in the history
  • Loading branch information
meganshand authored May 3, 2023
1 parent d2783f7 commit ba483e3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public final class ReblockGVCF extends MultiVariantWalker {
public static final String QUAL_APPROX_LONG_NAME = "do-qual-score-approximation";
public static final String QUAL_APPROX_SHORT_NAME = "do-qual-approx";
public static final String ALLOW_MISSING_LONG_NAME = "allow-missing-hom-ref-data";
public static final String KEEP_SITE_FILTERS_LONG_NAME = "keep-site-filters";
public static final String KEEP_SITE_FILTERS_SHORT_NAME = "keep_filters";

private static final GenotypeLikelihoodCalculators GL_CALCS = new GenotypeLikelihoodCalculators();

Expand Down Expand Up @@ -163,6 +165,10 @@ public final class ReblockGVCF extends MultiVariantWalker {
@Argument(fullName=KEEP_ALL_ALTS_ARG_NAME, doc="Keep all ALT alleles and full PL array for most accurate GQs", optional = true)
protected boolean keepAllAlts = false;

@Advanced
@Argument(fullName=KEEP_SITE_FILTERS_LONG_NAME, shortName = KEEP_SITE_FILTERS_SHORT_NAME, doc="Keep site level filters for variants (not ref blocks).")
private boolean keepFilters = false;

//TODO: this will be an argument when posteriors handling is fully implemented in AlleleSubsettingUtils
protected String posteriorsKey = null;

Expand Down Expand Up @@ -648,7 +654,7 @@ VariantContext cleanUpHighQualityVariant(final VariantContext variant) {

composeUpdatedAnnotations(attrMap, doQualApprox, posteriorsKey, variant, annotationEngine, relevantIndices, updatedAllelesVC, annotationsToKeep);

return builder.attributes(attrMap).unfiltered().make();
return keepFilters ? builder.attributes(attrMap).make() : builder.attributes(attrMap).unfiltered().make();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,28 @@ public void testDragenGvcfs() {
}
}
}

@Test
public void testFilters() throws IOException {
final File input = getTestFile("dragen.g.vcf");
final File output = createTempFile("reblockedgvcf", ".vcf");

final ArgumentsBuilder args = new ArgumentsBuilder();
args.addReference(new File(hg38Reference))
.add("V", input)
.add("L", "chr1")
.add(ReblockGVCF.KEEP_SITE_FILTERS_LONG_NAME, true)
.addOutput(output);
runCommandLine(args);

final VariantContext filteredVC = VariantContextTestUtils.readEntireVCFIntoMemory(output.getAbsolutePath()).getRight().get(3); // last site in the file
Assert.assertTrue(filteredVC.isFiltered());

final VariantContext unfilteredVC = VariantContextTestUtils.readEntireVCFIntoMemory(output.getAbsolutePath()).getRight().get(1);
Assert.assertFalse(unfilteredVC.isFiltered());

final VariantContext filteredRefBlockVC = VariantContextTestUtils.readEntireVCFIntoMemory(output.getAbsolutePath()).getRight().get(0);
Assert.assertFalse(filteredRefBlockVC.isFiltered()); // Ref block is unfiltered even though the input RefBlock and low qual variant were both filtered
Assert.assertEquals(filteredRefBlockVC.getGenotype(0).getDP(), 12); // Ref block is combination of filtered variant with depth 22 and filtered ref block with depth 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3407,4 +3407,8 @@
##contig=<ID=HLA-DRB1*16:02:01,length=11005>
##source=SelectVariants
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT sample
chr1 17407 . G A,<NON_REF> 2.58 DRAGENHardQUAL DP=22;MQ=14.54;MQRankSum=-0.638;ReadPosRankSum=0.128;FractionInformativeReads=1.000;R2_5P_bias=0.000 GT:AD:AF:DP:F1R2:F2R1:GQ:PL:SPL:ICNT:GP:PRI:SB:MB 0/0:18,4,0:0.182,0.000:22:10,1,0:8,3,0:3:34,0,25,127,572,699:73,0,255:18,0:2.5754e+00,3.5005e+00,3.1500e+01,1.3057e+02,4.5000e+02,4.5000e+02:0.00,34.77,37.77,34.77,69.54,37.77:11,7,2,2:7,11,1,3
chr1 17408 . C <NON_REF> . LowDepth END=939435 GT:AD:DP:GQ:MIN_DP:PL:SPL:ICNT ./.:1,0:1:0:0:0,0,0:0,0,0:1,0
chr1 939436 . C CCCCCTCATCACCTCCCCAGCCACGGTGAGGACCCACCCTGGCATGATCT,CT,<NON_REF> 71.98 PASS DP=25;FractionInformativeReads=0.280;MQ=232.84 GT:AD:AF:DP:F1R2:F2R1:GQ:PL:SPL:ICNT:GP:PRI:SB:MB 1/1:0,6,1,0:0.857,0.143,0.000:7:0,3,0,0:0,3,1,0:22:104,25,0,289,33,112,275,18,290,268:133,0,255:20,7:7.1980e+01,2.1980e+01,2.7671e-02,2.8634e+02,5.9197e+01,1.1220e+02,2.7740e+02,4.9515e+01,3.2148e+02,2.7422e+02:0.00,29.00,32.00,29.00,58.00,32.00,34.77,63.77,63.77,37.77:0,0,3,4:0,0,3,4
chr1 939437 . C <NON_REF> . PASS END=1634404 GT:AD:DP:GQ:MIN_DP:PL:SPL:ICNT 0/0:18,0:18:42:15:0,42,489:0,45,255:19,0
chr1 1634405 . CCGG C,<NON_REF> 3.78 DRAGENHardQUAL DP=13;MQ=19.35;MQRankSum=-1.437;ReadPosRankSum=1.437;FractionInformativeReads=1.000;R2_5P_bias=0.000 GT:AD:AF:DP:F1R2:F2R1:GQ:PL:SPL:ICNT:GP:PRI:SB:MB 0/1:10,3,0:0.231,0.000:13:8,2,0:2,1,0:4:30,0,28,118,356,474:68,0,255:8,4:3.7805e+00,2.3598e+00,3.3360e+01,1.2609e+02,3.9345e+02,4.5000e+02:0.00,29.00,32.00,34.77,63.77,37.77:3,7,0,3:3,7,1,2
Binary file not shown.

0 comments on commit ba483e3

Please sign in to comment.