Search in sources :

Example 1 with ExpressionExperimentValueObject

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

the class DatasetsRestTest method testAll.

@Test
public void testAll() {
    ResponseDataObject response = datasetsWebService.all(DatasetFilterArg.valueOf(""), IntArg.valueOf("5"), IntArg.valueOf("5"), SortArg.valueOf("+id"), new MockHttpServletResponse());
    assertNotNull(response.getData());
    assertTrue(response.getData() instanceof Collection<?>);
    assertEquals(5, ((Collection) response.getData()).size());
    assertTrue(((Collection) response.getData()).iterator().next() instanceof ExpressionExperimentValueObject);
}
Also used : ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) ResponseDataObject(ubic.gemma.web.services.rest.util.ResponseDataObject) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Example 2 with ExpressionExperimentValueObject

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

the class DifferentialExpressionProbeResultEndpoint method invokeInternal.

/**
 * Reads the given <code>requestElement</code>, and sends a the response back.
 *
 * @param requestElement the contents of the SOAP message as DOM elements
 * @param document       a DOM document to be used for constructing <code>Node</code>s
 * @return the response element
 */
@Override
protected Element invokeInternal(Element requestElement, Document document) {
    StopWatch watch = new StopWatch();
    watch.start();
    setLocalName(LOCAL_NAME);
    // taxon input
    Collection<String> taxonInput = getSingleNodeValue(requestElement, "taxon_id");
    String taxonId = "";
    for (String id : taxonInput) {
        taxonId = id;
    }
    Taxon taxon = taxonService.load(Long.parseLong(taxonId));
    if (taxon == null) {
        String msg = "No taxon with id, " + taxonId + ", can be found.";
        return buildBadResponse(document, msg);
    }
    // gene ids input
    Collection<String> geneInput = getArrayValues(requestElement, "gene_ids");
    Collection<Long> geneIDLong = new HashSet<Long>();
    for (String id : geneInput) geneIDLong.add(Long.parseLong(id));
    Collection<Gene> rawGeneCol = geneService.loadThawed(geneIDLong);
    if (rawGeneCol.isEmpty()) {
        String msg = "None of the gene id's can be found.";
        return buildBadResponse(document, msg);
    }
    Collection<Gene> geneCol = retainGenesInCorrectTaxon(rawGeneCol, taxon);
    if (geneCol == null || geneCol.isEmpty()) {
        String msg = "Input genes do not match input taxon.";
        return buildBadResponse(document, msg);
    }
    // expression experiment set id input
    Collection<String> analysisInput = getSingleNodeValue(requestElement, "expression_experiment_set_id");
    String analysisId = "";
    for (String id : analysisInput) {
        analysisId = id;
    }
    ExpressionExperimentSet ees = expressionExperimentSetService.load(Long.parseLong(analysisId));
    if (ees == null) {
        String msg = "No matching expression experiment set can be found for id, " + analysisId;
        return buildBadResponse(document, msg);
    }
    if (!(ees.getTaxon().getId()).equals(taxon.getId())) {
        String msg = "Expression experiment set " + analysisId + " does not match input taxon " + taxon.getCommonName();
        return buildBadResponse(document, msg);
    }
    Collection<ExpressionExperiment> eeCol = getExperiments(ees);
    Collection<BioAssaySet> bioAssaySets = new HashSet<BioAssaySet>();
    bioAssaySets.addAll(eeCol);
    // threshold input
    Collection<String> thresholdInput = getSingleNodeValue(requestElement, "threshold");
    String threshold = "";
    for (String id : thresholdInput) {
        threshold = id;
    }
    log.info("XML input read: " + geneInput.size() + " gene ids,  & taxon id " + taxonId + ", & expression experiment set id " + analysisId + ", and threshold " + threshold);
    Element responseWrapper = document.createElementNS(NAMESPACE_URI, LOCAL_NAME);
    Element responseElement = document.createElementNS(NAMESPACE_URI, LOCAL_NAME + RESPONSE);
    responseWrapper.appendChild(responseElement);
    for (Gene gene : geneCol) {
        Map<ExpressionExperimentValueObject, List<DifferentialExpressionValueObject>> results = differentialExpressionResultService.find(gene, EntityUtils.getIds(bioAssaySets), Double.parseDouble(threshold), null);
        for (ExpressionExperimentValueObject ee : results.keySet()) {
            // main call to the DifferentialExpressionAnalysisService to retrieve
            // DifferentialExpressionAnalysisResultSet collection
            Collection<DifferentialExpressionValueObject> parCol = results.get(ee);
            // check that a DifferentialExpressionAnalysisResult is not null
            if (parCol == null || parCol.isEmpty()) {
                log.error("No probe analysis results can be found for gene: " + gene.getOfficialSymbol() + " & experiment: " + ee);
                buildXMLResponse(document, responseElement, gene.getId().toString(), ee.getId().toString(), null);
            } else
                buildXMLResponse(document, responseElement, gene.getId().toString(), ee.getId().toString(), parCol);
        }
    }
    watch.stop();
    Long time = watch.getTime();
    log.info("XML response for differential expression probe results built in " + time + "ms.");
    return responseWrapper;
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) Element(org.w3c.dom.Element) DifferentialExpressionValueObject(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionValueObject) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) StopWatch(org.apache.commons.lang3.time.StopWatch) Gene(ubic.gemma.model.genome.Gene) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet)

