use of ubic.gemma.core.analysis.preprocess.ExpressionDataMatrixBuilder in project Gemma by PavlidisLab.
the class ExpressionDataDoubleMatrixTest method testMatrixConversion.
@Test
public void testMatrixConversion() throws Exception {
try {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("")));
Collection<?> results = geoService.fetchAndLoad("GSE8294", false, true, false);
newee = (ExpressionExperiment) results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
newee = (ExpressionExperiment) ((List<?>) e.getData()).iterator().next();
}
newee = expressionExperimentService.thaw(newee);
// make sure we really thawRawAndProcessed them, so we can get the design element sequences.
Collection<RawExpressionDataVector> vectors = newee.getRawExpressionDataVectors();
rawExpressionDataVectorService.thaw(vectors);
ExpressionDataMatrixBuilder builder = new ExpressionDataMatrixBuilder(vectors);
ExpressionDataDoubleMatrix matrix = builder.getPreferredData();
assertTrue(!Double.isNaN(matrix.get(10, 0)));
assertEquals(66, matrix.rows());
assertEquals(9, matrix.columns());
/*
* Additional tests for files and outlier marking.
*/
processedDataVectorService.computeProcessedExpressionData(newee);
File f1 = expressionDataFileService.writeOrLocateDataFile(expressionExperimentService.load(newee.getId()), true, true);
assertNotNull(f1);
assertTrue(f1.exists());
expressionDataFileService.deleteAllFiles(newee);
assertTrue(!f1.exists());
/*
* outlier removal.
*/
BioAssay tba = newee.getBioAssays().iterator().next();
Collection<BioAssay> ol = new HashSet<>();
ol.add(tba);
sampleRemoveService.markAsMissing(ol);
assertTrue(tba.getIsOutlier());
newee = expressionExperimentService.thaw(newee);
Collection<ProcessedExpressionDataVector> vecs = newee.getProcessedExpressionDataVectors();
this.processedDataVectorService.thaw(vecs);
assertTrue(!vecs.isEmpty());
ExpressionDataMatrixBuilder matrixBuilder = new ExpressionDataMatrixBuilder(vecs);
ExpressionDataDoubleMatrix data = matrixBuilder.getProcessedData();
assertNotNull(data);
assertTrue(Double.isNaN(data.getColumn(tba)[10]));
sampleRemoveService.unmarkAsMissing(ol);
newee = expressionExperimentService.load(newee.getId());
newee = expressionExperimentService.thaw(newee);
vecs = newee.getProcessedExpressionDataVectors();
this.processedDataVectorService.thaw(vecs);
assertTrue(!vecs.isEmpty());
matrixBuilder = new ExpressionDataMatrixBuilder(vecs);
data = matrixBuilder.getProcessedData();
assertTrue(!tba.getIsOutlier());
assertTrue(!Double.isNaN(data.getColumn(tba)[10]));
}
use of ubic.gemma.core.analysis.preprocess.ExpressionDataMatrixBuilder in project Gemma by PavlidisLab.
the class GeoDatasetServiceTest method testFetchAndLoadMultiChipPerSeriesShort.
@Test
public void testFetchAndLoadMultiChipPerSeriesShort() throws Exception {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("shortTest")));
/*
* HG-U133A. GDS473 is for the other chip (B). Series is GSE674. see
* http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gds&term=GSE674[Accession]&cmd=search
*/
ExpressionExperiment newee;
try {
Collection<?> results = geoService.fetchAndLoad("GSE674", false, true, false);
newee = (ExpressionExperiment) results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
log.info("Skipping test, data already exists in db");
return;
}
assertNotNull(newee);
newee = eeService.thaw(newee);
/*
* Test for bug 468 (merging of subsets across GDS's)
*/
ExperimentalFactor factor = newee.getExperimentalDesign().getExperimentalFactors().iterator().next();
// otherwise get 4.
assertEquals(2, factor.getFactorValues().size());
Collection<RawExpressionDataVector> vectors = newee.getRawExpressionDataVectors();
rawExpressionDataVectorService.thaw(vectors);
ExpressionDataMatrixBuilder builder = new ExpressionDataMatrixBuilder(vectors);
ExpressionDataMatrix<Double> matrix = builder.getPreferredData();
assertNotNull(matrix);
assertEquals(31, matrix.rows());
assertEquals(15, matrix.columns());
// GSM10363 = D1-U133B
this.testMatrixValue(newee, matrix, "200000_s_at", "GSM10363", 5722.0);
// GSM10380 = C7-U133A
this.testMatrixValue(newee, matrix, "1007_s_at", "GSM10380", 1272.0);
}
Aggregations