Search in sources :

Example 6 with BioMaterialValueObject

use of ubic.gemma.model.expression.biomaterial.BioMaterialValueObject in project Gemma by PavlidisLab.

the class BioAssayDimensionValueObject method makeDummyBioAssayDimension.

private BioAssayDimension makeDummyBioAssayDimension() {
    assert this.id == null;
    BioAssayDimension fakeBd = BioAssayDimension.Factory.newInstance("Placeholder representing: " + name, description, new ArrayList<BioAssay>());
    Map<Long, ExperimentalFactor> fakeEfs = new HashMap<>();
    for (BioAssayValueObject bav : this.bioAssays) {
        BioAssay ba = BioAssay.Factory.newInstance();
        ba.setId(bav.getId());
        ba.setName(bav.getName());
        ba.setDescription("Fake placeholder");
        BioMaterial sampleUsed = BioMaterial.Factory.newInstance();
        BioMaterialValueObject bmVo = bav.getSample();
        assert bmVo != null;
        sampleUsed.setId(bmVo.getId());
        sampleUsed.setName(bmVo.getName());
        sampleUsed.setDescription("Fake placeholder");
        for (IdentifiableValueObject iVo : bmVo.getFactorValueObjects()) {
            FactorValueValueObject fvVo = (FactorValueValueObject) iVo;
            FactorValue fv = FactorValue.Factory.newInstance();
            assert fvVo.getId() != null;
            fv.setId(fvVo.getId());
            assert fvVo.getValue() != null;
            fv.setValue(fvVo.getValue());
            Long efId = fvVo.getFactorId();
            ExperimentalFactor ef;
            if (fakeEfs.containsKey(efId)) {
                ef = fakeEfs.get(efId);
            } else {
                ef = ExperimentalFactor.Factory.newInstance();
                ef.setId(efId);
                ef.setName(fvVo.getCategory());
                ef.setType(fvVo.isMeasurement() ? FactorType.CONTINUOUS : FactorType.CATEGORICAL);
                fakeEfs.put(efId, ef);
            }
            ef.getFactorValues().add(fv);
            fv.setExperimentalFactor(ef);
            sampleUsed.getFactorValues().add(fv);
        }
        ba.setSampleUsed(sampleUsed);
        ArrayDesign ad = ArrayDesign.Factory.newInstance();
        ArrayDesignValueObject adVo = bav.getArrayDesign();
        assert adVo != null;
        ad.setId(adVo.getId());
        ad.setShortName(adVo.getShortName());
        ad.setDescription("Fake placeholder");
        ba.setArrayDesignUsed(ad);
        fakeBd.getBioAssays().add(ba);
    }
    return fakeBd;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) IdentifiableValueObject(ubic.gemma.model.IdentifiableValueObject) BioMaterialValueObject(ubic.gemma.model.expression.biomaterial.BioMaterialValueObject) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 7 with BioMaterialValueObject

use of ubic.gemma.model.expression.biomaterial.BioMaterialValueObject in project Gemma by PavlidisLab.

the class DoubleVectorValueObject method addGaps.

