Search in sources :

Example 11 with ExpressionExperiment

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

the class SearchServiceImpl method characteristicExpressionExperimentSearch.

private Collection<SearchResult> characteristicExpressionExperimentSearch(final SearchSettings settings) {
    Collection<SearchResult> results = new HashSet<>();
    // this is a collection because of the API
    Collection<Class<?>> classToSearch = new ArrayList<>(1);
    // for characteristicService; could add
    // findByUri(Class<?>...)
    // order matters.
    Queue<Class<?>> orderedClassesToSearch = new LinkedList<>();
    orderedClassesToSearch.add(ExpressionExperiment.class);
    orderedClassesToSearch.add(FactorValue.class);
    orderedClassesToSearch.add(BioMaterial.class);
    orderedClassesToSearch.add(Treatment.class);
    Collection<SearchResult> characterSearchResults = new HashSet<>();
    while (characterSearchResults.size() < SearchServiceImpl.SUFFICIENT_EXPERIMENT_RESULTS_FROM_CHARACTERISTICS && !orderedClassesToSearch.isEmpty()) {
        classToSearch.clear();
        classToSearch.add(orderedClassesToSearch.poll());
        // We handle the OR clauses here.
        String[] subclauses = settings.getQuery().split(" OR ");
        for (String subclause : subclauses) {
            /*
                 * Note that the AND is applied only within one entity type. The fix would be to apply AND at this
                 * level.
                 */
            Collection<SearchResult> classResults = this.characteristicSearchWithChildren(classToSearch, subclause);
            if (!classResults.isEmpty()) {
                String msg = "Found " + classResults.size() + " " + classToSearch.iterator().next().getSimpleName() + " results from characteristic search.";
                if (characterSearchResults.size() >= SearchServiceImpl.SUFFICIENT_EXPERIMENT_RESULTS_FROM_CHARACTERISTICS) {
                    msg += " Total found > " + SearchServiceImpl.SUFFICIENT_EXPERIMENT_RESULTS_FROM_CHARACTERISTICS + ", will not search for more entities.";
                }
                SearchServiceImpl.log.info(msg);
            }
            characterSearchResults.addAll(classResults);
        }
    }
    StopWatch watch = new StopWatch();
    watch.start();
    // filter and get parents...
    int numEEs = 0;
    Collection<BioMaterial> biomaterials = new HashSet<>();
    Collection<FactorValue> factorValues = new HashSet<>();
    Collection<Treatment> treatments = new HashSet<>();
    for (SearchResult sr : characterSearchResults) {
        Class<?> resultClass = sr.getResultClass();
        // highlightedText.put( sr.getResultObject(), sr.getHighlightedText() );
        if (ExpressionExperiment.class.isAssignableFrom(resultClass)) {
            sr.setHighlightedText(sr.getHighlightedText() + " (characteristic)");
            results.add(sr);
            numEEs++;
        } else if (BioMaterial.class.isAssignableFrom(resultClass)) {
            biomaterials.add((BioMaterial) sr.getResultObject());
        } else if (FactorValue.class.isAssignableFrom(resultClass)) {
            factorValues.add((FactorValue) sr.getResultObject());
        } else if (Treatment.class.isAssignableFrom(resultClass)) {
            treatments.add((Treatment) sr.getResultObject());
        }
    }
    /*
         * Much faster to batch it...but we loose track of which search result came from which, so we put generic
         * highlighted text.
         */
    if (biomaterials.size() > 0) {
        Collection<ExpressionExperiment> ees = expressionExperimentService.findByBioMaterials(biomaterials);
        for (ExpressionExperiment ee : ees) {
            results.add(new SearchResult(ee, SearchServiceImpl.INDIRECT_DB_HIT_PENALTY, "BioMaterial characteristic"));
        }
    }
    this.addEEeByFactorvalues(results, factorValues);
    if (treatments.size() > 0) {
        SearchServiceImpl.log.info("Not processing treatments, but hits were found");
    }
    if (SearchServiceImpl.log.isDebugEnabled()) {
        SearchServiceImpl.log.debug("ExpressionExperiment search: " + settings + " -> " + results.size() + " characteristic hits");
    }
    if (watch.getTime() > 1000) {
        SearchServiceImpl.log.info("Retrieving " + results.size() + " experiments from " + characterSearchResults.size() + " retrieved characteristics took " + watch.getTime() + " ms");
        SearchServiceImpl.log.info("Breakdown: " + numEEs + " via direct association with EE; " + biomaterials.size() + " via association with Biomaterial; " + factorValues.size() + " via experimental design");
    }
    return results;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) StopWatch(org.apache.commons.lang3.time.StopWatch) Treatment(ubic.gemma.model.expression.biomaterial.Treatment)

