use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class GeoConverterTest method testConvertDataDoubles.
@Test
public void testConvertDataDoubles() {
List<Object> testList = new ArrayList<>();
testList.add("1.1");
testList.add("2929202e-4");
testList.add("-394949.44422");
QuantitationType qt = QuantitationType.Factory.newInstance();
qt.setRepresentation(PrimitiveType.DOUBLE);
byte[] actualResult = gc.convertData(testList, qt);
double[] revertedResult = bac.byteArrayToDoubles(actualResult);
assertEquals(revertedResult[0], 1.1, 0.00001);
assertEquals(revertedResult[1], 2929202e-4, 0.00001);
assertEquals(revertedResult[2], -394949.44422, 0.00001);
}
use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class GeoSuperSeriesLoadTest method testFetchAndLoadSuperSeriesB.
/*
* See bug 2064. GSE14618 is a superseries of GSE14613 and GSE14615. This is actually even worse, because some
* samples were run on both platforms. This is a situation we don't really want to handle completely.
*
*/
@Test
public void testFetchAndLoadSuperSeriesB() throws Exception {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("gse14618superser")));
ee = ees.findByShortName("GSE14618");
this.tearDown();
// noinspection unchecked
Collection<ExpressionExperiment> results = (Collection<ExpressionExperiment>) geoService.fetchAndLoad("GSE14618", false, true, false, true, false);
assertEquals(1, results.size());
ee = results.iterator().next();
ee = ees.findByShortName("GSE14618");
ee = ees.thawLite(ee);
Collection<QuantitationType> qts = ee.getQuantitationTypes();
assertEquals(1, qts.size());
Collection<ArrayDesign> arrayDesignsUsed = ees.getArrayDesignsUsed(ee);
Collection<ArrayDesign> others = new HashSet<>();
others.add((ArrayDesign) arrayDesignsUsed.toArray()[1]);
ArrayDesign arrayDesign = (ArrayDesign) arrayDesignsUsed.toArray()[0];
ArrayDesign merged = adms.merge(arrayDesign, others, RandomStringUtils.randomAlphabetic(5), RandomStringUtils.randomAlphabetic(5), false);
ee = eepss.switchExperimentToArrayDesign(ee, merged);
vms.mergeVectors(ee);
ee = ees.load(ee.getId());
ee = ees.findByShortName("GSE14618");
ee = ees.thaw(ee);
assertEquals(40, ee.getProcessedExpressionDataVectors().size());
// System.err.println( ee.getProcessedExpressionDataVectors().size() );
boolean found1 = false;
boolean found2 = false;
ByteArrayConverter bac = new ByteArrayConverter();
for (ProcessedExpressionDataVector v : ee.getProcessedExpressionDataVectors()) {
double[] dat = bac.byteArrayToDoubles(v.getData());
int count = 0;
assertEquals(92, dat.length);
if (v.getDesignElement().getName().equals("117_at")) {
found1 = true;
for (double d : dat) {
if (Double.isNaN(d)) {
count++;
}
}
assertEquals("Should have been no missing values", 0, count);
} else if (v.getDesignElement().getName().equals("1552279_a_at")) {
found2 = true;
for (double d : dat) {
if (Double.isNaN(d)) {
count++;
}
}
assertEquals("Wrong number of missing values", 42, count);
}
}
assertTrue("Didn't find first test probe expected.", found1);
assertTrue("Didn't find second test probe expected.", found2);
}
use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class TwoChannelMissingValuesTest method testMissingValueGSE11017.
/**
* Was giving all missing values.
*/
@Test
public void testMissingValueGSE11017() throws Exception {
ExpressionExperiment old = eeService.findByShortName("GSE11017");
if (old != null)
eeService.remove(old);
InputStream is = new GZIPInputStream(this.getClass().getResourceAsStream("/data/loader/expression/geo/GSE11017.soft.gz"));
GeoFamilyParser parser = new GeoFamilyParser();
parser.parse(is);
GeoSeries series = ((GeoParseResult) parser.getResults().iterator().next()).getSeriesMap().get("GSE11017");
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>());
// print( calls );
assertEquals(20, calls.size());
boolean hasNewQT = false;
Collection<QuantitationType> qts = eeService.getQuantitationTypes(expExp);
for (QuantitationType qt : qts) {
if (qt.getType().equals(StandardQuantitationType.PRESENTABSENT)) {
hasNewQT = true;
break;
}
}
assertTrue(hasNewQT);
ExpressionDataMatrixBuilder builder = new ExpressionDataMatrixBuilder(calls);
ExpressionDataBooleanMatrix missingValues = builder.getMissingValueData();
assertTrue(missingValues.getQuantitationTypes().iterator().next().getDescription().contains("signal threshold"));
Boolean[][] mm = missingValues.getRawMatrix();
boolean hasPresent = false;
for (Boolean[] aMm : mm) {
for (Boolean anAMm : aMm) {
if (anAMm) {
hasPresent = true;
break;
}
}
}
assertTrue(hasPresent);
}
use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class MatrixConversionTest method getDesignElementDataVectors.
/**
* Creates an ugly (but not unusual) situation where there are two bioassay dimensions with different sizes,
* referring to the same set of biomaterials.
*
* @return design element data vectors
*/
private Collection<DesignElementDataVector> getDesignElementDataVectors(Collection<QuantitationType> quantTypes) {
Collection<DesignElementDataVector> vectors = new HashSet<>();
ArrayDesign ad = ArrayDesign.Factory.newInstance();
ad.setName("junk");
List<CompositeSequence> sequences = this.getCompositeSequences(ad);
ArrayDesign adb = ArrayDesign.Factory.newInstance();
adb.setName("bjunk");
List<CompositeSequence> sequencesb = this.getCompositeSequences(ad);
// resused
List<BioMaterial> bioMaterials = this.getBioMaterials();
for (QuantitationType quantType : quantTypes) {
/*
* Create two bioassay dimension which overlap; "A" does not use all the biomaterials.
*/
BioAssayDimension baDimA = BioAssayDimension.Factory.newInstance();
Iterator<BioMaterial> bmita = bioMaterials.iterator();
for (long i = 0; i < MatrixConversionTest.NUM_BIOMATERIALS - 20; i++) {
BioAssay ba = ubic.gemma.model.expression.bioAssay.BioAssay.Factory.newInstance();
ba.setName(RandomStringUtils.randomNumeric(5) + "_testbioassay");
ba.setSampleUsed(bmita.next());
ba.setArrayDesignUsed(ad);
ba.setId(i);
baDimA.getBioAssays().add(ba);
}
baDimA.setName(RandomStringUtils.randomAlphanumeric(10));
BioAssayDimension baDimB = BioAssayDimension.Factory.newInstance();
Iterator<BioMaterial> bmitb = bioMaterials.iterator();
for (long i = 0; i < MatrixConversionTest.NUM_BIOMATERIALS; i++) {
BioAssay ba = ubic.gemma.model.expression.bioAssay.BioAssay.Factory.newInstance();
ba.setName(RandomStringUtils.randomNumeric(15) + "_testbioassay");
ba.setSampleUsed(bmitb.next());
ba.setArrayDesignUsed(adb);
ba.setId(i + 20);
baDimB.getBioAssays().add(ba);
}
baDimB.setName(RandomStringUtils.randomAlphanumeric(10));
// bio.a gets cs 0-99, bio.b gets 100-199.
long j = 0;
j = this.loopVectors(vectors, sequencesb, quantType, baDimA, j, MatrixConversionTest.NUM_CS - 100);
// noinspection UnusedAssignment // Better readability
j = this.loopVectors(vectors, sequences, quantType, baDimB, j, MatrixConversionTest.NUM_CS);
}
return vectors;
}
use of ubic.gemma.model.common.quantitationtype.QuantitationType in project Gemma by PavlidisLab.
the class QuantitationTypeData method getPreferredQTypes.
public List<QuantitationType> getPreferredQTypes() {
List<QuantitationType> result = new ArrayList<>();
List<BioAssayDimension> dimensions = this.getBioAssayDimensions();
if (dimensions.size() == 0) {
throw new IllegalArgumentException("No bioAssayDimensions!");
}
for (BioAssayDimension dimension : dimensions) {
for (DesignElementDataVector vector : vectors) {
if (!vector.getBioAssayDimension().equals(dimension))
continue;
QuantitationType qType = vector.getQuantitationType();
if (!qType.getIsPreferred() && !qType.getIsMaskedPreferred())
continue;
// if we get here, we're in the right place.
result.add(qType);
// on to the next dimension.
break;
}
}
return result;
}
Aggregations