Search in sources :

Example 6 with StringMatrixReader

use of ubic.basecode.io.reader.StringMatrixReader in project Gemma by PavlidisLab.

the class ComBatTest method test1.

@Test
public void test1() throws Exception {
    DoubleMatrixReader f = new DoubleMatrixReader();
    DoubleMatrix<String, String> testMatrix = f.read(this.getClass().getResourceAsStream("/data/analysis/preprocess/batcheffects/example.madata.small.txt"));
    StringMatrixReader of = new StringMatrixReader();
    StringMatrix<String, String> sampleInfo = of.read(this.getClass().getResourceAsStream("/data/analysis/preprocess/batcheffects/example.metadata.small.txt"));
    @SuppressWarnings({ "unchecked", "rawtypes" }) ComBat<String, String> comBat = new ComBat(testMatrix, sampleInfo);
    DoubleMatrix2D X = comBat.getDesignMatrix();
    assertEquals(1, X.get(0, 0), 0.001);
    assertEquals(0, X.get(3, 0), 0.001);
    assertEquals(1, X.get(4, 2), 0.001);
    DoubleMatrix2D y = new DenseDoubleMatrix2D(testMatrix.asArray());
    DoubleMatrix2D sdata = comBat.standardize(y, X);
    assertEquals(-0.25074, sdata.get(17, 1), 0.0001);
    assertEquals(0.54122, sdata.get(8, 2), 0.001);
    assertEquals(0.22358, sdata.get(0, 8), 0.001);
    assertEquals(0.25211, sdata.get(3, 7), 0.001);
    DoubleMatrix2D finalResult = comBat.run();
    assertEquals(10.67558, finalResult.get(7, 0), 0.0001);
    assertEquals(11.68505, finalResult.get(7, 7), 0.0001);
    assertEquals(6.769583, finalResult.get(10, 7), 0.0001);
}
Also used : StringMatrixReader(ubic.basecode.io.reader.StringMatrixReader) DenseDoubleMatrix2D(cern.colt.matrix.impl.DenseDoubleMatrix2D) DoubleMatrix2D(cern.colt.matrix.DoubleMatrix2D) DenseDoubleMatrix2D(cern.colt.matrix.impl.DenseDoubleMatrix2D) DoubleMatrixReader(ubic.basecode.io.reader.DoubleMatrixReader) Test(org.junit.Test)

Aggregations

DoubleMatrix2D (cern.colt.matrix.DoubleMatrix2D)6 DenseDoubleMatrix2D (cern.colt.matrix.impl.DenseDoubleMatrix2D)6 Test (org.junit.Test)6 DoubleMatrixReader (ubic.basecode.io.reader.DoubleMatrixReader)6 StringMatrixReader (ubic.basecode.io.reader.StringMatrixReader)6