use of ubic.gemma.model.expression.experiment.ExperimentalFactorValueObject in project Gemma by PavlidisLab.
the class DifferentialExpressionSearchTaskImpl method addConditionsToSearchResultValueObject.
/**
* Get information on the conditions to be searched. This is not part of the query for the results themselves, but
* uses the database to get metadata/summaries about the analyses that will be used. Initializes the searchResult
* value object. Later, values which are non-missing will be replaced with either 'non-significant' or 'significant'
* results.
*
* @param searchResult to be initialized
* @return list of the resultSets that should be queried.
*/
private List<DiffExResultSetSummaryValueObject> addConditionsToSearchResultValueObject(DifferentialExpressionGenesConditionsValueObject searchResult) {
StopWatch watch = new StopWatch("addConditionsToSearchResultValueObject");
watch.start("Add conditions to search result value object");
List<DiffExResultSetSummaryValueObject> usedResultSets = new LinkedList<>();
int i = 0;
DifferentialExpressionSearchTaskImpl.log.info("Loading " + experimentGroupName + " experiments...");
// database hit: important that this be fast.
Map<ExpressionExperimentDetailsValueObject, Collection<DifferentialExpressionAnalysisValueObject>> analyses = differentialExpressionAnalysisService.getAnalysesByExperiment(EntityUtils.getIds(experimentGroup));
experiment: for (ExpressionExperimentDetailsValueObject bas : analyses.keySet()) {
Collection<DifferentialExpressionAnalysisValueObject> analysesForExperiment = this.filterAnalyses(analyses.get(bas));
if (analysesForExperiment.isEmpty()) {
continue;
}
/*
* There will often just be one analysis for the experiment. Exception would be when there is subsetting.
*/
for (DifferentialExpressionAnalysisValueObject analysis : analysesForExperiment) {
List<DiffExResultSetSummaryValueObject> resultSets = this.filterResultSets(analysis);
usedResultSets.addAll(resultSets);
if (resultSets.isEmpty()) {
DifferentialExpressionSearchTaskImpl.log.info("No resultSets usable for " + bas.getId());
}
for (DiffExResultSetSummaryValueObject resultSet : resultSets) {
// sanity check.
assert resultSet.getNumberOfDiffExpressedProbes() != null;
// interactions not okay
assert resultSet.getExperimentalFactors().size() == 1;
ExperimentalFactorValueObject factor = resultSet.getExperimentalFactors().iterator().next();
Collection<FactorValueValueObject> factorValues = this.filterFactorValues(analysis, factor.getValues(), resultSet.getBaselineGroup().getId());
if (factorValues.isEmpty()) {
/*
* This can only happen if there is just a baseline factorvalue. Even for one-sided tests //
* that // won't be the case.
*/
DifferentialExpressionSearchTaskImpl.log.warn("Nothing usable for resultSet=" + resultSet.getResultSetId());
continue;
}
for (FactorValueValueObject factorValue : factorValues) {
Condition condition = searchResult.new Condition(bas, analysis, resultSet, factorValue);
condition.setExperimentGroupName(experimentGroupName);
/*
* SANITY CHECKS these fields should be filled in. If not, we are going to skip the results.
*/
if (condition.getNumberDiffExpressedProbes() == -1) {
DifferentialExpressionSearchTaskImpl.log.warn(bas + ": Error: No hit list sizes for resultSet with ID=" + resultSet.getResultSetId());
continue;
}
if (condition.getNumberOfProbesOnArray() == null || condition.getNumberDiffExpressedProbes() == null) {
DifferentialExpressionSearchTaskImpl.log.error(bas + ": Error: Null counts for # diff ex probe or # probes on array, Skipping");
continue experiment;
} else if (condition.getNumberOfProbesOnArray() < condition.getNumberDiffExpressedProbes()) {
DifferentialExpressionSearchTaskImpl.log.error(bas + ": Error: More diff expressed probes than probes on array. Skipping.");
continue experiment;
}
searchResult.addCondition(condition);
i++;
}
}
}
}
watch.stop();
if (watch.getTotalTimeMillis() > 100) {
// This does not include getting the actual diff ex results.
DifferentialExpressionSearchTaskImpl.log.info("Get information on conditions/analyses for " + i + " factorValues: " + watch.getTotalTimeMillis() + "ms");
}
return usedResultSets;
}
use of ubic.gemma.model.expression.experiment.ExperimentalFactorValueObject in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalysisController method determineAnalysisType.
/**
* Ajax method. Pick the analysis type when we want it to be completely automated.
*
* @param id id
* @return analysis info
*/
public DifferentialExpressionAnalyzerInfo determineAnalysisType(Long id) {
ExpressionExperiment ee = expressionExperimentService.load(id);
if (ee == null) {
throw new IllegalArgumentException("Cannot access experiment with id=" + id);
}
ee = expressionExperimentService.thawLite(ee);
Collection<ExperimentalFactor> factorsWithoutBatch = ExperimentalDesignUtils.factorsWithoutBatch(ee.getExperimentalDesign().getExperimentalFactors());
AnalysisType analyzer = this.analysisSelectionAndExecutionService.determineAnalysis(ee, factorsWithoutBatch, null, true);
DifferentialExpressionAnalyzerInfo result = new DifferentialExpressionAnalyzerInfo();
// we include all factors here, so that batch can be used for subsetting (up to client)
for (ExperimentalFactor factor : ee.getExperimentalDesign().getExperimentalFactors()) {
result.getFactors().add(new ExperimentalFactorValueObject(factor));
}
if (analyzer == null) {
/*
* Either there are no viable automatic choices, or there are no usable factors...
*/
if (factorsWithoutBatch.size() < 2) {
throw new IllegalStateException("This data set does not seem suitable for analysis.");
}
result.setType(AnalysisType.GENERICLM.toString());
} else {
result.setType(analyzer.toString());
}
return result;
}
Aggregations