Search in sources :

Example 1 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.

the class VectorMergingServiceImpl method print.

@SuppressWarnings("unused")
private void print(Collection<DesignElementDataVector> newVectors) {
    StringBuilder buf = new StringBuilder();
    ByteArrayConverter conv = new ByteArrayConverter();
    for (DesignElementDataVector vector : newVectors) {
        buf.append(vector.getDesignElement());
        QuantitationType qtype = vector.getQuantitationType();
        if (qtype.getRepresentation().equals(PrimitiveType.DOUBLE)) {
            double[] vals = conv.byteArrayToDoubles(vector.getData());
            for (double d : vals) {
                buf.append("\t").append(d);
            }
        } else if (qtype.getRepresentation().equals(PrimitiveType.INT)) {
            int[] vals = conv.byteArrayToInts(vector.getData());
            for (int i : vals) {
                buf.append("\t").append(i);
            }
        } else if (qtype.getRepresentation().equals(PrimitiveType.BOOLEAN)) {
            boolean[] vals = conv.byteArrayToBooleans(vector.getData());
            for (boolean d : vals) {
                buf.append("\t").append(d);
            }
        } else if (qtype.getRepresentation().equals(PrimitiveType.STRING)) {
            String[] vals = conv.byteArrayToStrings(vector.getData());
            for (String d : vals) {
                buf.append("\t").append(d);
            }
        }
        buf.append("\n");
    }
    VectorMergingServiceImpl.log.info("\n" + buf);
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType)

Example 2 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.

the class GeoDatasetServiceTest method testMatrixValue.

private void testMatrixValue(ExpressionExperiment exp, ExpressionDataMatrix<Double> matrix, String probeToTest, String sampleToTest, double expectedValue) {
    CompositeSequence soughtDesignElement = null;
    BioAssay soughtBioAssay = null;
    Collection<RawExpressionDataVector> vectors = exp.getRawExpressionDataVectors();
    for (DesignElementDataVector vector : vectors) {
        CompositeSequence de = vector.getDesignElement();
        if (de.getName().equals(probeToTest)) {
            soughtDesignElement = de;
        }
        BioAssayDimension bad = vector.getBioAssayDimension();
        for (BioAssay ba : bad.getBioAssays()) {
            if (ba.getAccession().getAccession().equals(sampleToTest)) {
                soughtBioAssay = ba;
            }
        }
    }
    if (soughtDesignElement == null || soughtBioAssay == null)
        fail("didn't find values for " + sampleToTest);
    Double actualValue = matrix.get(soughtDesignElement, soughtBioAssay);
    assertNotNull("No value for " + soughtBioAssay, actualValue);
    assertEquals(expectedValue, actualValue, 0.00001);
}
Also used : BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 3 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.

the class TwoChannelMissingValuesTest method print.

/**
 * Debug code.
 */
@SuppressWarnings("unused")
private void print(Collection<RawExpressionDataVector> calls) {
    ByteArrayConverter bac = new ByteArrayConverter();
    BioAssayDimension dim = calls.iterator().next().getBioAssayDimension();
    System.err.print("\n");
    for (BioAssay bas : dim.getBioAssays()) {
        System.err.print("\t" + bas);
    }
    System.err.print("\n");
    for (DesignElementDataVector vector : calls) {
        System.err.print(vector.getDesignElement());
        byte[] dat = vector.getData();
        boolean[] row = bac.byteArrayToBooleans(dat);
        for (boolean b : row) {
            System.err.print("\t" + b);
        }
        System.err.print("\n");
    }
}
Also used : BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 4 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.

the class TwoChannelMissingValuesTest method testMissingValue.

