use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal in project Gemma by PavlidisLab.
the class ProcessedExpressionDataCreateServiceTest method testComputeDevRankForExpressionExperimentB.
@SuppressWarnings("unchecked")
@Test
public void testComputeDevRankForExpressionExperimentB() throws Exception {
try {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("GSE5949short")));
Collection<ExpressionExperiment> results = (Collection<ExpressionExperiment>) geoService.fetchAndLoad("GSE5949", false, true, false);
this.ee = results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
this.ee = ((Collection<ExpressionExperiment>) e.getData()).iterator().next();
}
ee = this.eeService.thawLite(ee);
processedExpressionDataVectorService.computeProcessedExpressionData(ee);
Collection<ProcessedExpressionDataVector> preferredVectors = this.processedExpressionDataVectorService.getProcessedDataVectors(ee);
ee = eeService.load(ee.getId());
ee = this.eeService.thawLite(ee);
int numQts = ee.getQuantitationTypes().size();
for (ProcessedExpressionDataVector d : preferredVectors) {
assertTrue(d.getQuantitationType().getIsMaskedPreferred());
assertTrue(ee.getQuantitationTypes().contains(d.getQuantitationType()));
assertNotNull(d.getRankByMean());
assertNotNull(d.getRankByMax());
}
assertNotNull(ee.getNumberOfDataVectors());
ExpressionExperimentValueObject s = expressionExperimentReportService.generateSummary(ee.getId());
assertNotNull(s);
assertEquals(ee.getNumberOfDataVectors(), s.getProcessedExpressionVectorCount());
processedExpressionDataVectorService.computeProcessedExpressionData(ee);
// repeat, make sure deleted old QTs.
ee = eeService.load(ee.getId());
ee = this.eeService.thawLite(ee);
assertEquals(numQts, ee.getQuantitationTypes().size());
}
use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal in project Gemma by PavlidisLab.
the class VectorMergingServiceTest method test.
@Test
public final void test() throws Exception {
/*
* Need a persistent experiment that uses multiple array designs. Then merge the designs, switch the vectors,
* and merge the vectors. GSE3443
*/
/*
* The experiment uses the following GPLs
*
* GPL2868, GPL2933, GPL2934, GPL2935, GPL2936, GPL2937, GPL2938
*
* Example of a sequence appearing on more than one platform: N57553
*/
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("gse3443merge")));
Collection<?> results = geoService.fetchAndLoad("GSE3443", false, false, false);
ee = (ExpressionExperiment) results.iterator().next();
ee = this.eeService.thawLite(ee);
Collection<ArrayDesign> aas = eeService.getArrayDesignsUsed(ee);
assertEquals(7, aas.size());
/*
* Check number of sequences across all platforms. This is how many elements we need on the new platform, plus
* extras for duplicated sequences (e.g. elements that don't have a sequence...)
*/
Collection<ArrayDesign> taas = new HashSet<>();
Set<BioSequence> oldbs = new HashSet<>();
for (ArrayDesign arrayDesign : aas) {
arrayDesign = arrayDesignService.thaw(arrayDesign);
taas.add(arrayDesign);
for (CompositeSequence cs : arrayDesign.getCompositeSequences()) {
log.info(cs + " " + cs.getBiologicalCharacteristic());
oldbs.add(cs.getBiologicalCharacteristic());
}
}
assertEquals(63, oldbs.size());
/*
* Check total size of elements across all 7 platforms.
*/
int totalElements = 0;
for (ArrayDesign arrayDesign : taas) {
totalElements += arrayDesign.getCompositeSequences().size();
}
assertEquals(140, totalElements);
ArrayDesign firstaa = taas.iterator().next();
aas.remove(firstaa);
assertEquals(null, firstaa.getMergedInto());
mergedAA = arrayDesignMergeService.merge(firstaa, taas, "testMerge" + RandomStringUtils.randomAlphabetic(5), "merged" + RandomStringUtils.randomAlphabetic(5), false);
assertEquals(72, mergedAA.getCompositeSequences().size());
Set<BioSequence> seenBs = new HashSet<>();
for (CompositeSequence cs : mergedAA.getCompositeSequences()) {
seenBs.add(cs.getBiologicalCharacteristic());
}
assertEquals(63, seenBs.size());
// just to make this explicit. The new array design has to contain all the old sequences.
assertEquals(oldbs.size(), seenBs.size());
ee = eeService.thaw(ee);
assertEquals(1828, ee.getRawExpressionDataVectors().size());
ee = eePlatformSwitchService.switchExperimentToArrayDesign(ee, mergedAA);
ee = eeService.thaw(ee);
// check we actually got switched over.
for (BioAssay ba : ee.getBioAssays()) {
assertEquals(mergedAA, ba.getArrayDesignUsed());
}
for (RawExpressionDataVector v : ee.getRawExpressionDataVectors()) {
assertEquals(mergedAA, v.getDesignElement().getArrayDesign());
}
assertEquals(15, ee.getQuantitationTypes().size());
assertEquals(1828, ee.getRawExpressionDataVectors().size());
ee = vectorMergingService.mergeVectors(ee);
// check we got the right processed data
Collection<ProcessedExpressionDataVector> pvs = processedExpressionDataVectorService.getProcessedDataVectors(ee);
assertEquals(72, pvs.size());
ee = eeService.thaw(ee);
Collection<DoubleVectorValueObject> processedDataArrays = processedExpressionDataVectorService.getProcessedDataArrays(ee, 50);
assertEquals(50, processedDataArrays.size());
}
use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal in project Gemma by PavlidisLab.
the class ExpressionExperimentBatchCorrectionServiceTest method testComBatOnEE.
@Test
public void testComBatOnEE() throws Exception {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("gse18162Short")));
ExpressionExperiment newee;
try {
Collection<?> results = geoService.fetchAndLoad("GSE18162", false, true, false);
newee = (ExpressionExperiment) results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
newee = (ExpressionExperiment) ((List<?>) e.getData()).iterator().next();
}
assertNotNull(newee);
newee = expressionExperimentService.thawLite(newee);
processedExpressionDataVectorService.computeProcessedExpressionData(newee);
try (InputStream deis = this.getClass().getResourceAsStream("/data/loader/expression/geo/gse18162Short/design.txt")) {
experimentalDesignImporter.importDesign(newee, deis);
}
ExpressionDataDoubleMatrix comBat = correctionService.comBat(newee);
assertNotNull(comBat);
}
use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal in project Gemma by PavlidisLab.
the class SVDServiceImplTest method testsvdGapped.
/*
* See bug 2139; two different sets of bioassays in the data.
*/
@Test
public void testsvdGapped() throws Exception {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("gse482short")));
// also used in the GeoDatasetServiceIntegrationTest.
try {
Collection<?> results = geoService.fetchAndLoad("GSE482", false, true, false);
ee = (ExpressionExperiment) results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
if (e.getData() instanceof List) {
ee = (ExpressionExperiment) ((List<?>) e.getData()).iterator().next();
} else {
ee = (ExpressionExperiment) e.getData();
}
}
assertNotNull(ee);
ee = eeService.thaw(ee);
processedExpressionDataVectorService.createProcessedDataVectors(ee);
ee = eeService.findByShortName("GSE482");
assertNotNull(ee);
SVDValueObject svd = svdService.svd(ee.getId());
assertNotNull(svd);
assertNotNull(svd.getvMatrix());
assertEquals(10, svd.getBioMaterialIds().length);
}
use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal in project Gemma by PavlidisLab.
the class ArrayDesignSequenceProcessorTest method testFetchAndLoadWithSequences.
@Test
public void testFetchAndLoadWithSequences() throws Exception {
GeoService geoService = this.getBean(GeoService.class);
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath()));
@SuppressWarnings("unchecked") final Collection<ArrayDesign> ads = (Collection<ArrayDesign>) geoService.fetchAndLoad("GPL226", true, true, false);
result = ads.iterator().next();
result = arrayDesignService.thaw(result);
try {
Collection<BioSequence> res = app.processArrayDesign(result, new String[] { "testblastdb", "testblastdbPartTwo" }, FileTools.resourceToPath("/data/loader/genome/blast"), false);
assertNotNull(res);
for (BioSequence sequence : res) {
assertNotNull(sequence.getSequence());
}
} catch (Exception e) {
if (StringUtils.isNotBlank(e.getMessage()) && e.getMessage().contains("not found")) {
log.error("fastacmd is not installed or is misconfigured. Test skipped");
return;
}
throw e;
}
}
Aggregations