Search in sources :

Example 31 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class ExpressionExperimentPlatformSwitchTest method test.

/**
 * for bug 3451
 */
@Test
public void test() {
    // GSE36025
    // 
    // GPL9250
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGenerator());
    Collection<?> results = geoService.fetchAndLoad("GSE36025", false, false, false);
    ExpressionExperiment ee = (ExpressionExperiment) results.iterator().next();
    results = geoService.fetchAndLoad("GPL13112", true, false, false);
    ArrayDesign arrayDesign = (ArrayDesign) results.iterator().next();
    arrayDesign = arrayDesignService.thaw(arrayDesign);
    ee = experimentPlatformSwitchService.switchExperimentToArrayDesign(ee, arrayDesign);
    assertNotNull(ee);
    Collection<ArrayDesign> arrayDesignsUsed = experimentService.getArrayDesignsUsed(ee);
    assertEquals(1, arrayDesignsUsed.size());
    assertEquals(arrayDesign, arrayDesignsUsed.iterator().next());
}
Also used : GeoDomainObjectGenerator(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGenerator) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 32 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class SampleCoexpressionMatrixServiceTest method test.

@Test
public void test() {
    ExpressionExperiment ee = super.getTestPersistentCompleteExpressionExperiment(false);
    processedExpressionDataVectorService.computeProcessedExpressionData(ee);
    DoubleMatrix<BioAssay, BioAssay> matrix = sampleCoexpressionMatrixService.create(ee);
    this.check(matrix);
    // recompute ...
    matrix = sampleCoexpressionMatrixService.create(ee);
    this.check(matrix);
    matrix = sampleCoexpressionMatrixService.findOrCreate(ee);
    this.check(matrix);
}
Also used : ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 33 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class SecureValueObjectAuthorizationTest method setup.

@Before
public void setup() {
    ExpressionExperiment publicEe = super.getTestPersistentBasicExpressionExperiment();
    securityService.makePublic(publicEe);
    publicExpressionExperimentId = publicEe.getId();
    ee = super.getTestPersistentBasicExpressionExperiment();
    ownersExpressionExperimentId = ee.getId();
    this.makeUser(ownerUsername);
    this.securityService.makeOwnedByUser(ee, ownerUsername);
    this.makeUser(aDifferentUsername);
}
Also used : ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) Before(org.junit.Before)

Example 34 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class DatabaseViewGeneratorImpl method generateDifferentialExpressionView.

private void generateDifferentialExpressionView(Integer limit, Collection<ExpressionExperiment> experiments) throws IOException {
    DatabaseViewGeneratorImpl.log.info("Generating dataset diffex view");
    /*
         * Get handle to output file
         */
    File file = this.getViewFile(DatabaseViewGeneratorImpl.DATASET_DIFFEX_VIEW_BASENAME);
    DatabaseViewGeneratorImpl.log.info("Writing to " + file);
    try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)))) {
        /*
             * For each gene that is differentially expressed, print out a line per contrast
             */
        writer.write("GemmaDsId\tEEShortName\tGeneNCBIId\tGemmaGeneId\tFactor\tFactorURI\tBaseline\tContrasting\tDirection\n");
        int i = 0;
        for (ExpressionExperiment ee : experiments) {
            ee = expressionExperimentService.thawLite(ee);
            Collection<DifferentialExpressionAnalysis> results = differentialExpressionAnalysisService.getAnalyses(ee);
            if (results == null || results.isEmpty()) {
                DatabaseViewGeneratorImpl.log.warn("No differential expression results found for " + ee);
                continue;
            }
            // noinspection StatementWithEmptyBody // FIXME. Should probably skip for this purpose.
            if (results.size() > 1) {
            }
            DatabaseViewGeneratorImpl.log.info("Processing: " + ee.getShortName());
            for (DifferentialExpressionAnalysis analysis : results) {
                analysis = this.differentialExpressionAnalysisService.thawFully(analysis);
                for (ExpressionAnalysisResultSet ears : analysis.getResultSets()) {
                    // ears = differentialExpressionResultService.thawRawAndProcessed( ears );
                    FactorValue baselineGroup = ears.getBaselineGroup();
                    if (baselineGroup == null) {
                        // log.warn( "No baseline defined for " + ee ); // interaction
                        continue;
                    }
                    if (ExperimentalDesignUtils.isBatch(baselineGroup.getExperimentalFactor())) {
                        continue;
                    }
                    String baselineDescription = ExperimentalDesignUtils.prettyString(baselineGroup);
                    // Get the factor category name
                    StringBuilder factorName = new StringBuilder();
                    StringBuilder factorURI = new StringBuilder();
                    for (ExperimentalFactor ef : ears.getExperimentalFactors()) {
                        factorName.append(ef.getName()).append(",");
                        if (ef.getCategory() instanceof VocabCharacteristic) {
                            factorURI.append(ef.getCategory().getCategoryUri()).append(",");
                        }
                    }
                    factorName = new StringBuilder(StringUtils.removeEnd(factorName.toString(), ","));
                    factorURI = new StringBuilder(StringUtils.removeEnd(factorURI.toString(), ","));
                    if (ears.getResults() == null || ears.getResults().isEmpty()) {
                        DatabaseViewGeneratorImpl.log.warn("No  differential expression analysis results found for " + ee);
                        continue;
                    }
                    // Generate probe details
                    for (DifferentialExpressionAnalysisResult dear : ears.getResults()) {
                        if (dear == null) {
                            DatabaseViewGeneratorImpl.log.warn("Missing results for " + ee + " skipping to next. ");
                            continue;
                        }
                        if (dear.getCorrectedPvalue() == null || dear.getCorrectedPvalue() > DatabaseViewGeneratorImpl.THRESH_HOLD)
                            continue;
                        String formatted = this.formatDiffExResult(ee, dear, factorName.toString(), factorURI.toString(), baselineDescription);
                        if (StringUtils.isNotBlank(formatted))
                            writer.write(formatted);
                    }
                // dear loop
                }
            // ears loop
            }
            if (limit != null && (limit > 0 && ++i > limit))
                break;
        }
    // EE loop
    }
}
Also used : FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) DifferentialExpressionAnalysisResult(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet) GZIPOutputStream(java.util.zip.GZIPOutputStream)

