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);
}
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);
}
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");
}
}
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);
}
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));
}
}
}
Aggregations