use of ubic.gemma.model.expression.bioAssay.BioAssayValueObject in project Gemma by PavlidisLab.
the class DEDVController method makeHeader.
/**
* @param dedv exemplar to use for forming the heading
*/
private String makeHeader(DoubleVectorValueObject dedv) {
String firstThreeColumnHeadings = "GeneSymbol\tGeneName\tElement";
StringBuilder buf = new StringBuilder();
ExpressionExperimentValueObject ee = dedv.getExpressionExperiment();
buf.append("# ").append(ee.getShortName()).append(" : ").append(ee.getName()).append("\n");
buf.append(firstThreeColumnHeadings);
for (BioAssayValueObject ba : dedv.getBioAssays()) {
buf.append("\t").append(ba.getName());
}
buf.append("\n");
return buf.toString();
}
use of ubic.gemma.model.expression.bioAssay.BioAssayValueObject in project Gemma by PavlidisLab.
the class DEDVController method getSampleNames.
/**
* Get the names we'll use for the columns of the vectors.
*/
private void getSampleNames(Collection<DoubleVectorValueObject> vectors, VisualizationValueObject vvo, Map<Long, LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>>> layouts) {
for (DoubleVectorValueObject vec : vectors) {
List<String> sampleNames = new ArrayList<>();
if (layouts != null && layouts.get(vec.getExpressionExperiment().getId()) != null) {
// if same sample was run more than
Collection<BioMaterialValueObject> seenSamples = new HashSet<>();
for (BioAssayValueObject ba : layouts.get(vec.getExpressionExperiment().getId()).keySet()) {
if (seenSamples.contains(ba.getSample())) {
continue;
}
seenSamples.add(ba.getSample());
sampleNames.add(ba.getName());
}
if (sampleNames.size() > 0) {
assert sampleNames.size() == vec.getData().length;
log.debug(sampleNames.size() + " sample names!");
vvo.setSampleNames(sampleNames);
}
} else {
sampleNames = getSampleNames(vec);
if (sampleNames.size() > 0) {
log.debug(sampleNames.size() + " sample names!");
vvo.setSampleNames(sampleNames);
}
}
}
}
use of ubic.gemma.model.expression.bioAssay.BioAssayValueObject in project Gemma by PavlidisLab.
the class DEDVController method makeVisCollection.
/**
* Takes the DEDVs and put them in point objects and normalize the values. returns a map of eeid to visValueObject.
* Currently removes multiple hits for same gene. Tries to pick best DEDV.
*/
private VisualizationValueObject[] makeVisCollection(Collection<DoubleVectorValueObject> dedvs, Collection<Long> genes, Map<Long, Collection<Long>> validatedProbes, Map<Long, LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>>> layouts) {
Map<Long, List<DoubleVectorValueObject>> vvoMap = new HashMap<>();
// Organize by expression experiment
if (dedvs == null || dedvs.isEmpty())
return new VisualizationValueObject[1];
for (DoubleVectorValueObject dvvo : dedvs) {
// FIXME: we can probably use this information, and do away with carrying so much Layout information around?
// assert dvvo.isReorganized() && dvvo.getBioAssayDimension().isReordered(); // not always true!!
ExpressionExperimentValueObject ee = dvvo.getExpressionExperiment();
if (!vvoMap.containsKey(ee.getId())) {
vvoMap.put(ee.getId(), new ArrayList<DoubleVectorValueObject>());
}
vvoMap.get(ee.getId()).add(dvvo);
}
List<GeneValueObject> geneValueObjects;
if (genes == null || genes.isEmpty()) {
geneValueObjects = new ArrayList<>(getGeneValueObjectsUsed(dedvs).values());
} else {
geneValueObjects = getGeneValueObjectList(new ArrayList<>(genes));
}
StopWatch timer = new StopWatch();
timer.start();
VisualizationValueObject[] result = new VisualizationValueObject[vvoMap.keySet().size()];
// Create collection of visualizationValueObject for flotr on js side
int i = 0;
for (Long ee : vvoMap.keySet()) {
Collection<Long> validatedProbeList = null;
if (validatedProbes != null) {
validatedProbeList = validatedProbes.get(ee);
}
Collection<DoubleVectorValueObject> vectors = vvoMap.get(ee);
VisualizationValueObject vvo = new VisualizationValueObject(vectors, geneValueObjects, validatedProbeList);
if (vectors.size() > 0) {
getSampleNames(vectors, vvo, layouts);
if (vectors.size() > 0 && layouts != null && !layouts.isEmpty() && layouts.containsKey(ee)) {
// Set up the experimental designinfo so we can show it above the graph.
LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>> layout = layouts.get(ee);
this.prepareFactorsForFrontEndDisplay(vvo, layout);
}
}
/*
* Set up the experimental design info so we can show it above the graph.
*/
if (layouts != null && layouts.get(ee) != null) {
vvo.setUpFactorProfiles(layouts.get(ee));
}
result[i] = vvo;
i++;
}
long time = timer.getTime();
if (time > 1000) {
log.info("Created vis value objects in: " + time);
}
return result;
}
use of ubic.gemma.model.expression.bioAssay.BioAssayValueObject in project Gemma by PavlidisLab.
the class BioAssayController method getBioAssays.
public Collection<BioAssayValueObject> getBioAssays(Long eeId) {
ExpressionExperiment ee = eeService.load(eeId);
if (ee == null) {
throw new IllegalArgumentException("Could not load experiment with ID=" + eeId);
}
ee = this.eeService.thawLite(ee);
Collection<BioAssayValueObject> result = new HashSet<>();
// this used to be in a separate method.
DoubleMatrix<BioAssay, BioAssay> sampleCorrelationMatrix = sampleCoexpressionMatrixService.findOrCreate(ee);
Collection<OutlierDetails> outliers = outlierDetectionService.identifyOutliersByMedianCorrelation(ee);
Map<Long, OutlierDetails> outlierMap = EntityUtils.getNestedIdMap(outliers, "bioAssay", "getId");
for (BioAssay assay : ee.getBioAssays()) {
BioAssayValueObject bioAssayValueObject = new BioAssayValueObject(assay, false);
if (outlierMap.containsKey(assay.getId())) {
bioAssayValueObject.setPredictedOutlier(true);
}
result.add(bioAssayValueObject);
}
BioAssayController.log.debug("Loaded " + result.size() + " bioassays for experiment ID=" + eeId);
return result;
}
use of ubic.gemma.model.expression.bioAssay.BioAssayValueObject in project Gemma by PavlidisLab.
the class BioAssayController method show.
@RequestMapping(value = { "/showBioAssay.html", "/" })
public ModelAndView show(HttpServletRequest request, HttpServletResponse response) {
BioAssayController.log.debug(request.getParameter("id"));
Long id;
try {
id = Long.parseLong(request.getParameter("id"));
} catch (NumberFormatException e) {
return new ModelAndView(WebConstants.HOME_PAGE).addObject("message", BioAssayController.identifierNotFound);
}
BioAssay bioAssay = bioAssayService.load(id);
if (bioAssay == null) {
throw new EntityNotFoundException(id + " not found");
}
bioAssayService.thaw(bioAssay);
request.setAttribute("id", id);
return new ModelAndView("bioAssay.detail").addObject("bioAssay", new BioAssayValueObject(bioAssay, false));
}
Aggregations