Search in sources :

Example 6 with ExperimentalFactor

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

the class DiffExWithInvalidInteraction2Test method test.

@Test
public void test() {
    ee = expressionExperimentService.thawLite(ee);
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    // includes batch
    assertEquals(3, factors.size());
    for (BioAssay ba : ee.getBioAssays()) {
        assertEquals(3, ba.getSampleUsed().getFactorValues().size());
    }
    ExperimentalFactor strain = null;
    ExperimentalFactor cell_type = null;
    for (ExperimentalFactor ef : factors) {
        if (ef.getCategory().getValue().equals("strain")) {
            strain = ef;
        } else if (ef.getCategory().getValue().equals("cell type")) {
            cell_type = ef;
        }
    }
    assertNotNull(cell_type);
    assertNotNull(strain);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    config.getFactorsToInclude().add(strain);
    config.getFactorsToInclude().add(cell_type);
    config.addInteractionToInclude(cell_type, strain);
    Collection<DifferentialExpressionAnalysis> result = analyzer.runDifferentialExpressionAnalyses(ee, config);
    assertEquals(1, result.size());
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 7 with ExperimentalFactor

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

the class DiffExWithInvalidInteraction2Test method setup.

@Before
public void setup() throws Exception {
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(FileTools.resourceToPath("/data/analysis/expression")));
    try {
        Collection<?> results = geoService.fetchAndLoad("GSE37301", false, true, false);
        ee = (ExpressionExperiment) results.iterator().next();
    } catch (AlreadyExistsInSystemException e) {
        ee = (ExpressionExperiment) ((Collection<?>) e.getData()).iterator().next();
    }
    ee = expressionExperimentService.thawLite(ee);
    Collection<ExperimentalFactor> toremove = new HashSet<>(ee.getExperimentalDesign().getExperimentalFactors());
    for (ExperimentalFactor ef : toremove) {
        experimentalFactorService.delete(ef);
        ee.getExperimentalDesign().getExperimentalFactors().remove(ef);
    }
    expressionExperimentService.update(ee);
    processedExpressionDataVectorService.computeProcessedExpressionData(ee);
    ee = expressionExperimentService.thaw(ee);
    designImporter.importDesign(ee, this.getClass().getResourceAsStream("/data/analysis/expression/7737_GSE37301_expdesign.data.txt"));
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) Collection(java.util.Collection) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 8 with ExperimentalFactor

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

the class OneWayAnovaAnalyzerTest method testOneWayAnova.

/**
 * Tests the OneWayAnova method.
 */
@Test
public void testOneWayAnova() throws Exception {
    if (!connected) {
        log.warn("Could not establish R connection.  Skipping test ...");
        return;
    }
    super.configureTestDataForOneWayAnova();
    this.configureMocks();
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    Collection<ExperimentalFactor> factors = expressionExperiment.getExperimentalDesign().getExperimentalFactors();
    config.setFactorsToInclude(factors);
    Collection<DifferentialExpressionAnalysis> expressionAnalyses = analyzer.run(expressionExperiment, config);
    DifferentialExpressionAnalysis expressionAnalysis = expressionAnalyses.iterator().next();
    Collection<ExpressionAnalysisResultSet> resultSets = expressionAnalysis.getResultSets();
    ExpressionAnalysisResultSet resultSet = resultSets.iterator().next();
    int numResults = resultSet.getResults().size();
    assertEquals(100, numResults);
/*
         * Check we got the histograms - only happens during persisting.
         */
// File dir = DifferentialExpressionFileUtils.getBaseDifferentialDirectory( expressionExperiment.getShortName()
// );
// 
// File histFile = new File( dir, expressionExperiment.getShortName() + ".pvalues"
// + DifferentialExpressionFileUtils.PVALUE_DIST_SUFFIX );
// assertTrue( histFile.exists() );
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet) Test(org.junit.Test)

Example 9 with ExperimentalFactor

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

the class OneWayAnovaAnalyzerTest method testOnewayAnovaB.

