use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.
the class HDF5PCACoveragePoNCreationUtilsUnitTest method testCalculateVariance.
@Test
public void testCalculateVariance() {
/*
This tests that the post-projection variance is correct. Ground truth was acquired through a breakpoint (to get input values),
some text parsing, and matlab. This simply tests that the variances are correctly calculated from a matrix.
*/
final int numEigensamples = 20;
final File ponFile = PoNTestUtils.createDummyHDF5FilePoN(TEST_PCOV_FILE, numEigensamples);
final double[] gtTargetVariances = ParamUtils.readValuesFromFile(GT_TARGET_VAR_FILE);
try (final HDF5File ponHDF5File = new HDF5File(ponFile)) {
final HDF5PCACoveragePoN pon = new HDF5PCACoveragePoN(ponHDF5File);
final double[] targetVariances = pon.getTargetVariances();
PoNTestUtils.assertEqualsDoubleArrays(targetVariances, gtTargetVariances, 1E-4);
}
}
use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.
the class HDF5PCACoveragePoNUnitTest method testSampleNameReading.
@Test
public void testSampleNameReading() throws IOException {
final HDF5File reader = new HDF5File(TEST_PON);
final PCACoveragePoN pon = new HDF5PCACoveragePoN(reader);
final List<String> sampleNames = pon.getSampleNames();
final List<String> expected = readLines(TEST_PON_SAMPLES);
Assert.assertNotNull(sampleNames);
Assert.assertEquals(sampleNames, expected);
reader.close();
}
use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.
the class PCATangentNormalizationUtilsUnitTest method testSparkTangentNormalizeSparkVsNoSpark.
@Test
public void testSparkTangentNormalizeSparkVsNoSpark() {
final JavaSparkContext ctx = SparkContextFactory.getTestSparkContext();
final File ponFile = PoNTestUtils.createDummyHDF5FilePoN(TEST_PCOV_FILE, 20);
try (final HDF5File ponHDF5File = new HDF5File(ponFile)) {
final PCACoveragePoN pon = new HDF5PCACoveragePoN(ponHDF5File);
final PCATangentNormalizationResult tnWithSpark = pon.normalizeNormalsInPoN(ctx);
final PCATangentNormalizationResult tnWithoutSpark = pon.normalizeNormalsInPoN();
PoNTestUtils.assertEqualsMatrix(tnWithSpark.getTangentNormalized().counts(), tnWithoutSpark.getTangentNormalized().counts(), false);
PoNTestUtils.assertEqualsMatrix(tnWithSpark.getPreTangentNormalized().counts(), tnWithoutSpark.getPreTangentNormalized().counts(), false);
PoNTestUtils.assertEqualsMatrix(tnWithSpark.getTangentBetaHats(), tnWithoutSpark.getTangentBetaHats(), false);
}
}
use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.
the class HDF5PCACoveragePoNUnitTest method testNormalizedPcovReading.
@Test(dependsOnMethods = { "testTargetNameReading", "testSampleNameReading" })
public void testNormalizedPcovReading() throws IOException {
final HDF5File reader = new HDF5File(TEST_PON);
final PCACoveragePoN pon = new HDF5PCACoveragePoN(reader);
final List<String> targets = pon.getTargetNames();
final List<String> samples = pon.getSampleNames();
final RealMatrix actual = pon.getNormalizedCounts();
Assert.assertNotNull(actual);
Assert.assertEquals(actual.getRowDimension(), targets.size());
Assert.assertEquals(actual.getColumnDimension(), samples.size());
final RealMatrix expected = readDoubleMatrix(TEST_PON_NORMALIZED_PCOV);
MathObjectAsserts.assertRealMatrixEquals(actual, expected);
}
use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.
the class HDF5PCACoveragePoNUnitTest method testLogNormalizedSampleNameReading.
@Test(dependsOnMethods = "testSampleNameReading")
public void testLogNormalizedSampleNameReading() throws IOException {
final HDF5File reader = new HDF5File(TEST_PON);
final PCACoveragePoN pon = new HDF5PCACoveragePoN(reader);
final List<String> expected = readLines(TEST_PON_LOG_NORMAL_SAMPLES);
final List<String> logNormalizedSampleNames = pon.getPanelSampleNames().stream().sorted().collect(Collectors.toList());
Assert.assertEquals(logNormalizedSampleNames, expected);
}
Aggregations