Search in sources :

Example 36 with GeoDomainObjectGeneratorLocal

use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal 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);
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ProcessedExpressionDataVector(ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) Collection(java.util.Collection) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) HashSet(java.util.HashSet) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 37 with GeoDomainObjectGeneratorLocal

use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal in project Gemma by PavlidisLab.

the class SimpleExpressionDataLoaderServiceTestB method testLoadWithDuplicateBioMaterials.

@Test
public final void testLoadWithDuplicateBioMaterials() throws Exception {
    /*
         * Have to add ssal for this platform.
         */
    // Taxon salmon = taxonService.findByScientificName( "atlantic salmon" );
    // if ( salmon == null ) {
    Taxon salmon = taxonService.findByCommonName("atlantic salmon");
    // }
    assertNotNull(salmon);
    /*
         * Load the array design (platform).
         */
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath()));
    geoService.fetchAndLoad("GPL2716", true, true, false);
    ArrayDesign ad = arrayDesignService.findByShortName("GPL2716");
    assertNotNull(ad);
    try (InputStream data = this.getClass().getResourceAsStream("/data/loader/expression/flatfileload/gill2006hormone.head.txt")) {
        SimpleExpressionExperimentMetaData metaData = new SimpleExpressionExperimentMetaData();
        this.makeMetaData(salmon, ad, metaData);
        ee = simpleExpressionDataLoaderService.create(metaData, data);
    }
    /*
         * Do second one that has overlapping bioassay names.
         */
    try (InputStream data = this.getClass().getResourceAsStream("/data/loader/expression/flatfileload/gill2006oceanfate.head.txt")) {
        SimpleExpressionExperimentMetaData metaData = new SimpleExpressionExperimentMetaData();
        assertNotNull(salmon);
        this.makeMetaData(salmon, ad, metaData);
        ExpressionExperiment a = simpleExpressionDataLoaderService.create(metaData, data);
        // ugly, but try to
        // clean up .
        eeService.remove(a);
    }
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) InputStream(java.io.InputStream) Taxon(ubic.gemma.model.genome.Taxon) SimpleExpressionExperimentMetaData(ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 38 with GeoDomainObjectGeneratorLocal

use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal in project Gemma by PavlidisLab.

the class BatchInfoPopulationServiceIntegrationTest method testLoadCommandConsoleFormat.

/*
     * Another Affymetrix format - GCOS
     */
@Test
public void testLoadCommandConsoleFormat() throws Exception {
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath()));
    ExpressionExperiment newee;
    try {
        Collection<?> results = geoService.fetchAndLoad("GSE20219", false, true, false);
        newee = (ExpressionExperiment) results.iterator().next();
    } catch (AlreadyExistsInSystemException e) {
        newee = (ExpressionExperiment) ((List<?>) e.getData()).iterator().next();
    }
    assertNotNull(newee);
    newee = eeService.thawLite(newee);
    assertTrue(batchInfoPopulationService.fillBatchInformation(newee, true));
    newee = eeService.thawLite(newee);
    for (ExperimentalFactor ef : newee.getExperimentalDesign().getExperimentalFactors()) {
        if (ef.getName().equals(ExperimentalFactorService.BATCH_FACTOR_NAME)) {
            for (FactorValue fv : ef.getFactorValues()) {
                assertNotNull(fv.getValue());
                // Batch_01, Batch_02 etc.
                assertTrue(fv.getValue().startsWith("Batch_0"));
            }
        }
    }
}
Also used : FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) List(java.util.List) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 39 with GeoDomainObjectGeneratorLocal

use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal in project Gemma by PavlidisLab.

the class DiffExWithInvalidInteractionTest method setup.

@Before
public void setup() throws Exception {
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(FileTools.resourceToPath("/data/analysis/expression")));
    try {
        Collection<?> results = geoService.fetchAndLoad("GSE50664", false, true, false);
        ee = (ExpressionExperiment) results.iterator().next();
    } catch (AlreadyExistsInSystemException e) {
        ee = (ExpressionExperiment) ((Collection<?>) e.getData()).iterator().next();
    }
    ee = expressionExperimentService.thawLite(ee);
    Collection<ExperimentalFactor> toremove = new HashSet<>(ee.getExperimentalDesign().getExperimentalFactors());
    for (ExperimentalFactor ef : toremove) {
        experimentalFactorService.delete(ef);
        ee.getExperimentalDesign().getExperimentalFactors().remove(ef);
    }
    expressionExperimentService.update(ee);
    processedExpressionDataVectorService.computeProcessedExpressionData(ee);
    ee = expressionExperimentService.thaw(ee);
    designImporter.importDesign(ee, this.getClass().getResourceAsStream("/data/analysis/expression/8165_GSE50664_expdesign.data.txt"));
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) Collection(java.util.Collection) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 40 with GeoDomainObjectGeneratorLocal

