From 2b923f1568329ce3af4d1953746e74e327ea0c44 Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Sat, 20 Apr 2013 13:05:14 -0400 Subject: [PATCH] fix for DiagnoseTargets multiple filter output Problem ------- Diagnose targets is outputting both LOW_MEDIAN_COVERAGE and NO_READS when no reads are covering the interval Solution -------- Only allow low median coverage check if there are reads [fixes #48442675] --- .../targets/IntervalStatistics.java | 20 ++++++++++++++----- .../diagnostics/targets/SampleStatistics.java | 2 +- .../DiagnoseTargetsIntegrationTest.java | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/IntervalStatistics.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/IntervalStatistics.java index 0aea54fa0..0a6b73dae 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/IntervalStatistics.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/IntervalStatistics.java @@ -148,24 +148,34 @@ class IntervalStatistics { votes.put(status, votes.get(status) + 1); // output tall values above the threshold + final double minVotesNeeded = thresholds.getVotePercentageThreshold() * samples.size(); for (CallableStatus status : votes.keySet()) { - if (votes.get(status) > (samples.size() * thresholds.getVotePercentageThreshold()) && !(status.equals(CallableStatus.PASS))) + if (!status.equals((CallableStatus.PASS)) && votes.get(status) > minVotesNeeded) output.add(status); } - if (hasNref) output.add(CallableStatus.REF_N); // get median DP of each sample + final double minMedianDepth = thresholds.getLowMedianDepthThreshold() * samples.size(); + final int nSamples = samples.size(); int nLowMedianDepth = 0; + int samplesSeen = 0; for (SampleStatistics sample : samples.values()) { - if (sample.getQuantileDepth(0.5) < thresholds.getMinimumMedianDepth()) + samplesSeen++; + final double medianDepth = sample.getQuantileDepth(0.5); + if (medianDepth > 0 && medianDepth < thresholds.getMinimumMedianDepth()) { nLowMedianDepth++; + } + if (nLowMedianDepth > minMedianDepth) { + output.add(CallableStatus.LOW_MEDIAN_DEPTH); + break; + } + if (nSamples - samplesSeen + nLowMedianDepth < minMedianDepth) + break; } - if (nLowMedianDepth > (samples.size() * thresholds.getLowMedianDepthThreshold())) - output.add(CallableStatus.LOW_MEDIAN_DEPTH); return output; } diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatistics.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatistics.java index ad9f287d2..9efdbefe1 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatistics.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/SampleStatistics.java @@ -101,7 +101,7 @@ class SampleStatistics { * @return the callable statuses of the entire sample */ public Set getCallableStatuses(ThresHolder thresholds) { - // We check if reads are present ot prevent div / 0 exceptions + // We check if reads are present to prevent div / 0 exceptions if (nReads == 0) { return Collections.singleton(CallableStatus.NO_READS); } diff --git a/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargetsIntegrationTest.java b/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargetsIntegrationTest.java index 2875e10d7..a9330f2dd 100644 --- a/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargetsIntegrationTest.java +++ b/protected/java/test/org/broadinstitute/sting/gatk/walkers/diagnostics/targets/DiagnoseTargetsIntegrationTest.java @@ -66,11 +66,11 @@ public class DiagnoseTargetsIntegrationTest extends WalkerTest { @Test(enabled = true) public void testSingleSample() { - DTTest("testSingleSample ", "-I " + singleSample + " -max 75", "9b51561bcf248da70a4d711380b04f7b"); + DTTest("testSingleSample ", "-I " + singleSample + " -max 75", "bd614643284a849724bf8ee6bc4df8bf"); } @Test(enabled = true) public void testMultiSample() { - DTTest("testMultiSample ", "-I " + multiSample, "925f88f0c41c6a9ac479be34e052dc5d"); + DTTest("testMultiSample ", "-I " + multiSample, "145f5d4641abfdeadbc59ee74ce1560f"); } }