Search in sources :

Example 1 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.

the class SearchServiceImpl method filterCharacteristicOwnersByClass.

private Collection<SearchResult> filterCharacteristicOwnersByClass(Collection<Class<?>> classes, Map<Characteristic, Object> characteristic2entity) {
    Collection<BioMaterial> biomaterials = new HashSet<>();
    Collection<FactorValue> factorValues = new HashSet<>();
    Collection<SearchResult> results = new HashSet<>();
    for (Characteristic c : characteristic2entity.keySet()) {
        Object o = characteristic2entity.get(c);
        for (Class<?> clazz : classes) {
            if (clazz.isAssignableFrom(o.getClass())) {
                String matchedText = c.getValue();
                if (o instanceof BioMaterial) {
                    biomaterials.add((BioMaterial) o);
                } else if (o instanceof FactorValue) {
                    factorValues.add((FactorValue) o);
                } else {
                    if (c instanceof VocabCharacteristic && c.getValueUri() != null) {
                        matchedText = "Ontology term: <a href=\"" + Settings.getRootContext() + "/searcher.html?query=" + c.getValueUri() + "\">" + matchedText + "</a>";
                    }
                    results.add(new SearchResult(o, 1.0, matchedText));
                }
            }
        }
    }
    this.addEEeByFactorvalues(results, factorValues);
    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"));
        }
    }
    return results;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) SearchSettingsValueObject(ubic.gemma.model.common.search.SearchSettingsValueObject) BioSequenceValueObject(ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject) GeneEvidenceValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject) CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)

Example 2 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.

the class GoMetric method getOntologyTerms.

/**
 * @param gene gene
 * @return direct GO annotation terms
 */
private Collection<OntologyTerm> getOntologyTerms(Gene gene) {
    Collection<VocabCharacteristic> termsVoc = gene2GOAssociationService.findByGene(gene);
    HashSet<OntologyTerm> termsGO = new HashSet<>();
    for (VocabCharacteristic characteristic : termsVoc) {
        OntologyTerm term = GeneOntologyServiceImpl.getTermForId(characteristic.getValue());
        if ((term != null))
            termsGO.add(term);
    }
    return termsGO;
}
Also used : VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) OntologyTerm(ubic.basecode.ontology.model.OntologyTerm)

Example 3 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.

the class OntologyServiceImpl method gene2Characteristic.

/**
 * Allow us to store gene information as a characteristic associated with our entities. This doesn't work so well
 * for non-ncbi genes.
 */
private Characteristic gene2Characteristic(Gene g) {
    VocabCharacteristic vc = VocabCharacteristic.Factory.newInstance();
    vc.setCategory("gene");
    vc.setCategoryUri("http://purl.org/commons/hcls/gene");
    vc.setValue(g.getOfficialSymbol() + " [" + g.getTaxon().getCommonName() + "]" + " " + g.getOfficialName());
    vc.setDescription(g.toString());
    if (g.getNcbiGeneId() != null) {
        vc.setValueUri("http://purl.org/commons/record/ncbi_gene/" + g.getNcbiGeneId());
    }
    return vc;
}
Also used : VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

Example 4 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic 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 5 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.

the class ExperimentalDesignImporterTest method assertFv.

static void assertFv(FactorValue fv) {
    if (fv.getCharacteristics().size() > 0) {
        VocabCharacteristic c = (VocabCharacteristic) fv.getCharacteristics().iterator().next();
        assertNotNull(c.getValue());
        assertNotNull(c.getCategoryUri());
    } else {
        assertNotNull(fv.getValue() + " should have a measurement or a characteristic", fv.getMeasurement());
    }
}
Also used : VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

Aggregations

VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)44 Characteristic (ubic.gemma.model.common.description.Characteristic)15 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)10 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)7 Test (org.junit.Test)6 AnnotationValueObject (ubic.gemma.model.common.description.AnnotationValueObject)4 Gene (ubic.gemma.model.genome.Gene)4 HashSet (java.util.HashSet)3 Gene2GOAssociation (ubic.gemma.model.association.Gene2GOAssociation)3 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 ConcurrentHashSet (org.compass.core.util.concurrent.ConcurrentHashSet)2 OntologyIndividual (ubic.basecode.ontology.model.OntologyIndividual)2 OntologyResource (ubic.basecode.ontology.model.OntologyResource)2 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)2 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)2 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)2 AclObjectIdentity (gemma.gsec.acl.domain.AclObjectIdentity)1 InputStream (java.io.InputStream)1