Example 35 with ExpressionExperiment

use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.

the class DatabaseViewGeneratorImpl method generateDatasetView.

private void generateDatasetView(Integer limit, Collection<ExpressionExperiment> experiments) throws IOException {
    DatabaseViewGeneratorImpl.log.info("Generating dataset summary view");
    /*
         * Get handle to output file
         */
    File file = this.getViewFile(DatabaseViewGeneratorImpl.DATASET_SUMMARY_VIEW_BASENAME);
    DatabaseViewGeneratorImpl.log.info("Writing to " + file);
    try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)))) {
        writer.write("GemmaDsId\tSource\tSourceAccession\tShortName\tName\tDescription\ttaxon\tManufacturer\n");
        /*
             * Print out their names etc.
             */
        int i = 0;
        for (ExpressionExperiment ee : experiments) {
            ee = expressionExperimentService.thawLite(ee);
            DatabaseViewGeneratorImpl.log.info("Processing: " + ee.getShortName());
            String acc = "";
            String source = "";
            if (ee.getAccession() != null && ee.getAccession().getAccession() != null) {
                acc = ee.getAccession().getAccession();
                source = ee.getAccession().getExternalDatabase().getName();
            }
            Long gemmaId = ee.getId();
            String shortName = ee.getShortName();
            String name = ee.getName();
            String description = ee.getDescription();
            description = StringUtils.replaceChars(description, '\t', ' ');
            description = StringUtils.replaceChars(description, '\n', ' ');
            description = StringUtils.replaceChars(description, '\r', ' ');
            Taxon taxon = expressionExperimentService.getTaxon(ee);
            if (taxon == null)
                continue;
            Collection<ArrayDesign> ads = expressionExperimentService.getArrayDesignsUsed(ee);
            StringBuilder manufacturers = new StringBuilder();
            // TODO could cache the arrayDesigns to make faster, thawing ad is time consuming
            for (ArrayDesign ad : ads) {
                ad = arrayDesignService.thawLite(ad);
                if (ad.getDesignProvider() == null) {
                    DatabaseViewGeneratorImpl.log.debug("Array Design: " + ad.getShortName() + " has no design provoider assoicated with it. Skipping");
                    continue;
                }
                manufacturers.append(ad.getDesignProvider().getName()).append(",");
            }
            writer.write(String.format("%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", gemmaId, source, acc, shortName, name, description, taxon.getCommonName(), StringUtils.removeEnd(manufacturers.toString(), ",")));
            if (limit != null && (limit > 0 && ++i > limit))
                break;
        }
    }
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GZIPOutputStream(java.util.zip.GZIPOutputStream)

Aggregations

ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)214 Test (org.junit.Test)71 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)42 InputStream (java.io.InputStream)36 GeoSeries (ubic.gemma.core.loader.expression.geo.model.GeoSeries)29 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)29 GZIPInputStream (java.util.zip.GZIPInputStream)28 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)26 HashSet (java.util.HashSet)25 BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)25 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)23 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)22 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)20 Collection (java.util.Collection)18 StopWatch (org.apache.commons.lang3.time.StopWatch)18 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)18 Taxon (ubic.gemma.model.genome.Taxon)14 Before (org.junit.Before)12 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11