use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalyzerServiceImpl method persistAnalyses.
private Collection<DifferentialExpressionAnalysis> persistAnalyses(ExpressionExperiment expressionExperiment, Collection<DifferentialExpressionAnalysis> diffExpressionAnalyses, DifferentialExpressionAnalysisConfig config) {
Collection<DifferentialExpressionAnalysis> results = new HashSet<>();
for (DifferentialExpressionAnalysis analysis : diffExpressionAnalyses) {
DifferentialExpressionAnalysis persistentAnalysis = this.persistAnalysis(expressionExperiment, analysis, config);
results.add(persistentAnalysis);
}
return results;
}
use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalyzerServiceImpl method extendResultSets.
private void extendResultSets(Collection<DifferentialExpressionAnalysis> results, Collection<ExpressionAnalysisResultSet> toUpdateResultSets) {
for (DifferentialExpressionAnalysis a : results) {
boolean found = false;
for (ExpressionAnalysisResultSet oldrs : toUpdateResultSets) {
assert oldrs.getId() != null;
this.differentialExpressionResultService.thaw(oldrs);
for (ExpressionAnalysisResultSet temprs : a.getResultSets()) {
/*
* Compare the config
*/
if (this.configsAreEqual(temprs, oldrs)) {
found = true;
this.extendResultSet(oldrs, temprs);
break;
}
}
if (!found)
throw new IllegalStateException("Failed to find a matching existing result set for " + oldrs);
}
}
}
use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalyzerServiceImpl method deleteAnalyses.
@Override
public int deleteAnalyses(ExpressionExperiment expressionExperiment) {
Collection<DifferentialExpressionAnalysis> diffAnalysis = differentialExpressionAnalysisService.findByInvestigation(expressionExperiment);
int result = 0;
if (diffAnalysis == null || diffAnalysis.isEmpty()) {
DifferentialExpressionAnalyzerServiceImpl.log.debug("No differential expression analyses to remove for " + expressionExperiment.getShortName());
return result;
}
for (DifferentialExpressionAnalysis de : diffAnalysis) {
DifferentialExpressionAnalyzerServiceImpl.log.info("Deleting old differential expression analysis for experiment " + expressionExperiment.getShortName() + ": Analysis ID=" + de.getId());
differentialExpressionAnalysisService.remove(de);
this.deleteStatistics(expressionExperiment, de);
this.deleteAnalysisFiles(de);
result++;
}
return result;
}
use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalysisConfig method toAnalysis.
/**
* @return representation of this analysis with populated protocol holding information from this.
*/
public DifferentialExpressionAnalysis toAnalysis() {
DifferentialExpressionAnalysis analysis = DifferentialExpressionAnalysis.Factory.newInstance();
Protocol protocol = Protocol.Factory.newInstance();
protocol.setName("Differential expression analysis settings");
protocol.setDescription(this.toString());
analysis.setProtocol(protocol);
return analysis;
}
use of ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis in project Gemma by PavlidisLab.
the class DifferentialExpressionSearchController method getFactors.
/**
* AJAX entry.
* Value objects returned contain experiments that have 2 factors and have had the diff analysis run on it.
*/
public Collection<ExpressionExperimentExperimentalFactorValueObject> getFactors(final Collection<Long> eeIds) {
Collection<ExpressionExperimentExperimentalFactorValueObject> result = new HashSet<>();
final Collection<Long> securityFilteredIds = securityFilterExpressionExperimentIds(eeIds);
if (securityFilteredIds.size() == 0) {
return result;
}
log.debug("Getting factors for experiments with ids: " + StringUtils.abbreviate(securityFilteredIds.toString(), 100));
Collection<Long> filteredEeIds = new HashSet<>();
Map<Long, Collection<DifferentialExpressionAnalysis>> diffAnalyses = differentialExpressionAnalysisService.findByInvestigationIds(securityFilteredIds);
if (diffAnalyses.isEmpty()) {
log.debug("No differential expression analyses for given ids: " + StringUtils.join(filteredEeIds, ','));
return result;
}
Collection<ExpressionExperimentValueObject> eevos = this.expressionExperimentService.loadValueObjects(diffAnalyses.keySet(), false);
Map<Long, ExpressionExperimentValueObject> eevoMap = new HashMap<>();
for (ExpressionExperimentValueObject eevo : eevos) {
eevoMap.put(eevo.getId(), eevo);
}
for (Long id : diffAnalyses.keySet()) {
Collection<DifferentialExpressionAnalysis> analyses = diffAnalyses.get(id);
for (DifferentialExpressionAnalysis analysis : analyses) {
differentialExpressionAnalysisService.thaw(analysis);
Collection<ExperimentalFactor> factors = new HashSet<>();
for (FactorAssociatedAnalysisResultSet fars : analysis.getResultSets()) {
// FIXME includes factors making up interaction terms, but shouldn't
// matter, because they will be included as main effects too. If not, this will be wrong!
factors.addAll(fars.getExperimentalFactors());
}
filteredEeIds.add(id);
ExpressionExperimentValueObject eevo = eevoMap.get(id);
ExpressionExperimentExperimentalFactorValueObject eeefvo = new ExpressionExperimentExperimentalFactorValueObject();
eeefvo.setExpressionExperiment(eevo);
eeefvo.setNumFactors(factors.size());
for (ExperimentalFactor ef : factors) {
ExperimentalFactorValueObject efvo = geneDifferentialExpressionService.configExperimentalFactorValueObject(ef);
eeefvo.getExperimentalFactors().add(efvo);
}
result.add(eeefvo);
}
}
log.info("Filtered experiments. Returning factors for experiments with ids: " + StringUtils.abbreviate(filteredEeIds.toString(), 100));
return result;
}
Aggregations