Example 12 with ExpressionExperiment

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

the class ProcessedExpressionDataVectorCreateTaskImpl method execute.

@Override
public TaskResult execute() {
    ExpressionExperiment ee = taskCommand.getExpressionExperiment();
    Collection<ProcessedExpressionDataVector> processedVectors;
    if (taskCommand.isCorrelationMatrixOnly()) {
        // only create them if necessary. This is sort of stupid, it's just so I didn't have to create a whole other
        // task for the correlation matrix computation.
        processedVectors = processedExpressionDataVectorService.getProcessedDataVectors(ee);
        if (processedVectors.isEmpty()) {
            processedVectors = processedExpressionDataVectorService.computeProcessedExpressionData(ee);
        }
    } else {
        processedVectors = processedExpressionDataVectorService.computeProcessedExpressionData(ee);
    }
    coexpressionMatrixService.create(ee);
    return new TaskResult(taskCommand, processedVectors.size());
}
Also used : ProcessedExpressionDataVector(ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector) TaskResult(ubic.gemma.core.job.TaskResult) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 13 with ExpressionExperiment

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

the class TwoChannelMissingValueTaskImpl method execute.

@Override
public TaskResult execute() {
    ExpressionExperiment ee = taskCommand.getExpressionExperiment();
    Collection<RawExpressionDataVector> missingValueVectors = twoChannelMissingValues.computeMissingValues(ee, taskCommand.getS2n(), taskCommand.getExtraMissingValueIndicators());
    System.out.println("MVs: " + missingValueVectors.size());
    return new TaskResult(taskCommand, missingValueVectors.size());
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) TaskResult(ubic.gemma.core.job.TaskResult) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 14 with ExpressionExperiment

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

the class BaselineDetectionTest method setUp.

@Before
public void setUp() throws Exception {
    String path = FileTools.resourceToPath("/data/loader/expression/geo/gse18162Short");
    try {
        geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(path));
        Collection<?> results = geoService.fetchAndLoad("GSE18162", false, true, false);
        ee = (ExpressionExperiment) results.iterator().next();
    } catch (AlreadyExistsInSystemException e) {
        // OK.
        if (e.getData() instanceof List) {
            ee = (ExpressionExperiment) ((List<?>) e.getData()).iterator().next();
        } else {
            ee = (ExpressionExperiment) e.getData();
        }
    }
    ee = this.eeService.thawLite(ee);
    if (ee.getExperimentalDesign().getExperimentalFactors().isEmpty()) {
        ee = eeService.load(ee.getId());
        ee = this.eeService.thawLite(ee);
        try (InputStream is = this.getClass().getResourceAsStream("/data/loader/expression/geo/gse18162Short/design.txt")) {
            experimentalDesignImporter.importDesign(ee, is);
        }
        ee = eeService.load(ee.getId());
        ee = this.eeService.thawLite(ee);
    }
// end setup
}
Also used : InputStream(java.io.InputStream) 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) Before(org.junit.Before)

Example 15 with ExpressionExperiment

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

the class DiffExMetaAnalyzerServiceTest method cleanup.

private void cleanup() {
    for (GeneDifferentialExpressionMetaAnalysisSummaryValueObject vo : geneDiffExMetaAnalysisHelperService.loadAllMetaAnalyses()) {
        analysisService.delete(vo.getId());
    }
    this.deleteSet("GSE2018");
    this.deleteSet("GSE2111");
    this.deleteSet("GSE6344");
    ArrayDesign gpl96 = arrayDesignService.findByShortName("GPL96");
    ArrayDesign gpl97 = arrayDesignService.findByShortName("GPL97");
    if (gpl96 != null) {
        for (ExpressionExperiment ee : arrayDesignService.getExpressionExperiments(gpl96)) {
            experimentService.remove(ee);
        }
        arrayDesignService.remove(gpl96);
    }
    if (gpl97 != null) {
        for (ExpressionExperiment ee : arrayDesignService.getExpressionExperiments(gpl97)) {
            experimentService.remove(ee);
        }
        arrayDesignService.remove(gpl97);
    }
    Collection<Gene> genes = geneService.loadAll();
    for (Gene gene : genes) {
        try {
            geneService.remove(gene);
        } catch (Exception e) {
            log.warn("Failed to remove gene " + gene);
        }
    }
}
Also used : Gene(ubic.gemma.model.genome.Gene) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException)

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