use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk-protected by broadinstitute.
the class NormalizeSomaticReadCountsIntegrationTest method reorderTargetsToPoNOrder.
private RealMatrix reorderTargetsToPoNOrder(final ReadCountCollection preTangentNormalized, final List<String> ponTargets) {
final RealMatrix preTangentNormalizedCounts = preTangentNormalized.counts();
final Map<String, Integer> ponTargetIndex = IntStream.range(0, ponTargets.size()).boxed().collect(Collectors.toMap(ponTargets::get, Function.identity()));
// first we need to sort the input counts so that they match the
// target order in the PoN.
final double[][] ponPreparedInput = new double[ponTargets.size()][];
for (int i = 0; i < preTangentNormalizedCounts.getRowDimension(); i++) {
final Target target = preTangentNormalized.targets().get(i);
if (!ponTargetIndex.containsKey(target.getName()))
continue;
final int idx = ponTargetIndex.get(target.getName());
ponPreparedInput[idx] = preTangentNormalizedCounts.getRow(i);
}
// The actual input to create the beta-hats, sorted by the PoN targets:
return new Array2DRowRealMatrix(ponPreparedInput, false);
}
use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk by broadinstitute.
the class NormalizeSomaticReadCountsIntegrationTest method reorderTargetsToPoNOrder.
private RealMatrix reorderTargetsToPoNOrder(final ReadCountCollection preTangentNormalized, final List<String> ponTargets) {
final RealMatrix preTangentNormalizedCounts = preTangentNormalized.counts();
final Map<String, Integer> ponTargetIndex = IntStream.range(0, ponTargets.size()).boxed().collect(Collectors.toMap(ponTargets::get, Function.identity()));
// first we need to sort the input counts so that they match the
// target order in the PoN.
final double[][] ponPreparedInput = new double[ponTargets.size()][];
for (int i = 0; i < preTangentNormalizedCounts.getRowDimension(); i++) {
final Target target = preTangentNormalized.targets().get(i);
if (!ponTargetIndex.containsKey(target.getName()))
continue;
final int idx = ponTargetIndex.get(target.getName());
ponPreparedInput[idx] = preTangentNormalizedCounts.getRow(i);
}
// The actual input to create the beta-hats, sorted by the PoN targets:
return new Array2DRowRealMatrix(ponPreparedInput, false);
}
use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk by broadinstitute.
the class MatrixSummaryUtilsUnitTest method testGetRowVariances.
@Test(dataProvider = "rowVarianceTestData")
public void testGetRowVariances(double[][] testdata, double[] gtRowVariances) {
final RealMatrix tmp = new Array2DRowRealMatrix(testdata);
PoNTestUtils.assertEqualsDoubleArrays(MatrixSummaryUtils.getRowVariances(tmp), gtRowVariances);
}
use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk by broadinstitute.
the class MatrixSummaryUtilsUnitTest method testGetRowAndColumnMedians.
@Test(dataProvider = "rowAndColumnMedianTestData")
public void testGetRowAndColumnMedians(double[][] testdata, double[] gtRowMedian, double[] gtColumnMedian) {
final RealMatrix tmp = new Array2DRowRealMatrix(testdata);
PoNTestUtils.assertEqualsDoubleArrays(MatrixSummaryUtils.getRowMedians(tmp), gtRowMedian);
PoNTestUtils.assertEqualsDoubleArrays(MatrixSummaryUtils.getColumnMedians(tmp), gtColumnMedian);
}
use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk by broadinstitute.
the class GATKProtectedMathUtilsTest method testColumnSum.
@Test
public void testColumnSum() {
final double[][] array = { { 1, 2, 3 }, { 5, 5, 5 }, { 7, 8, 9 }, { -15, 2, 12 } };
final double[] guess = GATKProtectedMathUtils.columnSums(new Array2DRowRealMatrix(array));
final double[] gt = { -2, 17, 29 };
Assert.assertEquals(guess.length, 3);
Assert.assertEquals(guess, gt);
}
Aggregations