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 <- "GSE8441_expmat_8probes.txt"
* expDesignFile <- "606_GSE8441_expdesign.data.txt"
* expMat <- log2(read.table(expMatFile, header = TRUE, row.names = 1, sep = "\t", quote=""))
* expDesign <- read.table(expDesignFile, header = TRUE, row.names = 1, sep = "\t", quote="")
*
* expData <- expMat[rownames(expDesign)]
*
* names(expData) == row.names(expDesign)
* attach(expDesign)
* lf<-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);
}
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 );
}
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;
}
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);
}
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);
}
Aggregations