use of ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal in project Gemma by PavlidisLab.

the class DifferentialExpressionAnalyzerServiceTest method testAnalyzeWithSubsetWhenOneIsNotUsableAndWithInteractionInTheOther.

/**
 * Test inspired by bug 2605
 */
@Test
public void testAnalyzeWithSubsetWhenOneIsNotUsableAndWithInteractionInTheOther() throws Exception {
    ee = expressionExperimentService.findByShortName("GSE32136");
    if (ee == null) {
        geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath()));
        Collection<?> results = geoService.fetchAndLoad("GSE32136", false, true, false);
        ee = (ExpressionExperiment) results.iterator().next();
    }
    processedDataVectorService.createProcessedDataVectors(ee);
    ee = expressionExperimentService.thawLite(ee);
    Collection<ExperimentalFactor> experimentalFactors = ee.getExperimentalDesign().getExperimentalFactors();
    for (ExperimentalFactor experimentalFactor : experimentalFactors) {
        experimentalFactorService.delete(experimentalFactor);
    }
    ee = expressionExperimentService.thawLite(ee);
    try (InputStream is = this.getClass().getResourceAsStream("/data/loader/expression/geo/GSE32136.design.txt")) {
        assertNotNull(is);
        experimentalDesignImporter.importDesign(ee, is);
    }
    experimentalFactors = ee.getExperimentalDesign().getExperimentalFactors();
    assertEquals(3, experimentalFactors.size());
    differentialExpressionAnalyzerService.deleteAnalyses(ee);
    // Done with setting it up.
    Collection<ExperimentalFactor> factors = new HashSet<>();
    ExperimentalFactor subsetFactor = null;
    for (ExperimentalFactor ef : experimentalFactors) {
        if (ef.getName().equals("PooledTreatment")) {
            subsetFactor = ef;
        } else {
            factors.add(ef);
        }
    }
    assertNotNull(subsetFactor);
    assertEquals(2, factors.size());
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    config.setFactorsToInclude(factors);
    config.setSubsetFactor(subsetFactor);
    HashSet<Collection<ExperimentalFactor>> ifacts = new HashSet<>();
    ifacts.add(factors);
    config.setInteractionsToInclude(ifacts);
    Collection<DifferentialExpressionAnalysis> analyses = differentialExpressionAnalyzerService.runDifferentialExpressionAnalyses(ee, config);
    assertEquals("Should have quietly ignored one of the subsets that is not analyzable", 1, analyses.size());
    DifferentialExpressionAnalysis analysis = analyses.iterator().next();
    assertEquals("Subsetting was not done correctly", subsetFactor, analysis.getSubsetFactorValue().getExperimentalFactor());
    assertEquals("Interaction was not retained in the analyzed subset", 3, analysis.getResultSets().size());
    ExpressionExperimentSubSet eeset = (ExpressionExperimentSubSet) analysis.getExperimentAnalyzed();
    aclTestUtils.checkEESubSetAcls(eeset);
    aclTestUtils.checkHasAcl(analysis);
    aclTestUtils.checkLacksAces(eeset);
    aclTestUtils.checkLacksAces(analysis);
    // check that we read it back correctly.
    {
        Map<ExpressionExperimentDetailsValueObject, Collection<DifferentialExpressionAnalysisValueObject>> vos = differentialExpressionAnalysisService.getAnalysesByExperiment(Collections.singleton(ee.getId()));
        // it will retrieve the analysis of the subset.
        assertEquals(1, vos.size());
    }
    // retrieve the analysis of the subset directly.
    {
        Map<ExpressionExperimentDetailsValueObject, Collection<DifferentialExpressionAnalysisValueObject>> vos = differentialExpressionAnalysisService.getAnalysesByExperiment(Collections.singleton(eeset.getId()));
        assertEquals(1, vos.size());
        for (DifferentialExpressionAnalysisValueObject vo : vos.entrySet().iterator().next().getValue()) {
            assertNotNull(vo.getSubsetFactorValue());
        }
    }
}
Also used : InputStream(java.io.InputStream) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) ExpressionExperimentSubSet(ubic.gemma.model.expression.experiment.ExpressionExperimentSubSet) DifferentialExpressionAnalysisValueObject(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisValueObject) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Aggregations

GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)45 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)33 Test (org.junit.Test)30 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)30 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)23 Collection (java.util.Collection)13 Before (org.junit.Before)13 HashSet (java.util.HashSet)10 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)10 ProcessedExpressionDataVector (ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector)8 InputStream (java.io.InputStream)7 List (java.util.List)7 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)7 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)7 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)6 File (java.io.File)4 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)4 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)4 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)4 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)3