use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class CharacteristicBrowserController method populateParentInformation.
private void populateParentInformation(AnnotationValueObject avo, Object parent) {
if (parent == null) {
avo.setParentLink("[Parent hidden or not available, " + avo.getObjectClass() + " ID=" + avo.getId() + "]");
} else if (parent instanceof ExpressionExperiment) {
ExpressionExperiment ee = (ExpressionExperiment) parent;
avo.setParentName(String.format("Experiment: %s", ee.getName()));
avo.setParentLink(AnchorTagUtil.getExpressionExperimentLink(ee.getId(), avo.getParentName()));
} else if (parent instanceof BioMaterial) {
BioMaterial bm = (BioMaterial) parent;
avo.setParentName(String.format("BioMat: %s", bm.getName()));
avo.setParentLink(AnchorTagUtil.getBioMaterialLink(bm.getId(), avo.getParentName()));
ExpressionExperiment ee = expressionExperimentService.findByBioMaterial(bm);
if (ee != null) {
avo.setParentOfParentName(String.format("%s", ee.getName()));
// avo.setParentOfParentDescription( ee.getDescription() );
avo.setParentOfParentLink(AnchorTagUtil.getExpressionExperimentLink(ee.getId(), avo.getParentOfParentName()));
} else {
log.warn("Expression experiment for " + bm + " was null");
}
} else if (parent instanceof FactorValue) {
FactorValue fv = (FactorValue) parent;
avo.setParentDescription(String.format("FactorValue: %s « Exp.Factor: %s", (fv.getValue() == null ? "" : ": " + fv.getValue()), fv.getExperimentalFactor().getName()));
ExpressionExperiment ee = experimentalDesignService.getExpressionExperiment(fv.getExperimentalFactor().getExperimentalDesign());
avo.setParentOfParentName(String.format("Experimental Design for: %s", ee.getName()));
avo.setParentOfParentLink(AnchorTagUtil.getExperimentalDesignLink(fv.getExperimentalFactor().getExperimentalDesign().getId(), avo.getParentName()) + " « " + AnchorTagUtil.getExpressionExperimentLink(ee.getId(), String.format("%s (%s)", StringUtils.abbreviate(ee.getName(), 80), ee.getShortName())));
} else if (parent instanceof ExperimentalFactor) {
ExperimentalFactor ef = (ExperimentalFactor) parent;
avo.setParentLink(AnchorTagUtil.getExperimentalDesignLink(ef.getExperimentalDesign().getId(), "Exp Fac: " + ef.getName() + " (" + StringUtils.abbreviate(ef.getDescription(), 50) + ")"));
ExpressionExperiment ee = experimentalDesignService.getExpressionExperiment(ef.getExperimentalDesign());
avo.setParentOfParentName(String.format("%s (%s)", StringUtils.abbreviate(ee.getName(), 80), ee.getShortName()));
avo.setParentOfParentLink(AnchorTagUtil.getExpressionExperimentLink(ee.getId(), avo.getParentOfParentName()));
} else if (parent instanceof PhenotypeAssociation) {
PhenotypeAssociation pa = (PhenotypeAssociation) parent;
avo.setParentLink("PhenotypeAssoc: " + pa.getGene().getOfficialSymbol());
avo.setParentDescription(pa.getId().toString());
}
}
use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalysisTaskImpl method doAnalysis.
private Collection<DifferentialExpressionAnalysis> doAnalysis() {
ExpressionExperiment ee = taskCommand.getExpressionExperiment();
if (taskCommand.getToRedo() != null) {
log.info("Redoing analysis");
ee = expressionExperimentService.thawLite(ee);
return differentialExpressionAnalyzerService.redoAnalysis(ee, taskCommand.getToRedo(), true);
}
ee = expressionExperimentService.thawLite(ee);
Collection<DifferentialExpressionAnalysis> diffAnalyses = differentialExpressionAnalysisService.getAnalyses(ee);
if (!diffAnalyses.isEmpty()) {
log.info("This experiment has some existing analyses; if they overlap with the new analysis they will be deleted after the run.");
}
Collection<DifferentialExpressionAnalysis> results;
Collection<ExperimentalFactor> factors = taskCommand.getFactors();
DifferentialExpressionAnalysisConfig config = new DifferentialExpressionAnalysisConfig();
boolean rnaSeq = expressionExperimentService.isRNASeq(ee);
config.setUseWeights(rnaSeq);
config.setFactorsToInclude(factors);
config.setSubsetFactor(taskCommand.getSubsetFactor());
if (taskCommand.isIncludeInteractions() && factors.size() == 2) {
/*
* We should not include 'batch' in an interaction. But I don't want to enforce that here.
*/
for (ExperimentalFactor ef : factors) {
if (BatchInfoPopulationServiceImpl.isBatchFactor(ef)) {
log.warn("Batch is included in the interaction!");
}
}
// might get dropped.
config.addInteractionToInclude(factors);
}
DifferentialExpressionAnalyzerServiceImpl.AnalysisType analyzer = analysisSelectionAndExecutionService.determineAnalysis(ee, config);
if (analyzer == null) {
throw new IllegalStateException("Data set cannot be analyzed");
}
config.setAnalysisType(analyzer);
results = differentialExpressionAnalyzerService.runDifferentialExpressionAnalyses(ee, config);
return results;
}
use of ubic.gemma.model.expression.experiment.ExperimentalFactor in project Gemma by PavlidisLab.
the class ExpressionExperimentQCController method getCategories.
/**
* Support method for writeDetailedFactorAnalysis
*
* @param categories map of factor ID to text value. Strings will be unique, but possibly abbreviated and/or munged.
*/
private void getCategories(Map<Long, ExperimentalFactor> efIdMap, Long efId, Map<Long, String> categories) {
ExperimentalFactor ef = efIdMap.get(efId);
if (ef == null)
return;
int maxCategoryLabelLength = 10;
for (FactorValue fv : ef.getFactorValues()) {
String value = fv.getValue();
if (StringUtils.isBlank(value) || value.equals("null")) {
for (Characteristic c : fv.getCharacteristics()) {
if (StringUtils.isNotBlank(c.getValue())) {
if (StringUtils.isNotBlank(value)) {
value = value + "; " + c.getValue();
} else {
value = c.getValue();
}
}
}
}
if (StringUtils.isBlank(value)) {
value = fv.toString() + "--??";
}
if (value.startsWith(ExperimentalDesignUtils.BATCH_FACTOR_NAME_PREFIX)) {
value = value.replaceFirst(ExperimentalDesignUtils.BATCH_FACTOR_NAME_PREFIX, "");
} else {
value = StringUtils.abbreviate(value, maxCategoryLabelLength);
}
while (categories.values().contains(value)) {
// make unique, kludge, will end up with string of ++++
value = value + "+";
}
categories.put(fv.getId(), value);
}
}
Aggregations