Search in sources :

Example 66 with ExperimentalFactor

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

the class DifferentialExpressionAnalyzerServiceTest method testAnalyzeAndDeleteSpecificAnalysisWithSubset.

/**
 * Tests running with a subset factor, then deleting.
 */
@Test
public void testAnalyzeAndDeleteSpecificAnalysisWithSubset() {
    ExperimentalFactor[] factors = ee.getExperimentalDesign().getExperimentalFactors().toArray(new ExperimentalFactor[] {});
    List<ExperimentalFactor> factorsToUse = Collections.singletonList(factors[0]);
    ExperimentalFactor subsetFactor = factors[1];
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    config.setFactorsToInclude(factorsToUse);
    config.setSubsetFactor(subsetFactor);
    Collection<DifferentialExpressionAnalysis> analyses = differentialExpressionAnalyzerService.runDifferentialExpressionAnalyses(ee, config);
    assertTrue(!analyses.isEmpty());
    differentialExpressionAnalyzerService.deleteAnalysis(ee, analyses.iterator().next());
}
Also used : ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 67 with ExperimentalFactor

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

the class DifferentialExpressionAnalyzerServiceTest method testWritePValuesHistogram.

@Test
public void testWritePValuesHistogram() {
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    config.setFactorsToInclude(factors);
    Collection<DifferentialExpressionAnalysis> analyses = differentialExpressionAnalyzerService.runDifferentialExpressionAnalyses(ee, config);
    for (DifferentialExpressionAnalysis analysis : analyses) {
        differentialExpressionAnalysisService.thaw(analysis);
        for (ExpressionAnalysisResultSet resultSet : analysis.getResultSets()) {
            Histogram hist = resultService.loadPvalueDistribution(resultSet.getId());
            assertNotNull(hist);
        }
    }
}
Also used : Histogram(ubic.basecode.math.distribution.Histogram) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 68 with ExperimentalFactor

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

the class SubsettedAnalysis2Test method test.

@Test
public void test() {
    ee = expressionExperimentService.thawLite(ee);
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    // includes batch
    assertEquals(4, factors.size());
    for (BioAssay ba : ee.getBioAssays()) {
        assertEquals(4, ba.getSampleUsed().getFactorValues().size());
    }
    ExperimentalFactor strainOrLine = null;
    ExperimentalFactor genotype = null;
    ExperimentalFactor phenotype = null;
    for (ExperimentalFactor ef : factors) {
        switch(ef.getCategory().getValue()) {
            case "genotype":
                genotype = ef;
                break;
            case "strain":
                strainOrLine = ef;
                break;
            case "phenotype":
                phenotype = ef;
                break;
        }
    }
    assertNotNull(strainOrLine);
    assertNotNull(phenotype);
    assertNotNull(genotype);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    config.getFactorsToInclude().add(genotype);
    config.getFactorsToInclude().add(phenotype);
    config.setSubsetFactor(strainOrLine);
    analyzer = this.getBean(DiffExAnalyzer.class);
    Collection<DifferentialExpressionAnalysis> result = analyzer.run(ee, config);
    // two subsets
    assertEquals(2, 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 69 with ExperimentalFactor

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

the class TwoWayAnovaWithInteractionsTest2 method test.

@Test
public void test() {
    ee = expressionExperimentService.thawLite(ee);
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    assertEquals(2, factors.size());
    for (BioAssay ba : ee.getBioAssays()) {
        assertEquals(2, ba.getSampleUsed().getFactorValues().size());
    }
    AnalysisType aa = analysisService.determineAnalysis(ee, ee.getExperimentalDesign().getExperimentalFactors(), null, true);
    assertEquals(AnalysisType.TWO_WAY_ANOVA_WITH_INTERACTION, aa);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    config.setAnalysisType(aa);
    config.setFactorsToInclude(factors);
    config.addInteractionToInclude(factors);
    analyzer = this.getBean(DiffExAnalyzer.class);
    Collection<DifferentialExpressionAnalysis> result = analyzer.run(ee, config);
    assertEquals(1, result.size());
    DifferentialExpressionAnalysis analysis = result.iterator().next();
    assertNotNull(analysis);
    assertEquals(3, analysis.getResultSets().size());
}
Also used : AnalysisType(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType) 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 70 with ExperimentalFactor

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

the class ContinuousVariableDiffExTest method setup.

@Before
public void setup() throws Exception {
    /*
         * this is an exon array data set that has the data present. It's an annoying choice for a test in that it
         * exposes issues with our attempts to ignore the data from exon arrays until we get it from the raw CEL files.
         */
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(FileTools.resourceToPath("/data/analysis/expression/gse13949short")));
    try {
        Collection<?> results = geoService.fetchAndLoad("GSE13949", 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/gse13949short/1151_GSE13949_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)

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