From 08ba7696ebefe20acac490011832c2f877ef0aff Mon Sep 17 00:00:00 2001 From: Samuel Lee Date: Tue, 13 Feb 2018 09:56:36 -0500 Subject: [PATCH] Allowed use of zero eigensamples in DenoiseReadCounts. --- .../hellbender/tools/copynumber/DenoiseReadCounts.java | 3 +-- .../tools/copynumber/denoising/SVDDenoisingUtils.java | 6 +++++- .../tools/copynumber/DenoiseReadCountsIntegrationTest.java | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/copynumber/DenoiseReadCounts.java b/src/main/java/org/broadinstitute/hellbender/tools/copynumber/DenoiseReadCounts.java index 9419ee82cfd..3e4a1be1e26 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/copynumber/DenoiseReadCounts.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/copynumber/DenoiseReadCounts.java @@ -166,6 +166,7 @@ public final class DenoiseReadCounts extends CommandLineProgram { "If not specified or if the number of eigensamples available in the panel of normals " + "is smaller than this, all eigensamples will be used.", fullName = CopyNumberStandardArgument.NUMBER_OF_EIGENSAMPLES_LONG_NAME, + minValue = 0, optional = true ) private Integer numEigensamplesRequested = null; @@ -176,8 +177,6 @@ protected Object doWork() { throw new UserException.HardwareFeatureException("Cannot load the required HDF5 library. " + "HDF5 is currently supported on x86-64 architecture and Linux or OSX systems."); } - Utils.validateArg(numEigensamplesRequested == null || numEigensamplesRequested > 0, - "Number of eigensamples to use for denoising must be non-negative."); IOUtils.canReadFile(inputReadCountFile); logger.info(String.format("Reading read-counts file (%s)...", inputReadCountFile)); diff --git a/src/main/java/org/broadinstitute/hellbender/tools/copynumber/denoising/SVDDenoisingUtils.java b/src/main/java/org/broadinstitute/hellbender/tools/copynumber/denoising/SVDDenoisingUtils.java index f9bedfbf5ab..d194ad57dc1 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/copynumber/denoising/SVDDenoisingUtils.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/copynumber/denoising/SVDDenoisingUtils.java @@ -112,7 +112,7 @@ static SVDDenoisedCopyRatioResult denoise(final SVDReadCountPanelOfNormals panel if (!CopyNumberArgumentValidationUtils.isSameDictionary(panelOfNormals.getSequenceDictionary(), readCounts.getMetadata().getSequenceDictionary())) { logger.warn("Sequence dictionaries in panel and case sample do not match."); } - ParamUtils.isPositive(numEigensamples, "Number of eigensamples to use for denoising must be positive."); + ParamUtils.isPositiveOrZero(numEigensamples, "Number of eigensamples to use for denoising must be non-negative."); Utils.validateArg(numEigensamples <= panelOfNormals.getNumEigensamples(), "Number of eigensamples to use for denoising is greater than the number available in the panel of normals."); @@ -424,6 +424,10 @@ public double visit(int sampleIndex, int intervalIndex, double value) { private static RealMatrix subtractProjection(final RealMatrix standardizedValues, final double[][] eigensampleVectors, final int numEigensamples) { + if (numEigensamples == 0) { + return standardizedValues.copy(); + } + final int numIntervals = eigensampleVectors.length; final int numAllEigensamples = eigensampleVectors[0].length; diff --git a/src/test/java/org/broadinstitute/hellbender/tools/copynumber/DenoiseReadCountsIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/copynumber/DenoiseReadCountsIntegrationTest.java index e080aaf9ad5..1c29376afa7 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/copynumber/DenoiseReadCountsIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/copynumber/DenoiseReadCountsIntegrationTest.java @@ -26,7 +26,7 @@ public final class DenoiseReadCountsIntegrationTest extends CommandLineProgramTe private static final File WGS_ANNOTATED_INTERVALS_FILE = new File(TEST_SUB_DIR, "denoise-read-counts-wgs-annotated-intervals.tsv"); private static final File WGS_NO_GC_PON_FILE = new File(largeFileTestDir, "cnv_somatic_workflows_test_files/wgs-no-gc.pon.hdf5"); private static final File WGS_DO_GC_PON_FILE = new File(largeFileTestDir, "cnv_somatic_workflows_test_files/wgs-do-gc.pon.hdf5"); - private static final List NUMBER_OF_EIGENVALUES_LIST = Arrays.asList(null, 1, 10); + private static final List NUMBER_OF_EIGENVALUES_LIST = Arrays.asList(null, 0, 1, 10); //create all combinations of arguments @DataProvider(name = "dataDenoiseReadCounts") @@ -47,7 +47,7 @@ public Object[][] dataDenoiseReadCounts() { if (numberOfEigenvalues != null) { arguments.addArgument(CopyNumberStandardArgument.NUMBER_OF_EIGENSAMPLES_LONG_NAME, numberOfEigenvalues.toString()); } - data.add(Arrays.asList(arguments, ponFile == null)); //set isStandardizedEqualsDenoised = true if no PoN + data.add(Arrays.asList(arguments, ponFile == null || (numberOfEigenvalues != null && numberOfEigenvalues == 0))); //set isStandardizedEqualsDenoised = true if no PoN or if number of eigenvalues is zero } } }