Example 3 with ExpressionExperimentValueObject

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

the class SVDServiceHelperImpl method getTopLoadedVectors.

@Override
public Map<ProbeLoading, DoubleVectorValueObject> getTopLoadedVectors(ExpressionExperiment ee, int component, int count) {
    PrincipalComponentAnalysis pca = principalComponentAnalysisService.loadForExperiment(ee);
    Map<ProbeLoading, DoubleVectorValueObject> result = new HashMap<>();
    if (pca == null) {
        return result;
    }
    List<ProbeLoading> topLoadedProbes = principalComponentAnalysisService.getTopLoadedProbes(ee, component, count);
    if (topLoadedProbes == null) {
        SVDServiceHelperImpl.log.warn("No probes?");
        return result;
    }
    Map<Long, ProbeLoading> probes = new LinkedHashMap<>();
    Set<CompositeSequence> p = new HashSet<>();
    for (ProbeLoading probeLoading : topLoadedProbes) {
        CompositeSequence probe = probeLoading.getProbe();
        probes.put(probe.getId(), probeLoading);
        p.add(probe);
    }
    if (probes.isEmpty())
        return result;
    assert probes.size() <= count;
    Collection<ExpressionExperiment> ees = new HashSet<>();
    ees.add(ee);
    Collection<DoubleVectorValueObject> dvVos = processedExpressionDataVectorService.getProcessedDataArraysByProbe(ees, p);
    if (dvVos.isEmpty()) {
        SVDServiceHelperImpl.log.warn("No vectors came back from the call; check the Gene2CS table?");
        return result;
    }
    // note that this might have come from a cache.
    /*
         * This is actually expected, because we go through the genes.
         */
    BioAssayDimension bioAssayDimension = pca.getBioAssayDimension();
    assert bioAssayDimension != null;
    assert !bioAssayDimension.getBioAssays().isEmpty();
    for (DoubleVectorValueObject vct : dvVos) {
        ProbeLoading probeLoading = probes.get(vct.getDesignElement().getId());
        if (probeLoading == null) {
            /*
                 * This is okay, we will skip this probe. It was another probe for a gene that _was_ highly loaded.
                 */
            continue;
        }
        assert bioAssayDimension.getBioAssays().size() == vct.getData().length;
        vct.setRank(probeLoading.getLoadingRank().doubleValue());
        vct.setExpressionExperiment(new ExpressionExperimentValueObject(ee));
        result.put(probeLoading, vct);
    }
    if (result.isEmpty()) {
        SVDServiceHelperImpl.log.warn("No results, something went wrong; there were " + dvVos.size() + " vectors to start but they all got filtered out.");
    }
    return result;
}
Also used : ProbeLoading(ubic.gemma.model.analysis.expression.pca.ProbeLoading) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) PrincipalComponentAnalysis(ubic.gemma.model.analysis.expression.pca.PrincipalComponentAnalysis) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) DoubleVectorValueObject(ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject)

