Search in sources :

Example 16 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class TwoWayAnovaWithInteractionTest2 method test.

/*
     * NOTE I added a constant probe to this data after I set this up.
     *
     * <pre>
     * expMatFile &lt;- "GSE8441_expmat_8probes.txt"
     * expDesignFile &lt;- "606_GSE8441_expdesign.data.txt"
     * expMat &lt;- log2(read.table(expMatFile, header = TRUE, row.names = 1, sep = "\t", quote=""))
     * expDesign &lt;- read.table(expDesignFile, header = TRUE, row.names = 1, sep = "\t", quote="")
     *
     * expData &lt;- expMat[rownames(expDesign)]
     *
     * names(expData) == row.names(expDesign)
     * attach(expDesign)
     * lf&lt;-lm(unlist(expData["217757_at",])~Treatment*Sex )
     * summary(lf)
     * anova(lf)
     *
     * summary(lm(unlist(expData["202851_at",])~Treatment*Sex ))
     * anova(lm(unlist(expData["202851_at",])~Treatment*Sex ))
     *
     * # etc.
     * </pre>
     */
@Test
public void test() {
    AnalysisType aa = analysisService.determineAnalysis(ee, ee.getExperimentalDesign().getExperimentalFactors(), null, true);
    assertEquals(AnalysisType.TWO_WAY_ANOVA_WITH_INTERACTION, aa);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    assertEquals(2, factors.size());
    config.setAnalysisType(aa);
    config.setFactorsToInclude(factors);
    config.getInteractionsToInclude().add(factors);
    analyzer = this.getBean(DiffExAnalyzer.class);
    Collection<DifferentialExpressionAnalysis> result = analyzer.run(ee, config);
    assertEquals(1, result.size());
    DifferentialExpressionAnalysis analysis = result.iterator().next();
    this.checkResults(analysis);
    Collection<DifferentialExpressionAnalysis> persistent = differentialExpressionAnalyzerService.runDifferentialExpressionAnalyses(ee, config);
    DifferentialExpressionAnalysis refetched = differentialExpressionAnalysisService.load(persistent.iterator().next().getId());
    differentialExpressionAnalysisService.thaw(refetched);
    for (ExpressionAnalysisResultSet ears : refetched.getResultSets()) {
        differentialExpressionResultService.thaw(ears);
    }
    this.checkResults(refetched);
    differentialExpressionAnalyzerService.redoAnalysis(ee, refetched, true);
}
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) ExpressionAnalysisResultSet(ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 17 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class ContinuousVariableDiffExTest method test.

@Test
public void test() {
    AnalysisType aa = analysisService.determineAnalysis(ee, ee.getExperimentalDesign().getExperimentalFactors(), null, true);
    assertEquals(AnalysisType.GENERICLM, aa);
    DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
    Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors();
    assertEquals(1, factors.size());
    config.setAnalysisType(aa);
    config.setFactorsToInclude(factors);
    analyzer = this.getBean(DiffExAnalyzer.class);
    Collection<DifferentialExpressionAnalysis> result = analyzer.run(ee, config);
    assertEquals(1, result.size());
    DifferentialExpressionAnalysis analysis = result.iterator().next();
    assertNotNull(analysis);
    Map<ExperimentalFactor, FactorValue> baselineLevels = ExpressionDataMatrixColumnSort.getBaselineLevels(ee.getExperimentalDesign().getExperimentalFactors());
    assertEquals(1, baselineLevels.size());
    FactorValue fv = baselineLevels.values().iterator().next();
    assertEquals(24.0, Double.parseDouble(fv.getMeasurement().getValue()), 0.0001);
// checkResults( analysis );
}
Also used : AnalysisType(ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) 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 18 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class ExpressionDataFileServiceImpl method getDiffExpressionAnalysisArchiveFile.

@Override
public File getDiffExpressionAnalysisArchiveFile(Long analysisId, boolean forceCreate) {
    DifferentialExpressionAnalysis analysis = this.differentialExpressionAnalysisService.load(analysisId);
    String filename = this.getDiffExArchiveFileName(analysis);
    File f = this.getOutputFile(filename);
    // Force create if file is older than one year
    if (!forceCreate && f.canRead()) {
        Date d = new Date(f.lastModified());
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.YEAR, -1);
        forceCreate = d.before(new Date(calendar.getTimeInMillis()));
    }
    // If not force create and the file exists (can be read from), return the existing file.
    if (!forceCreate && f.canRead()) {
        ExpressionDataFileServiceImpl.log.info(f + " exists, not regenerating");
        return f;
    }
    // (Re-)create the file
    analysis = this.differentialExpressionAnalysisService.thawFully(analysis);
    BioAssaySet experimentAnalyzed = analysis.getExperimentAnalyzed();
    try {
        this.writeDiffExArchiveFile(experimentAnalyzed, analysis, null);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return f;
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)

Example 19 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class DifferentialExpressionAnalysisController method remove.

/**
 * AJAX entry point to remove an analysis given by the ID
 *
 * @param id id
 * @return string
 * @throws Exception exception
 */
public String remove(Long eeId, Long id) {
    ExpressionExperiment ee = expressionExperimentService.load(eeId);
    if (ee == null) {
        throw new IllegalArgumentException("Cannot access experiment with id=" + eeId);
    }
    DifferentialExpressionAnalysis toRemove = differentialExpressionAnalysisService.load(id);
    if (toRemove == null) {
        throw new IllegalArgumentException("Cannot access analysis with id=" + id);
    }
    DifferentialExpressionAnalysisRemoveTaskCommand cmd = new DifferentialExpressionAnalysisRemoveTaskCommand(ee, toRemove);
    this.experimentReportService.evictFromCache(ee.getId());
    return taskRunningService.submitRemoteTask(cmd);
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) DifferentialExpressionAnalysisRemoveTaskCommand(ubic.gemma.core.tasks.analysis.diffex.DifferentialExpressionAnalysisRemoveTaskCommand)

Example 20 with DifferentialExpressionAnalysis

use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.

the class ExpressionExperimentServiceImpl method remove.

@Override
@Transactional
public void remove(Long id) {
    final ExpressionExperiment ee = this.load(id);
    if (!securityService.isEditable(ee)) {
        throw new SecurityException("Error performing 'ExpressionExperimentService.remove(ExpressionExperiment expressionExperiment)' --> " + " You do not have permission to edit this experiment.");
    }
    // Remove subsets
    Collection<ExpressionExperimentSubSet> subsets = this.getSubSets(ee);
    for (ExpressionExperimentSubSet subset : subsets) {
        expressionExperimentSubSetService.remove(subset);
    }
    // Remove differential expression analyses
    Collection<DifferentialExpressionAnalysis> diffAnalyses = this.differentialExpressionAnalysisDao.findByInvestigation(ee);
    for (DifferentialExpressionAnalysis de : diffAnalyses) {
        this.differentialExpressionAnalysisDao.remove(de);
    }
    // remove any sample coexpression matrices
    this.sampleCoexpressionAnalysisDao.removeForExperiment(ee);
    // Remove PCA
    Collection<PrincipalComponentAnalysis> pcas = this.principalComponentAnalysisService.findByExperiment(ee);
    for (PrincipalComponentAnalysis pca : pcas) {
        this.principalComponentAnalysisService.remove(pca);
    }
    /*
         * Delete any expression experiment sets that only have this one ee in it. If possible remove this experiment
         * from other sets, and update them. IMPORTANT, this section assumes that we already checked for gene2gene
         * analyses!
         */
    Collection<ExpressionExperimentSet> sets = this.expressionExperimentSetService.find(ee);
    for (ExpressionExperimentSet eeSet : sets) {
        if (eeSet.getExperiments().size() == 1 && eeSet.getExperiments().iterator().next().equals(ee)) {
            AbstractService.log.info("Removing from set " + eeSet);
            this.expressionExperimentSetService.remove(// remove the set because in only contains this experiment
            eeSet);
        } else {
            AbstractService.log.info("Removing " + ee + " from " + eeSet);
            eeSet.getExperiments().remove(ee);
            // update set to not reference this experiment.
            this.expressionExperimentSetService.update(eeSet);
        }
    }
    this.expressionExperimentDao.remove(ee);
}
Also used : PrincipalComponentAnalysis(ubic.gemma.model.analysis.expression.pca.PrincipalComponentAnalysis) DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DifferentialExpressionAnalysis (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis)53 Test (org.junit.Test)26 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)26 ExpressionAnalysisResultSet (ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet)21 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)13 DifferentialExpressionAnalysisResult (ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult)11 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)8 HashSet (java.util.HashSet)5 ContrastResult (ubic.gemma.model.analysis.expression.diff.ContrastResult)5 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)5 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)5 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)5 AnalysisType (ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalyzerServiceImpl.AnalysisType)4 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Transactional (org.springframework.transaction.annotation.Transactional)3 DifferentialExpressionAnalysisConfig (ubic.gemma.core.analysis.expression.diff.DifferentialExpressionAnalysisConfig)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 DoubleMatrixReader (ubic.basecode.io.reader.DoubleMatrixReader)2 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)2