@Test
public void testOnewayAnovaB() throws Exception {
    if (!connected) {
        log.warn("Could not establish R connection.  Skipping test ...");
        return;
    }
    super.configureTestDataForOneWayAnova();
    this.configureMocks();
    /*
         * Add a factor with three levels
         */
    ExperimentalFactor experimentalFactorC = ExperimentalFactor.Factory.newInstance();
    experimentalFactorC.setName("groupash");
    experimentalFactorC.setId(5399424551L);
    experimentalFactorC.setType(FactorType.CATEGORICAL);
    expressionExperiment.getExperimentalDesign().getExperimentalFactors().add(experimentalFactorC);
    FactorValue controlGroup = null;
    for (int i = 1; i <= 3; i++) {
        FactorValue f = FactorValue.Factory.newInstance();
        f.setId(2000L + i);
        if (i != 2) {
            f.setValue(i + "_group");
        } else {
            f.setValue("control_group");
            controlGroup = f;
        }
        f.setExperimentalFactor(experimentalFactorC);
        experimentalFactorC.getFactorValues().add(f);
    }
    List<FactorValue> facV = new ArrayList<>(experimentalFactorC.getFactorValues());
    for (int i = 0; i < 8; i++) {
        super.biomaterials.get(i).getFactorValues().add(facV.get(i % 3));
    }
    Collection<ExperimentalFactor> factors = new HashSet<>();
    factors.add(experimentalFactorC);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    config.setFactorsToInclude(factors);
    Collection<DifferentialExpressionAnalysis> expressionAnalyses = analyzer.run(expressionExperiment, config);
    DifferentialExpressionAnalysis expressionAnalysis = expressionAnalyses.iterator().next();
    Collection<ExpressionAnalysisResultSet> resultSets = expressionAnalysis.getResultSets();
    ExpressionAnalysisResultSet resultSet = resultSets.iterator().next();
    int numResults = resultSet.getResults().size();
    assertEquals(100, numResults);
    assertEquals(controlGroup, resultSet.getBaselineGroup());
    factors = resultSet.getExperimentalFactors();
    assertEquals(1, factors.size());
    for (DifferentialExpressionAnalysisResult r : resultSet.getResults()) {
        CompositeSequence probe = r.getProbe();
        Double pvalue = r.getPvalue();
        // if ( pvalue != null ) assertNotNull( stat );
        assertNotNull(probe);
        switch(probe.getName()) {
            case "probe_98":
                assertEquals(0.1604, pvalue, 0.001);
                break;
            case "probe_10":
                assertEquals(0.8014, pvalue, 0.0001);
                break;
            case "probe_4":
                assertEquals(0.6531, pvalue, 0.0001);
                break;
        }
    }
}
Also used : FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) ArrayList(java.util.ArrayList) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) DifferentialExpressionAnalysisResult(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with ExperimentalFactor

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

the class AuditAdviceTest method checkEEAuditTrails.

private void checkEEAuditTrails(ExpressionExperiment ee, Collection<Long> trailIds, Collection<Long> eventIds) {
    this.checkAuditTrail(ee, trailIds, eventIds);
    for (BioAssay ba : ee.getBioAssays()) {
        this.checkAuditTrail(ba, trailIds, eventIds);
        BioMaterial bm = ba.getSampleUsed();
        this.checkAuditTrail(bm, trailIds, eventIds);
        for (Characteristic c : bm.getCharacteristics()) {
            this.checkAuditTrail(c, trailIds, eventIds);
        }
        for (Treatment t : bm.getTreatments()) {
            this.checkAuditTrail(t, trailIds, eventIds);
            this.checkAuditTrail(t.getAction(), trailIds, eventIds);
        // for ( CompoundMeasurement cm : t.getCompoundMeasurements() ) {
        // checkAuditTrail( cm.getCompound().getCompoundIndices(), trailIds, eventIds );
        // }
        }
    }
    Collection<ExperimentalFactor> experimentalFactors = ee.getExperimentalDesign().getExperimentalFactors();
    assertTrue(experimentalFactors.size() > 0);
    for (ExperimentalFactor ef : experimentalFactors) {
        this.checkAuditTrail(ef, trailIds, eventIds);
        for (FactorValue fv : ef.getFactorValues()) {
            for (Characteristic c : fv.getCharacteristics()) {
                this.checkAuditTrail(c, trailIds, eventIds);
            }
        }
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) Treatment(ubic.gemma.model.expression.biomaterial.Treatment) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) Characteristic(ubic.gemma.model.common.description.Characteristic) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

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