diff --git a/src/main/java/org/broadinstitute/hellbender/tools/gvs/common/FilterSensitivityTools.java b/src/main/java/org/broadinstitute/hellbender/tools/gvs/common/FilterSensitivityTools.java index b4231fd62b2..33ebcd0f659 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/gvs/common/FilterSensitivityTools.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/gvs/common/FilterSensitivityTools.java @@ -123,11 +123,20 @@ public static VCFHeaderLine getVqsLodHeader(Double vqsLodThreshold, String model "Site failed " + model + " model VQSLOD cutoff of " + vqsLodThreshold.toString()); } - public static VCFHeaderLine getTruthSensitivityHeader(Double truthSensitivityThreshold, Double vqsLodThreshold, String model) { + public static VCFHeaderLine getTruthSensitivityFilterHeader(Double truthSensitivityThreshold, Double vqsLodThreshold, String model) { if (truthSensitivityThreshold == null) { // at this point, we know that all vqsr threshold inputs are null, so use defaults truthSensitivityThreshold = GATKVCFConstants.SNP.contains(model) ? DEFAULT_TRUTH_SENSITIVITY_THRESHOLD_SNPS : DEFAULT_TRUTH_SENSITIVITY_THRESHOLD_INDELS; } return new VCFFilterHeaderLine(GATKVCFConstants.VQSR_FAILURE_PREFIX + model, "Site failed " + model + " model sensitivity cutoff (" + truthSensitivityThreshold + "), corresponding with VQSLOD cutoff of " + vqsLodThreshold.toString()); } + + public static VCFHeaderLine getTruthSensitivityHeader(Double truthSensitivityThreshold, Double vqsLodThreshold, String model) { + if (truthSensitivityThreshold == null) { // at this point, we know that all vqsr threshold inputs are null, so use defaults + truthSensitivityThreshold = GATKVCFConstants.SNP.contains(model) ? DEFAULT_TRUTH_SENSITIVITY_THRESHOLD_SNPS : DEFAULT_TRUTH_SENSITIVITY_THRESHOLD_INDELS; + } + return new VCFHeaderLine(GATKVCFConstants.VQSR_FAILURE_PREFIX + model, + "Sample Genotype FT filter value indicating that the genotyped allele failed " + model + " model sensitivity cutoff (" + truthSensitivityThreshold + "), corresponding with VQSLOD cutoff of " + vqsLodThreshold.toString()); + } + } diff --git a/src/main/java/org/broadinstitute/hellbender/tools/gvs/extract/ExtractCohort.java b/src/main/java/org/broadinstitute/hellbender/tools/gvs/extract/ExtractCohort.java index 809d33e2f66..e1e701f765c 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/gvs/extract/ExtractCohort.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/gvs/extract/ExtractCohort.java @@ -130,7 +130,7 @@ public enum VQScoreFilteringType {GENOTYPE, SITES, NONE} @Argument( fullName = "vqs-score-filter-by-site", - doc = "If Variant Quality Score filtering is applied, it should be at a site level. Default is false", + doc = "If Variant Quality Score filtering (either VETS or VQSR) is applied, it should be at a site level. Default is false", optional = true ) // historical note that this parameter was previously named 'vqsr-score-filter-by-site', changed as it's not VQSR-specific @@ -341,8 +341,15 @@ protected void onStartup() { vqsLodSNPThreshold = FilterSensitivityTools.getVqslodThreshold(trancheMaps.get(GATKVCFConstants.SNP), truthSensitivitySNPThreshold, GATKVCFConstants.SNP); vqsLodINDELThreshold = FilterSensitivityTools.getVqslodThreshold(trancheMaps.get(GATKVCFConstants.INDEL), truthSensitivityINDELThreshold, GATKVCFConstants.INDEL); // set headers - extraHeaderLines.add(FilterSensitivityTools.getTruthSensitivityHeader(truthSensitivitySNPThreshold, vqsLodSNPThreshold, GATKVCFConstants.SNP)); - extraHeaderLines.add(FilterSensitivityTools.getTruthSensitivityHeader(truthSensitivityINDELThreshold, vqsLodINDELThreshold, GATKVCFConstants.INDEL)); + + if (vqScoreFilteringType.equals(VQScoreFilteringType.SITES)) { + extraHeaderLines.add(FilterSensitivityTools.getTruthSensitivityFilterHeader(truthSensitivitySNPThreshold, vqsLodSNPThreshold, GATKVCFConstants.SNP)); + extraHeaderLines.add(FilterSensitivityTools.getTruthSensitivityFilterHeader(truthSensitivityINDELThreshold, vqsLodINDELThreshold, GATKVCFConstants.INDEL)); + } + else if (vqScoreFilteringType.equals(VQScoreFilteringType.GENOTYPE)) { + extraHeaderLines.add(FilterSensitivityTools.getTruthSensitivityHeader(truthSensitivitySNPThreshold, vqsLodSNPThreshold, GATKVCFConstants.SNP)); + extraHeaderLines.add(FilterSensitivityTools.getTruthSensitivityHeader(truthSensitivityINDELThreshold, vqsLodINDELThreshold, GATKVCFConstants.INDEL)); + } } } else { extraHeaderLines.add(GATKVCFHeaderLines.getInfoLine(GATKVCFConstants.SCORE_KEY)); @@ -359,15 +366,23 @@ protected void onStartup() { truthSensitivityINDELThreshold /= 100.0; logger.info("Passing all INDEL variants with " + GATKVCFConstants.CALIBRATION_SENSITIVITY_KEY + " < " + truthSensitivityINDELThreshold); - extraHeaderLines.add(new VCFFilterHeaderLine(GATKVCFConstants.CALIBRATION_SENSITIVITY_FAILURE_SNP, - "Site failed SNP model calibration sensitivity cutoff (" + truthSensitivitySNPThreshold.toString() + ")")); - extraHeaderLines.add(new VCFFilterHeaderLine(GATKVCFConstants.CALIBRATION_SENSITIVITY_FAILURE_INDEL, - "Site failed INDEL model calibration sensitivity cutoff (" + truthSensitivityINDELThreshold.toString() + ")")); + if (vqScoreFilteringType.equals(VQScoreFilteringType.SITES)) { + extraHeaderLines.add(new VCFFilterHeaderLine(GATKVCFConstants.CALIBRATION_SENSITIVITY_FAILURE_SNP, + "Site failed SNP model calibration sensitivity cutoff (" + truthSensitivitySNPThreshold.toString() + ")")); + extraHeaderLines.add(new VCFFilterHeaderLine(GATKVCFConstants.CALIBRATION_SENSITIVITY_FAILURE_INDEL, + "Site failed INDEL model calibration sensitivity cutoff (" + truthSensitivityINDELThreshold.toString() + ")")); + } + else if (vqScoreFilteringType.equals(VQScoreFilteringType.GENOTYPE)) { + extraHeaderLines.add(new VCFHeaderLine(GATKVCFConstants.CALIBRATION_SENSITIVITY_FAILURE_SNP, + "Sample Genotype FT filter value indicating that the genotyped allele failed SNP model calibration sensitivity cutoff (" + truthSensitivitySNPThreshold.toString() + ")")); + extraHeaderLines.add(new VCFHeaderLine(GATKVCFConstants.CALIBRATION_SENSITIVITY_FAILURE_INDEL, + "Sample Genotype FT filter value indicating that the genotyped allele failed INDEL model calibration sensitivity cutoff (" + truthSensitivityINDELThreshold.toString() + ")")); + } } } if (vqScoreFilteringType.equals(VQScoreFilteringType.GENOTYPE)) { - extraHeaderLines.add(new VCFFormatHeaderLine("FT", 1, VCFHeaderLineType.String, "Genotype Filter Field")); + extraHeaderLines.add(new VCFFormatHeaderLine("FT", 1, VCFHeaderLineType.String, "Sample Genotype Filter Field")); } if (emitPLs) { diff --git a/src/test/java/org/broadinstitute/hellbender/tools/gvs/common/FilterSensitivityToolsTest.java b/src/test/java/org/broadinstitute/hellbender/tools/gvs/common/FilterSensitivityToolsTest.java index 2aa1952c39d..e022c883970 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/gvs/common/FilterSensitivityToolsTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/gvs/common/FilterSensitivityToolsTest.java @@ -15,12 +15,12 @@ public class FilterSensitivityToolsTest { // for testing inputs - private Double definedDoubleInput = 0.0; - private Double undefinedDoubleInput = null; - private String definedStringInput = "I'm defined!"; - private String undefinedStringInput = null; + private final Double definedDoubleInput = 0.0; + private final Double undefinedDoubleInput = null; + private final String definedStringInput = "I'm defined!"; + private final String undefinedStringInput = null; - private Map testTrancheMap = new TreeMap<>(); + private final Map testTrancheMap = new TreeMap<>(); @BeforeMethod public void setUp() { @@ -211,7 +211,7 @@ public void testGetTruthSensitivityHeaderSNP() { VCFFilterHeaderLine expectedHeader = new VCFFilterHeaderLine(GATKVCFConstants.VQSR_FAILURE_PREFIX + model, "Site failed SNP model sensitivity cutoff (90.0), corresponding with VQSLOD cutoff of 0.0"); - assertEquals(getTruthSensitivityHeader(truthSensitivityThreshold, vqsLodThreshold, GATKVCFConstants.SNP), expectedHeader); + assertEquals(getTruthSensitivityFilterHeader(truthSensitivityThreshold, vqsLodThreshold, GATKVCFConstants.SNP), expectedHeader); } @Test @@ -222,7 +222,7 @@ public void testGetTruthSensitivityHeaderINDEL() { VCFFilterHeaderLine expectedHeader = new VCFFilterHeaderLine(GATKVCFConstants.VQSR_FAILURE_PREFIX + model, "Site failed INDEL model sensitivity cutoff (90.0), corresponding with VQSLOD cutoff of 0.0"); - assertEquals(getTruthSensitivityHeader(truthSensitivityThreshold, vqsLodThreshold, GATKVCFConstants.INDEL), expectedHeader); + assertEquals(getTruthSensitivityFilterHeader(truthSensitivityThreshold, vqsLodThreshold, GATKVCFConstants.INDEL), expectedHeader); } }