Search in sources :

Example 51 with ExperimentalFactor

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

the class ExperimentalDesignImporterTestB method testParseLoadDelete.

@Test
public final void testParseLoadDelete() throws Exception {
    try (InputStream is = this.getClass().getResourceAsStream("/data/loader/expression/gill2007temperatureGemmaAnnotationData.txt")) {
        experimentalDesignImporter.importDesign(ee, is);
    }
    this.checkResults();
    this.aclTestUtils.checkEEAcls(ee);
    ee = this.expressionExperimentService.load(ee.getId());
    ee = expressionExperimentService.thawLite(ee);
    int s = ee.getExperimentalDesign().getExperimentalFactors().size();
    ExperimentalFactor toDelete = ee.getExperimentalDesign().getExperimentalFactors().iterator().next();
    experimentalFactorService.delete(toDelete);
    ee = this.expressionExperimentService.load(ee.getId());
    ee = expressionExperimentService.thawLite(ee);
    assertEquals(s - 1, ee.getExperimentalDesign().getExperimentalFactors().size());
    for (BioAssay ba : ee.getBioAssays()) {
        BioMaterial bm = ba.getSampleUsed();
        for (FactorValue fv : bm.getFactorValues()) {
            assertTrue(!fv.getExperimentalFactor().equals(toDelete));
        }
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) InputStream(java.io.InputStream) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 52 with ExperimentalFactor

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

the class DiffExMetaAnalyzerServiceImpl method validate.

private void validate(ExpressionAnalysisResultSet rs) {
    if (rs.getExperimentalFactors().size() > 1) {
        throw new IllegalArgumentException("Cannot do a meta-analysis on interaction terms");
    }
    ExperimentalFactor factor = rs.getExperimentalFactors().iterator().next();
    /*
         * We need to check this just in the subset of samples actually used.
         */
    BioAssaySet experimentAnalyzed = rs.getAnalysis().getExperimentAnalyzed();
    assert experimentAnalyzed != null;
    if (experimentAnalyzed instanceof ExpressionExperimentSubSet) {
        ExpressionExperimentSubSet eesubset = (ExpressionExperimentSubSet) experimentAnalyzed;
        Collection<FactorValue> factorValuesUsed = expressionExperimentSubSetService.getFactorValuesUsed(eesubset, factor);
        if (factorValuesUsed.size() > 2) {
            throw new IllegalArgumentException("Cannot do a meta-analysis including a factor that has more than two levels: " + factor + " has " + factor.getFactorValues().size() + " levels from " + experimentAnalyzed);
        }
    } else {
        if (factor.getFactorValues().size() > 2) {
            /*
                 * Note that this doesn't account for continuous factors.
                 */
            throw new IllegalArgumentException("Cannot do a meta-analysis including a factor that has more than two levels: " + factor + " has " + factor.getFactorValues().size() + " levels from " + experimentAnalyzed);
        }
    }
}
Also used : FactorValue(ubic.gemma.model.expression.experiment.FactorValue) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) ExpressionExperimentSubSet(ubic.gemma.model.expression.experiment.ExpressionExperimentSubSet)

Example 53 with ExperimentalFactor

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

the class DifferentialExpressionAnalysisConfig method toString.

@Override
public String toString() {
    StringBuilder buf = new StringBuilder();
    buf.append("# AnalysisType: ").append(this.analysisType).append("\n");
    buf.append("# Factors: ").append(StringUtils.join(this.factorsToInclude, " "));
    buf.append("\n");
    if (this.subsetFactor != null) {
        buf.append("# SubsetFactor: ").append(this.subsetFactor).append("\n");
    } else if (this.subsetFactorValue != null) {
        buf.append("# Subset analysis for ").append(this.subsetFactorValue);
    }
    if (!interactionsToInclude.isEmpty()) {
        buf.append("# Interactions:  ").append(StringUtils.join(interactionsToInclude, ":")).append("\n");
    }
    if (!baseLineFactorValues.isEmpty()) {
        buf.append("# Baselines:\n");
        for (ExperimentalFactor ef : baseLineFactorValues.keySet()) {
            buf.append("# ").append(ef.getName()).append(": Baseline = ").append(baseLineFactorValues.get(ef)).append("\n");
        }
    }
    if (this.ebayes) {
        buf.append("# Empirical Bayes moderated statistics used\n");
    }
    return buf.toString();
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor)

Example 54 with ExperimentalFactor

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

the class BioAssayDimensionValueObject method makeDummyBioAssayDimension.