Example 4 with ExpressionExperimentValueObject

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

the class GeneralSearchControllerImpl method fillValueObjects.

@SuppressWarnings("unchecked")
private void fillValueObjects(Class<?> entityClass, List<SearchResult> results, SearchSettings settings) {
    StopWatch timer = new StopWatch();
    timer.start();
    Collection<?> vos;
    if (ExpressionExperiment.class.isAssignableFrom(entityClass)) {
        vos = this.filterEE(expressionExperimentService.loadValueObjects(EntityUtils.getIds(results), false), settings);
        if (!SecurityUtil.isUserAdmin()) {
            auditableUtil.removeTroubledEes((Collection<ExpressionExperimentValueObject>) vos);
        }
    } else if (ArrayDesign.class.isAssignableFrom(entityClass)) {
        vos = this.filterAD(arrayDesignService.loadValueObjectsByIds(EntityUtils.getIds(results)), settings);
        if (!SecurityUtil.isUserAdmin()) {
            auditableUtil.removeTroubledArrayDesigns((Collection<ArrayDesignValueObject>) vos);
        }
    } else if (CompositeSequence.class.isAssignableFrom(entityClass)) {
        Collection<CompositeSequenceValueObject> css = new ArrayList<>();
        for (SearchResult sr : results) {
            CompositeSequenceValueObject csvo = compositeSequenceService.loadValueObject((CompositeSequence) sr.getResultObject());
            css.add(csvo);
        }
        vos = css;
    } else if (BibliographicReference.class.isAssignableFrom(entityClass)) {
        Collection<BibliographicReference> bss = bibliographicReferenceService.load(EntityUtils.getIds(results));
        bss = bibliographicReferenceService.thaw(bss);
        vos = bibliographicReferenceService.loadValueObjects(bss);
    } else if (Gene.class.isAssignableFrom(entityClass)) {
        Collection<Gene> genes = geneService.load(EntityUtils.getIds(results));
        genes = geneService.thawLite(genes);
        vos = geneService.loadValueObjects(genes);
    } else if (Characteristic.class.isAssignableFrom(entityClass)) {
        Collection<CharacteristicValueObject> cvos = new ArrayList<>();
        for (SearchResult sr : results) {
            Characteristic ch = (Characteristic) sr.getResultObject();
            cvos.add(new CharacteristicValueObject(ch));
        }
        vos = cvos;
    } else if (CharacteristicValueObject.class.isAssignableFrom(entityClass)) {
        Collection<CharacteristicValueObject> cvos = new ArrayList<>();
        for (SearchResult sr : results) {
            CharacteristicValueObject ch = (CharacteristicValueObject) sr.getResultObject();
            cvos.add(ch);
        }
        vos = cvos;
    } else if (BioSequenceValueObject.class.isAssignableFrom(entityClass)) {
        return;
    } else if (GeneSet.class.isAssignableFrom(entityClass)) {
        vos = geneSetService.getValueObjects(EntityUtils.getIds(results));
    } else if (ExpressionExperimentSet.class.isAssignableFrom(entityClass)) {
        vos = experimentSetService.loadValueObjects(experimentSetService.load(EntityUtils.getIds(results)));
    } else if (FactorValue.class.isAssignableFrom(entityClass)) {
        Collection<FactorValueValueObject> fvo = new ArrayList<>();
        for (SearchResult sr : results) {
            fvo.add(new FactorValueValueObject((FactorValue) sr.getResultObject()));
        }
        vos = fvo;
    } else {
        throw new UnsupportedOperationException("Don't know how to make value objects for class=" + entityClass);
    }
    if (vos == null || vos.isEmpty()) {
        // it causing front end errors, if vos is empty make sure to get rid of all search results
        for (Iterator<SearchResult> it = results.iterator(); it.hasNext(); ) {
            it.next();
            it.remove();
        }
        return;
    }
    // retained objects...
    Map<Long, Object> idMap = EntityUtils.getIdMap(vos);
    for (Iterator<SearchResult> it = results.iterator(); it.hasNext(); ) {
        SearchResult sr = it.next();
        if (!idMap.containsKey(sr.getId())) {
            it.remove();
            continue;
        }
        sr.setResultObject(idMap.get(sr.getId()));
    }
    if (timer.getTime() > 1000) {
        BaseFormController.log.info("Value object conversion after search: " + timer.getTime() + "ms");
    }
}
Also used : CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) Gene(ubic.gemma.model.genome.Gene) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) BioSequenceValueObject(ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject) FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Characteristic(ubic.gemma.model.common.description.Characteristic) SearchResult(ubic.gemma.core.search.SearchResult) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) StopWatch(org.apache.commons.lang3.time.StopWatch) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) SearchSettingsValueObject(ubic.gemma.model.common.search.SearchSettingsValueObject) FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) BioSequenceValueObject(ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)