private void addGaps(BioAssayDimension dimToMatch) {
    BioAssayDimensionValueObject sourceBioAssayDimension = new BioAssayDimensionValueObject(dimToMatch);
    List<BioAssayValueObject> dimToMatchBioAssays = sourceBioAssayDimension.getBioAssays();
    double[] expandedData = new double[dimToMatch.getBioAssays().size()];
    BioAssayDimension expandedDim = BioAssayDimension.Factory.newInstance();
    expandedDim.setDescription("Expanded bioassay dimension based on " + this.getBioAssayDimension().getName());
    expandedDim.setName("Expanded bioassay dimension based on " + this.getBioAssayDimension().getName());
    Map<BioMaterialValueObject, BioAssayValueObject> bmap = new HashMap<>();
    ArrayDesignValueObject arrayDesign = null;
    for (BioAssayValueObject b : this.getBioAssays()) {
        bmap.put(b.getSample(), b);
        arrayDesign = b.getArrayDesign();
    }
    List<BioAssayValueObject> expandedBioAssays = new ArrayList<>();
    int i = 0;
    int indexInUngappedData = 0;
    for (BioAssayValueObject b : dimToMatchBioAssays) {
        BioMaterialValueObject bm = b.getSample();
        if (!bmap.containsKey(bm)) {
            /*
                 * This is one where we have to put in a gap.
                 */
            expandedData[i] = Double.NaN;
            BioAssayValueObject placeholder = new BioAssayValueObject(-1L);
            placeholder.setName("Missing bioassay for biomaterial=" + bm + " that was not run on " + arrayDesign);
            placeholder.setDescription("This is to represent a biomaterial that was not run on the platform for the rest of the bioassay dimension.");
            placeholder.setArrayDesign(arrayDesign);
            placeholder.setSample(bm);
            expandedBioAssays.add(placeholder);
        } else {
            expandedBioAssays.add(this.getBioAssays().get(indexInUngappedData));
            expandedData[i] = data[indexInUngappedData];
            indexInUngappedData++;
        }
        i++;
    }
    assert dimToMatchBioAssays.size() == expandedBioAssays.size();
    this.data = expandedData;
    this.setBioAssayDimension(new BioAssayDimensionValueObject(-1L));
    this.getBioAssayDimension().setSourceBioAssayDimension(sourceBioAssayDimension);
    // not exactly, but have to make clear it's not real.
    this.getBioAssayDimension().setIsSubset(true);
    this.getBioAssayDimension().clearBioAssays();
    this.getBioAssayDimension().addBioAssays(expandedBioAssays);
    this.getBioAssayDimension().setName("Expanded bioassay dimension based on " + this.getBioAssayDimension().getName());
    assert this.getBioAssays() != null;
}
Also used : BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) DoubleArrayList(cern.colt.list.DoubleArrayList) BioMaterialValueObject(ubic.gemma.model.expression.biomaterial.BioMaterialValueObject)

Example 8 with BioMaterialValueObject

use of ubic.gemma.model.expression.biomaterial.BioMaterialValueObject 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 9 with BioMaterialValueObject

use of ubic.gemma.model.expression.biomaterial.BioMaterialValueObject in project Gemma by PavlidisLab.

the class ExperimentalDesignControllerImpl method getBioMaterials.

@Override
public Collection<BioMaterialValueObject> getBioMaterials(EntityDelegator e) {
    if (e == null || e.getId() == null)
        return null;
    ExpressionExperiment ee = expressionExperimentService.load(e.getId());
    ee = expressionExperimentService.thawLite(ee);
    Collection<BioMaterialValueObject> result = new HashSet<>();
    for (BioAssay assay : ee.getBioAssays()) {
        BioMaterial sample = assay.getSampleUsed();
        BioMaterialValueObject bmvo = new BioMaterialValueObject(sample, assay);
        result.add(bmvo);
    }
    return result;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) BioMaterialValueObject(ubic.gemma.model.expression.biomaterial.BioMaterialValueObject) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Aggregations

BioMaterialValueObject (ubic.gemma.model.expression.biomaterial.BioMaterialValueObject)9 BioAssayValueObject (ubic.gemma.model.expression.bioAssay.BioAssayValueObject)5 ArrayDesignValueObject (ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)4 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)4 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)2 DoubleArrayList (cern.colt.list.DoubleArrayList)1 MapperException (com.sdicons.json.mapper.MapperException)1 HashSet (java.util.HashSet)1 JspException (javax.servlet.jsp.JspException)1 Transactional (org.springframework.transaction.annotation.Transactional)1 IdentifiableValueObject (ubic.gemma.model.IdentifiableValueObject)1 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)1 DoubleVectorValueObject (ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject)1 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)1 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)1 FactorValueValueObject (ubic.gemma.model.expression.experiment.FactorValueValueObject)1