Search in sources :

Example 16 with ExpressionExperimentValueObject

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

the class LinkAnalysisCli method doWork.

@Override
protected Exception doWork(String[] args) {
    Exception err = this.processCommandLine(args);
    if (err != null) {
        return err;
    }
    if (initializeFromOldData) {
        AbstractCLI.log.info("Initializing links from old data for " + this.taxon);
        LinkAnalysisPersister s = this.getBean(LinkAnalysisPersister.class);
        s.initializeLinksFromOldData(this.taxon);
        return null;
    } else if (updateNodeDegree) {
        // we waste some time here getting the experiments.
        this.loadTaxon();
        this.getBean(CoexpressionService.class).updateNodeDegrees(this.taxon);
        return null;
    }
    this.linkAnalysisService = this.getBean(LinkAnalysisService.class);
    if (this.dataFileName != null) {
        /*
             * Read vectors from file. Could provide as a matrix, but it's easier to provide vectors (less mess in later
             * code)
             */
        ArrayDesignService arrayDesignService = this.getBean(ArrayDesignService.class);
        ArrayDesign arrayDesign = arrayDesignService.findByShortName(this.linkAnalysisConfig.getArrayName());
        if (arrayDesign == null) {
            return new IllegalArgumentException("No such array design " + this.linkAnalysisConfig.getArrayName());
        }
        this.loadTaxon();
        arrayDesign = arrayDesignService.thawLite(arrayDesign);
        Collection<ProcessedExpressionDataVector> dataVectors = new HashSet<>();
        Map<String, CompositeSequence> csMap = new HashMap<>();
        for (CompositeSequence cs : arrayDesign.getCompositeSequences()) {
            csMap.put(cs.getName(), cs);
        }
        QuantitationType qtype = this.makeQuantitationType();
        SimpleExpressionDataLoaderService simpleExpressionDataLoaderService = this.getBean(SimpleExpressionDataLoaderService.class);
        ByteArrayConverter bArrayConverter = new ByteArrayConverter();
        try (InputStream data = new FileInputStream(new File(this.dataFileName))) {
            DoubleMatrix<String, String> matrix = simpleExpressionDataLoaderService.parse(data);
            BioAssayDimension bad = this.makeBioAssayDimension(arrayDesign, matrix);
            for (int i = 0; i < matrix.rows(); i++) {
                byte[] bData = bArrayConverter.doubleArrayToBytes(matrix.getRow(i));
                ProcessedExpressionDataVector vector = ProcessedExpressionDataVector.Factory.newInstance();
                vector.setData(bData);
                CompositeSequence cs = csMap.get(matrix.getRowName(i));
                if (cs == null) {
                    continue;
                }
                vector.setDesignElement(cs);
                vector.setBioAssayDimension(bad);
                vector.setQuantitationType(qtype);
                dataVectors.add(vector);
            }
            AbstractCLI.log.info("Read " + dataVectors.size() + " data vectors");
        } catch (Exception e) {
            return e;
        }
        this.linkAnalysisService.processVectors(this.taxon, dataVectors, filterConfig, linkAnalysisConfig);
    } else {
        /*
             * Do in decreasing order of size, to help capture more links earlier - reduces fragmentation.
             */
        List<BioAssaySet> sees = new ArrayList<>(expressionExperiments);
        if (expressionExperiments.size() > 1) {
            AbstractCLI.log.info("Sorting data sets by number of samples, doing large data sets first.");
            Collection<ExpressionExperimentValueObject> vos = eeService.loadValueObjects(EntityUtils.getIds(expressionExperiments), true);
            final Map<Long, ExpressionExperimentValueObject> idMap = EntityUtils.getIdMap(vos);
            Collections.sort(sees, new Comparator<BioAssaySet>() {

                @Override
                public int compare(BioAssaySet o1, BioAssaySet o2) {
                    ExpressionExperimentValueObject e1 = idMap.get(o1.getId());
                    ExpressionExperimentValueObject e2 = idMap.get(o2.getId());
                    assert e1 != null : "No valueobject: " + e2;
                    assert e2 != null : "No valueobject: " + e1;
                    return -e1.getBioMaterialCount().compareTo(e2.getBioMaterialCount());
                }
            });
        }
        for (BioAssaySet ee : sees) {
            if (ee instanceof ExpressionExperiment) {
                this.processExperiment((ExpressionExperiment) ee);
            } else {
                throw new UnsupportedOperationException("Can't handle non-EE BioAssaySets yet");
            }
        }
        this.summarizeProcessing();
    }
    return null;
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ProcessedExpressionDataVector(ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector) SimpleExpressionDataLoaderService(ubic.gemma.core.loader.expression.simple.SimpleExpressionDataLoaderService) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) FileInputStream(java.io.FileInputStream) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) LinkAnalysisPersister(ubic.gemma.core.analysis.expression.coexpression.links.LinkAnalysisPersister) LinkAnalysisService(ubic.gemma.core.analysis.expression.coexpression.links.LinkAnalysisService) File(java.io.File) ArrayDesignService(ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignService)

