use of org.apache.commons.math3.linear.RealMatrix in project gatk by broadinstitute.
the class HDF5PCACoveragePoNUnitTest method testLogNormalizedPInvMatrixReading.
@Test(dependsOnMethods = { "testTargetNameReading", "testLogNormalizedSampleNameReading" })
public void testLogNormalizedPInvMatrixReading() 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.getPanelSampleNames();
final RealMatrix actual = pon.getLogNormalizedPInverseCounts();
Assert.assertNotNull(actual);
Assert.assertEquals(actual.getRowDimension(), samples.size());
Assert.assertEquals(actual.getColumnDimension(), targets.size());
final RealMatrix expected = readDoubleMatrix(TEST_PON_LOG_NORMALS_PINV);
MathObjectAsserts.assertRealMatrixEquals(actual, expected);
}
use of org.apache.commons.math3.linear.RealMatrix in project gatk by broadinstitute.
the class RamPCACoveragePoNUnitTest method assertReducedPanelPInverseCounts.
private void assertReducedPanelPInverseCounts(final PCACoveragePoN filePoN, final PCACoveragePoN ramPoN) {
final RealMatrix ramNormalizedCounts = ramPoN.getReducedPanelPInverseCounts();
final RealMatrix fileNormalizedCounts = filePoN.getReducedPanelPInverseCounts();
Assert.assertEquals(ramNormalizedCounts.subtract(fileNormalizedCounts).getNorm(), 0, 1e-9);
ramNormalizedCounts.setEntry(3, 4, 500000);
Assert.assertEquals(ramNormalizedCounts.getEntry(3, 4), 500000, 1e-9);
Assert.assertNotEquals(ramPoN.getReducedPanelPInverseCounts().getEntry(3, 4), 500000, 1e-9);
Assert.assertFalse(ramNormalizedCounts.subtract(fileNormalizedCounts).getNorm() < 1e-9);
final RealMatrix fileNormalizedCounts2 = filePoN.getReducedPanelPInverseCounts();
Assert.assertFalse(ramNormalizedCounts.subtract(fileNormalizedCounts2).getNorm() < 1e-9);
}
use of org.apache.commons.math3.linear.RealMatrix in project gatk by broadinstitute.
the class RamPCACoveragePoNUnitTest method assertLogNormalizedPinvCounts.
private void assertLogNormalizedPinvCounts(final PCACoveragePoN filePoN, final PCACoveragePoN ramPoN) {
final RealMatrix ramNormalizedCounts = ramPoN.getLogNormalizedPInverseCounts();
final RealMatrix fileNormalizedCounts = filePoN.getLogNormalizedPInverseCounts();
Assert.assertEquals(ramNormalizedCounts.subtract(fileNormalizedCounts).getNorm(), 0, 1e-9);
ramNormalizedCounts.setEntry(3, 4, 500000);
Assert.assertEquals(ramNormalizedCounts.getEntry(3, 4), 500000, 1e-9);
Assert.assertNotEquals(ramPoN.getLogNormalizedPInverseCounts().getEntry(3, 4), 500000, 1e-9);
Assert.assertFalse(ramNormalizedCounts.subtract(fileNormalizedCounts).getNorm() < 1e-9);
final RealMatrix fileNormalizedCounts2 = filePoN.getLogNormalizedPInverseCounts();
Assert.assertFalse(ramNormalizedCounts.subtract(fileNormalizedCounts2).getNorm() < 1e-9);
}
use of org.apache.commons.math3.linear.RealMatrix in project gatk by broadinstitute.
the class RamPCACoveragePoNUnitTest method assertNormalizedCounts.
private void assertNormalizedCounts(final PCACoveragePoN filePoN, final PCACoveragePoN ramPoN) {
final RealMatrix ramNormalizedCounts = ramPoN.getNormalizedCounts();
final RealMatrix fileNormalizedCounts = filePoN.getNormalizedCounts();
Assert.assertEquals(ramNormalizedCounts.subtract(fileNormalizedCounts).getNorm(), 0, 1e-9);
ramNormalizedCounts.setEntry(3, 4, 500000);
Assert.assertEquals(ramNormalizedCounts.getEntry(3, 4), 500000, 1e-9);
Assert.assertNotEquals(ramPoN.getNormalizedCounts().getEntry(3, 4), 500000, 1e-9);
Assert.assertFalse(ramNormalizedCounts.subtract(fileNormalizedCounts).getNorm() < 1e-9);
final RealMatrix fileNormalizedCounts2 = filePoN.getNormalizedCounts();
Assert.assertFalse(ramNormalizedCounts.subtract(fileNormalizedCounts2).getNorm() < 1e-9);
}
use of org.apache.commons.math3.linear.RealMatrix in project gatk by broadinstitute.
the class HDF5LibraryUnitTest method createMatrixOfGaussianValues.
private RealMatrix createMatrixOfGaussianValues(int numRows, int numCols, final double mean, final double sigma) {
final RealMatrix bigCounts = new Array2DRowRealMatrix(numRows, numCols);
final RandomDataGenerator randomDataGenerator = new RandomDataGenerator();
randomDataGenerator.reSeed(337337337);
bigCounts.walkInOptimizedOrder(new DefaultRealMatrixChangingVisitor() {
@Override
public double visit(int row, int column, double value) {
return randomDataGenerator.nextGaussian(mean, sigma);
}
});
return bigCounts;
}
Aggregations