Example 5 with ExpressionExperimentValueObject

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

the class BibliographicReferenceControllerImpl method showAllForExperiments.

@Override
public ModelAndView showAllForExperiments(HttpServletRequest request, HttpServletResponse response) {
    Map<ExpressionExperiment, BibliographicReference> eeToBibRefs = bibliographicReferenceService.getAllExperimentLinkedReferences();
    // map sorted in natural order of the keys
    SortedMap<CitationValueObject, Collection<ExpressionExperimentValueObject>> citationToEEs = new TreeMap<>();
    for (Entry<ExpressionExperiment, BibliographicReference> entry : eeToBibRefs.entrySet()) {
        if (entry.getValue().getTitle() == null || entry.getValue().getTitle().isEmpty() || entry.getValue().getAuthorList() == null || entry.getValue().getAuthorList().isEmpty()) {
            continue;
        }
        CitationValueObject cvo = CitationValueObject.convert2CitationValueObject(entry.getValue());
        if (!citationToEEs.containsKey(cvo)) {
            citationToEEs.put(cvo, new ArrayList<ExpressionExperimentValueObject>());
        }
        ExpressionExperiment ee = entry.getKey();
        ee.setBioAssays(null);
        ee.setAccession(null);
        ee.setExperimentalDesign(null);
        citationToEEs.get(cvo).add(new ExpressionExperimentValueObject(ee));
    }
    return new ModelAndView("bibRefAllExperiments").addObject("citationToEEs", citationToEEs);
}
Also used : ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) CitationValueObject(ubic.gemma.model.common.description.CitationValueObject) ModelAndView(org.springframework.web.servlet.ModelAndView) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference)

Aggregations

ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)21 StopWatch (org.apache.commons.lang3.time.StopWatch)4 Test (org.junit.Test)4 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)4 Taxon (ubic.gemma.model.genome.Taxon)4 BaseSpringWebTest (ubic.gemma.web.util.BaseSpringWebTest)4 ModelAndView (org.springframework.web.servlet.ModelAndView)3 SearchResult (ubic.gemma.core.search.SearchResult)3 ExpressionExperimentSet (ubic.gemma.model.analysis.expression.ExpressionExperimentSet)3 ExpressionExperimentDetailsValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject)3 Gene (ubic.gemma.model.genome.Gene)3 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 SearchResultDisplayObject (ubic.gemma.core.search.SearchResultDisplayObject)2 BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)2 CitationValueObject (ubic.gemma.model.common.description.CitationValueObject)2 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)2 ArrayDesignValueObject (ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)2 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)2 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)2 BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)2