Example 17 with ExpressionExperimentValueObject

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

the class ExpressionExperimentSearchServiceImpl method getExpressionExperimentResults.

private List<SearchResultDisplayObject> getExpressionExperimentResults(Map<Class<?>, List<SearchResult>> results) {
    // get all expressionExperiment results and convert result object into a value object
    List<SearchResult> srEEs = results.get(ExpressionExperiment.class);
    if (srEEs == null) {
        srEEs = new ArrayList<>();
    }
    List<Long> eeIds = new ArrayList<>();
    for (SearchResult sr : srEEs) {
        eeIds.add(sr.getId());
    }
    Collection<ExpressionExperimentValueObject> eevos = expressionExperimentService.loadValueObjects(eeIds, true);
    List<SearchResultDisplayObject> experiments = new ArrayList<>();
    for (ExpressionExperimentValueObject eevo : eevos) {
        experiments.add(new SearchResultDisplayObject(eevo));
    }
    return experiments;
}
Also used : ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) SearchResult(ubic.gemma.core.search.SearchResult) SearchResultDisplayObject(ubic.gemma.core.search.SearchResultDisplayObject)

Example 18 with ExpressionExperimentValueObject

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

the class GeneralSearchControllerImpl method filterEE.

private Collection<ExpressionExperimentValueObject> filterEE(final Collection<ExpressionExperimentValueObject> toFilter, SearchSettings settings) {
    Taxon tax = settings.getTaxon();
    if (tax == null)
        return toFilter;
    Collection<ExpressionExperimentValueObject> filtered = new HashSet<>();
    for (ExpressionExperimentValueObject eevo : toFilter) {
        if (eevo.getTaxon().equalsIgnoreCase(tax.getCommonName()))
            filtered.add(eevo);
    }
    return filtered;
}
Also used : ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) Taxon(ubic.gemma.model.genome.Taxon)

Example 19 with ExpressionExperimentValueObject

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

the class CuratableValueObjectTest method testCuratableValueObjectCreation.

@Test
public void testCuratableValueObjectCreation() {
    ArrayDesignValueObject adVO = this.arrayDesignService.loadValueObject(arrayDesign);
    assertNotNull(adVO);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    ExpressionExperimentValueObject eeVO = this.expressionExperimentService.loadValueObject(expressionExperiment);
    assertNotNull(eeVO);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    ExpressionExperimentDetailsValueObject eeDVO = new ExpressionExperimentDetailsValueObject(eeVO);
    eeDVO.setArrayDesigns(Collections.singleton(adVO));
    assertNotNull(eeDVO);
    assertNotNull(eeDVO.getArrayDesigns());
}
Also used : ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) ExpressionExperimentDetailsValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentDetailsValueObject) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Example 20 with ExpressionExperimentValueObject

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

the class SearchResultDisplayObject method setValues.

/**
 * this method does not set the publik variable for the returned object (cannot autowire security service from here)
 *
 * @param searchResult search result
 */
private void setValues(SearchResult searchResult) {
    // if it's a search result, grab the underlying object
    Class<?> searchResultClass = searchResult.getResultClass();
    // class-specific construction
    if (searchResult.getResultObject() instanceof GeneValueObject) {
        GeneValueObject gene = (GeneValueObject) searchResult.getResultObject();
        this.setValues(gene);
    } else if (searchResult.getResultObject() instanceof Gene) {
        Gene gene = (Gene) searchResult.getResultObject();
        this.setValues(gene);
    } else if (searchResult.getResultObject() instanceof GeneSetValueObject) {
        GeneSetValueObject geneSet = (GeneSetValueObject) searchResult.getResultObject();
        this.setValues(geneSet);
    } else if (searchResult.getResultObject() instanceof ExpressionExperimentValueObject) {
        ExpressionExperimentValueObject ee = (ExpressionExperimentValueObject) searchResult.getResultObject();
        this.setValues(ee);
    } else if (searchResult.getResultObject() instanceof ExpressionExperimentSetValueObject) {
        ExpressionExperimentSetValueObject eeSet = (ExpressionExperimentSetValueObject) searchResult.getResultObject();
        this.setValues(eeSet);
    } else {
        this.isGroup = false;
        this.size = -1;
        this.taxonId = (long) -1;
        this.taxonName = "unknown";
        this.name = "Unhandled type";
        this.description = "Unhandled result type: " + searchResultClass;
        this.memberIds = null;
    }
}
Also used : ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) Gene(ubic.gemma.model.genome.Gene) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject) GeneSetValueObject(ubic.gemma.model.genome.gene.GeneSetValueObject)

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