Search in sources :

Example 86 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class GeneServiceImpl method loadValueObjectById.

@Override
@Transactional(readOnly = true)
public GeneValueObject loadValueObjectById(Long id) {
    Gene g = this.geneDao.load(id);
    if (g == null)
        return null;
    g = this.geneDao.thaw(g);
    return GeneValueObject.convert2ValueObject(g);
}
Also used : Gene(ubic.gemma.model.genome.Gene) Transactional(org.springframework.transaction.annotation.Transactional)

Example 87 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class GeneSetServiceImpl method findGeneSetsByGene.

@Override
@Transactional(readOnly = true)
public Collection<GeneSetValueObject> findGeneSetsByGene(Long geneId) {
    Gene gene = geneService.load(geneId);
    Collection<GeneSet> genesets = geneSetSearch.findByGene(gene);
    Collection<GeneSetValueObject> gsvos = new ArrayList<>();
    // noinspection CollectionAddAllCanBeReplacedWithConstructor // not possible safely
    gsvos.addAll(geneSetValueObjectHelper.convertToValueObjects(genesets, false));
    return gsvos;
}
Also used : Gene(ubic.gemma.model.genome.Gene) ArrayList(java.util.ArrayList) SessionBoundGeneSetValueObject(ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject) Transactional(org.springframework.transaction.annotation.Transactional)

Example 88 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class GeneCoreServiceImpl method searchGenes.

/**
 * Search for genes (by name or symbol)
 *
 * @param taxonId, can be null to not constrain by taxon
 * @return Collection of Gene entity objects
 */
@Override
public Collection<GeneValueObject> searchGenes(String query, Long taxonId) {
    Taxon taxon = null;
    if (taxonId != null) {
        taxon = this.taxonService.load(taxonId);
    }
    SearchSettings settings = SearchSettingsImpl.geneSearch(query, taxon);
    List<SearchResult> geneSearchResults = this.searchService.search(settings).get(Gene.class);
    Collection<Gene> genes = new HashSet<>();
    if (geneSearchResults == null || geneSearchResults.isEmpty()) {
        GeneCoreServiceImpl.log.info("No Genes for search: " + query + " taxon=" + taxonId);
        return new HashSet<>();
    }
    GeneCoreServiceImpl.log.info("Gene search: " + query + " taxon=" + taxonId + ", " + geneSearchResults.size() + " found");
    for (SearchResult sr : geneSearchResults) {
        Gene g = (Gene) sr.getResultObject();
        g = geneService.thaw(g);
        genes.add(g);
        GeneCoreServiceImpl.log.debug("Gene search result: " + g.getOfficialSymbol());
    }
    Collection<GeneValueObject> geneValueObjects = geneService.loadValueObjects(genes);
    GeneCoreServiceImpl.log.debug("Gene search: " + geneValueObjects.size() + " value objects returned.");
    return geneValueObjects;
}
Also used : GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) Gene(ubic.gemma.model.genome.Gene) Taxon(ubic.gemma.model.genome.Taxon) SearchSettings(ubic.gemma.model.common.search.SearchSettings) SearchResult(ubic.gemma.core.search.SearchResult) HashSet(java.util.HashSet)

Example 89 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class DEDVController method getDEDVForDiffExVisualization.

/**
 * AJAX exposed method - for ProbeLevelDiffExGrid, VisualizationDifferentialWindow,
 * DifferentialExpressionAnalysesSummaryTree
 *
 * @param eeIds     FIXME accommodate ExpressionExperimentSubSets. Currently we pass in the "source experiment" so we
 *                  don't get the slice.
 * @param geneIds   (could be just one)
 * @param threshold for 'significance'
 * @param factorMap Collection of DiffExpressionSelectedFactorCommand showing which factors to use.
 */