private BioAssayDimension makeDummyBioAssayDimension() {
    assert this.id == null;
    BioAssayDimension fakeBd = BioAssayDimension.Factory.newInstance("Placeholder representing: " + name, description, new ArrayList<BioAssay>());
    Map<Long, ExperimentalFactor> fakeEfs = new HashMap<>();
    for (BioAssayValueObject bav : this.bioAssays) {
        BioAssay ba = BioAssay.Factory.newInstance();
        ba.setId(bav.getId());
        ba.setName(bav.getName());
        ba.setDescription("Fake placeholder");
        BioMaterial sampleUsed = BioMaterial.Factory.newInstance();
        BioMaterialValueObject bmVo = bav.getSample();
        assert bmVo != null;
        sampleUsed.setId(bmVo.getId());
        sampleUsed.setName(bmVo.getName());
        sampleUsed.setDescription("Fake placeholder");
        for (IdentifiableValueObject iVo : bmVo.getFactorValueObjects()) {
            FactorValueValueObject fvVo = (FactorValueValueObject) iVo;
            FactorValue fv = FactorValue.Factory.newInstance();
            assert fvVo.getId() != null;
            fv.setId(fvVo.getId());
            assert fvVo.getValue() != null;
            fv.setValue(fvVo.getValue());
            Long efId = fvVo.getFactorId();
            ExperimentalFactor ef;
            if (fakeEfs.containsKey(efId)) {
                ef = fakeEfs.get(efId);
            } else {
                ef = ExperimentalFactor.Factory.newInstance();
                ef.setId(efId);
                ef.setName(fvVo.getCategory());
                ef.setType(fvVo.isMeasurement() ? FactorType.CONTINUOUS : FactorType.CATEGORICAL);
                fakeEfs.put(efId, ef);
            }
            ef.getFactorValues().add(fv);
            fv.setExperimentalFactor(ef);
            sampleUsed.getFactorValues().add(fv);
        }
        ba.setSampleUsed(sampleUsed);
        ArrayDesign ad = ArrayDesign.Factory.newInstance();
        ArrayDesignValueObject adVo = bav.getArrayDesign();
        assert adVo != null;
        ad.setId(adVo.getId());
        ad.setShortName(adVo.getShortName());
        ad.setDescription("Fake placeholder");
        ba.setArrayDesignUsed(ad);
        fakeBd.getBioAssays().add(ba);
    }
    return fakeBd;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) IdentifiableValueObject(ubic.gemma.model.IdentifiableValueObject) BioMaterialValueObject(ubic.gemma.model.expression.biomaterial.BioMaterialValueObject) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 55 with ExperimentalFactor

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

the class ExpressionAnalysisResultSet method toString.

@Override
public String toString() {
    StringBuilder buf = new StringBuilder();
    for (DifferentialExpressionAnalysisResult dear : this.getResults()) {
        int count = 0;
        CompositeSequence cs = dear.getProbe();
        buf.append(cs.getName()).append("\t");
        for (BioSequence2GeneProduct bs2gp : cs.getBiologicalCharacteristic().getBioSequence2GeneProduct()) {
            Gene g = bs2gp.getGeneProduct().getGene();
            if (g != null) {
                buf.append(bs2gp.getGeneProduct().getGene().getOfficialSymbol()).append(",");
                count++;
            }
        }
        if (count != 0)
            // removing trailing ,
            buf.deleteCharAt(buf.lastIndexOf(","));
        buf.append("\t");
        count = 0;
        for (ExperimentalFactor ef : this.getExperimentalFactors()) {
            buf.append(ef.getName()).append(",");
            count++;
        }
        if (count != 0)
            // removing trailing ,
            buf.deleteCharAt(buf.lastIndexOf(","));
        buf.append("\t");
        buf.append(dear.getCorrectedPvalue()).append("\n");
    }
    return buf.toString();
}
Also used : Gene(ubic.gemma.model.genome.Gene) BioSequence2GeneProduct(ubic.gemma.model.association.BioSequence2GeneProduct) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Aggregations

ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)88 Test (org.junit.Test)31 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)30 DifferentialExpressionAnalysis (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)26 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)22 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)18 HashSet (java.util.HashSet)17 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)17 ExpressionAnalysisResultSet (ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet)16 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)14 DifferentialExpressionAnalysisResult (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult)12 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)11 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)10 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)10 Before (org.junit.Before)8 Collection (java.util.Collection)7 ContrastResult (ubic.gemma.model.analysis.expression.diff.ContrastResult)6 AnalysisType (ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType)5 ExperimentalFactorValueObject (ubic.gemma.model.expression.experiment.ExperimentalFactorValueObject)5 InputStream (java.io.InputStream)4