@Test
public void testMissingValue() throws Exception {
    ExpressionExperiment old = eeService.findByShortName("GSE2221");
    if (old != null)
        eeService.remove(old);
    InputStream is = new GZIPInputStream(this.getClass().getResourceAsStream("/data/loader/expression/geo/shortGenePix/GSE2221_family.soft.gz"));
    GeoFamilyParser parser = new GeoFamilyParser();
    parser.parse(is);
    GeoSeries series = ((GeoParseResult) parser.getResults().iterator().next()).getSeriesMap().get("GSE2221");
    DatasetCombiner datasetCombiner = new DatasetCombiner();
    GeoSampleCorrespondence correspondence = datasetCombiner.findGSECorrespondence(series);
    series.setSampleCorrespondence(correspondence);
    Object result = this.gc.convert(series);
    assertNotNull(result);
    ExpressionExperiment expExp = (ExpressionExperiment) ((Collection<?>) result).iterator().next();
    expExp = persisterHelper.persist(expExp, persisterHelper.prepare(expExp));
    Collection<RawExpressionDataVector> calls = tcmv.computeMissingValues(expExp, 2.0, new ArrayList<Double>());
    assertEquals(500, calls.size());
    BioAssayDimension dim = calls.iterator().next().getBioAssayDimension();
    // Spot check the results. For sample ME-TMZ, ID #27 should be 'true' and 26 should be false.
    ByteArrayConverter bac = new ByteArrayConverter();
    boolean foundA = false;
    boolean foundB = false;
    for (DesignElementDataVector vector : calls) {
        if (vector.getDesignElement().getName().equals("26")) {
            byte[] dat = vector.getData();
            boolean[] row = bac.byteArrayToBooleans(dat);
            int i = 0;
            for (BioAssay bas : dim.getBioAssays()) {
                if (bas.getName().equals("expression array ME-TMZ")) {
                    assertTrue(!row[i]);
                    foundA = true;
                }
                i++;
            }
        }
        if (vector.getDesignElement().getName().equals("27")) {
            byte[] dat = vector.getData();
            boolean[] row = bac.byteArrayToBooleans(dat);
            int i = 0;
            for (BioAssay bas : dim.getBioAssays()) {
                if (bas.getName().equals("expression array ME-TMZ")) {
                    assertTrue(row[i]);
                    foundB = true;
                }
                i++;
            }
        }
    }
    assertTrue(foundA && foundB);
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) GeoSeries(ubic.gemma.core.loader.expression.geo.model.GeoSeries) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GZIPInputStream(java.util.zip.GZIPInputStream) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) Collection(java.util.Collection) DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 5 with DesignElementDataVector

use of ubic.gemma.model.expression.bioAssayData.DesignElementDataVector in project Gemma by PavlidisLab.

the class MatrixConversionTest method testColumnMapping.

public final void testColumnMapping() {
    Collection<QuantitationType> quantTypes = new HashSet<>();
    QuantitationType quantType = PersistentDummyObjectHelper.getTestNonPersistentQuantitationType();
    quantType.setId(0L);
    quantTypes.add(quantType);
    Collection<DesignElementDataVector> vectors = this.getDesignElementDataVectors(quantTypes);
    ExpressionDataDoubleMatrix mat = new ExpressionDataDoubleMatrix(vectors);
    MatrixConversionTest.log.debug(vectors.size() + " vectors");
    TestCase.assertEquals(MatrixConversionTest.NUM_CS, mat.rows());
    TestCase.assertEquals(MatrixConversionTest.NUM_BIOMATERIALS, mat.columns());
    for (int j = 0; j < mat.rows(); j++) {
        // System.err.print( mat.getRowElement( j ) );
        for (int i = 0; i < mat.columns(); i++) {
            Double r = mat.get(j, i);
            TestCase.assertNotNull("No value for at index " + i, r);
            TestCase.assertTrue("Expected " + i + ", got " + r, i == r.intValue() || r.equals(Double.NaN));
        }
    }
}
Also used : DesignElementDataVector(ubic.gemma.model.expression.bioAssayData.DesignElementDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType)

Aggregations

DesignElementDataVector (ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)33 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)18 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)18 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)15 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)9 StandardQuantitationType (ubic.gemma.model.common.quantitationtype.StandardQuantitationType)9 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)8 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)6 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)5 ProcessedExpressionDataVector (ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector)5 Collection (java.util.Collection)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)2 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)2 InputStream (java.io.InputStream)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1