public VisualizationValueObject[] getDEDVForDiffExVisualization(Collection<Long> eeIds, Collection<Long> geneIds, Double threshold, Collection<DiffExpressionSelectedFactorCommand> factorMap) {
    if (eeIds.isEmpty() || geneIds.isEmpty())
        return null;
    StopWatch watch = new StopWatch();
    watch.start();
    Collection<? extends BioAssaySet> ees = expressionExperimentService.load(eeIds);
    if (ees == null || ees.isEmpty())
        return null;
    Collection<Gene> genes = geneService.load(geneIds);
    if (genes == null || genes.isEmpty())
        return null;
    Collection<DoubleVectorValueObject> dedvs = processedExpressionDataVectorService.getProcessedDataArrays(ees, geneIds);
    watch.stop();
    Long time = watch.getTime();
    log.info("Retrieved " + dedvs.size() + " DEDVs for " + eeIds.size() + " EEs and " + geneIds.size() + " genes in " + time + " ms.");
    watch = new StopWatch();
    watch.start();
    Map<Long, LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>>> layouts;
    layouts = experimentalDesignVisualizationService.sortVectorDataByDesign(dedvs);
    time = watch.getTime();
    if (time > 100) {
        log.info("Ran sortVectorDataByDesign on " + dedvs.size() + " DEDVs for 1 EE" + " in " + time + " ms (times <100ms not reported).");
    }
    // layouts = experimentalDesignVisualizationService.sortLayoutSamplesByFactor( layouts ); // required? yes, see
    // GSE11859
    time = watch.getTime();
    if (time > 100) {
        log.info("Ran sortLayoutSamplesByFactor on " + layouts.size() + " layouts" + " in " + time + " ms (times <100ms not reported).");
    }
    watch = new StopWatch();
    watch.start();
    Map<Long, Collection<DifferentialExpressionValueObject>> validatedProbes = getProbeDiffExValidation(genes, threshold, factorMap);
    watch.stop();
    time = watch.getTime();
    log.info("Retrieved " + validatedProbes.size() + " valid probes in " + time + " ms.");
    return makeDiffVisCollection(dedvs, new ArrayList<>(geneIds), validatedProbes, layouts);
}
Also used : StopWatch(org.apache.commons.lang3.time.StopWatch) Gene(ubic.gemma.model.genome.Gene) DoubleVectorValueObject(ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject)

Example 90 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class DEDVController method getProbeDiffExValidation.

/**
 * This is probably no longer being really used?
 */
private Map<Long, Collection<DifferentialExpressionValueObject>> getProbeDiffExValidation(Collection<Gene> genes, Double threshold, Collection<DiffExpressionSelectedFactorCommand> factorMap) {
    if (factorMap == null)
        throw new IllegalArgumentException("Factor information is missing, please make sure factors are selected.");
    Map<Long, Collection<DifferentialExpressionValueObject>> validatedProbes = new HashMap<>();
    Collection<Long> wantedFactors = new HashSet<>();
    for (DiffExpressionSelectedFactorCommand factor : factorMap) {
        wantedFactors.add(factor.getEfId());
    }
    for (Gene gene : genes) {
        Collection<DifferentialExpressionValueObject> differentialExpression = geneDifferentialExpressionService.getDifferentialExpression(gene, threshold, factorMap);
        for (DifferentialExpressionValueObject diffVo : differentialExpression) {
            assert diffVo.getCorrP() <= threshold;
            Long eeId = diffVo.getExpressionExperiment().getId();
            if (!validatedProbes.containsKey(eeId)) {
                validatedProbes.put(eeId, new HashSet<DifferentialExpressionValueObject>());
            }
            Collection<ExperimentalFactorValueObject> factors = diffVo.getExperimentalFactors();
            for (ExperimentalFactorValueObject fac : factors) {
                if (wantedFactors.contains(fac.getId())) {
                    validatedProbes.get(eeId).add(diffVo);
                }
            }
        }
    }
    return validatedProbes;
}
Also used : DifferentialExpressionValueObject(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionValueObject) DiffExpressionSelectedFactorCommand(ubic.gemma.core.analysis.expression.diff.DiffExpressionSelectedFactorCommand) Gene(ubic.gemma.model.genome.Gene)

Aggregations

Gene (ubic.gemma.model.genome.Gene)186 Taxon (ubic.gemma.model.genome.Taxon)34 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)32 StopWatch (org.apache.commons.lang3.time.StopWatch)31 Test (org.junit.Test)24 HashSet (java.util.HashSet)23 GeneProduct (ubic.gemma.model.genome.gene.GeneProduct)20 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)18 Element (org.w3c.dom.Element)16 ArrayList (java.util.ArrayList)13 Transactional (org.springframework.transaction.annotation.Transactional)12 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)12 Collection (java.util.Collection)11 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)11 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)10 HashMap (java.util.HashMap)8 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)8 BioSequence2GeneProduct (ubic.gemma.model.association.BioSequence2GeneProduct)7 PhysicalLocation (ubic.gemma.model.genome.PhysicalLocation)7 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)7