Search in sources :

Example 16 with BioAssayValueObject

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();
}
Also used : BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject)

Example 17 with BioAssayValueObject

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);
            }
        }
    }
}
Also used : BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) BioMaterialValueObject(ubic.gemma.model.expression.biomaterial.BioMaterialValueObject) DoubleVectorValueObject(ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject)

Example 18 with BioAssayValueObject

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;
}
Also used : VisualizationValueObject(ubic.gemma.web.controller.visualization.VisualizationValueObject) StopWatch(org.apache.commons.lang3.time.StopWatch) GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) DoubleVectorValueObject(ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject)

Example 19 with BioAssayValueObject

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;
}
Also used : BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) OutlierDetails(ubic.gemma.core.analysis.preprocess.OutlierDetails) HashSet(java.util.HashSet)

Example 20 with BioAssayValueObject

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));
}
Also used : BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) ModelAndView(org.springframework.web.servlet.ModelAndView) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BioAssayValueObject (ubic.gemma.model.expression.bioAssay.BioAssayValueObject)20 DoubleVectorValueObject (ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject)7 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)6 BioMaterialValueObject (ubic.gemma.model.expression.biomaterial.BioMaterialValueObject)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 StopWatch (org.apache.commons.lang3.time.StopWatch)3 ArrayDesignValueObject (ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)3 BioAssayDimensionValueObject (ubic.gemma.model.expression.bioAssayData.BioAssayDimensionValueObject)3 HashSet (java.util.HashSet)2 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)2 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)2 VisualizationValueObject (ubic.gemma.web.controller.visualization.VisualizationValueObject)2 DoubleArrayList (cern.colt.list.DoubleArrayList)1 MapperException (com.sdicons.json.mapper.MapperException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 JspException (javax.servlet.jsp.JspException)1 Test (org.junit.Test)1