use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class PersistentDummyObjectHelper method getTestExpressionExperimentWithAllDependencies.
public ExpressionExperiment getTestExpressionExperimentWithAllDependencies(ExpressionExperiment prototype) {
ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance();
ee.setShortName(RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
ee.setName("Expression Experiment " + RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
ee.setDescription("A test expression experiment");
ee.setSource("https://www.ncbi.nlm.nih.gov/geo/");
DatabaseEntry de1 = this.getTestPersistentDatabaseEntry(PersistentDummyObjectHelper.geo);
ee.setAccession(de1);
LocalFile file = LocalFile.Factory.newInstance();
try {
file.setLocalURL(new URL("file:///just/a/placeholder/" + ee.getShortName()));
} catch (MalformedURLException e) {
log.error("Malformed URL");
}
ee.setRawDataFile(file);
Collection<FactorValue> allFactorValues = new HashSet<>();
ExperimentalDesign ed = this.getExperimentalDesign(allFactorValues);
Collection<BioMaterial> bioMaterials = this.getBioMaterials(allFactorValues);
ee.setExperimentalDesign(ed);
ee.setOwner(this.getTestPersistentContact());
List<ArrayDesign> arrayDesignsUsed = new ArrayList<>(eeService.getArrayDesignsUsed(prototype));
Collection<BioAssay> bioAssays = new HashSet<>();
Collection<QuantitationType> quantitationTypes = this.addQuantitationTypes(new HashSet<QuantitationType>());
eeService.thaw(prototype);
Collection<RawExpressionDataVector> vectors = new HashSet<>();
for (ArrayDesign ad : arrayDesignsUsed) {
List<BioAssay> bas = this.getBioAssays(bioMaterials, ad);
bioAssays.addAll(bas);
ad = this.adService.thaw(ad);
vectors.addAll(this.getDesignElementDataVectors(ee, quantitationTypes, bas, ad));
}
ee.setBioAssays(bioAssays);
assert quantitationTypes.size() > 0;
ee.setQuantitationTypes(quantitationTypes);
ee.setRawExpressionDataVectors(vectors);
ArrayDesignsForExperimentCache c = persisterHelper.prepare(ee);
ee = persisterHelper.persist(ee, c);
return ee;
}
use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class PersistentDummyObjectHelper method getDesignElementDataVectors.
/**
* @param bioAssays BAs
* @param ad AD
* @param ee EE
* @param quantitationTypes QTs
* @return These are non-persistent
*/
private Collection<RawExpressionDataVector> getDesignElementDataVectors(ExpressionExperiment ee, Collection<QuantitationType> quantitationTypes, List<BioAssay> bioAssays, ArrayDesign ad) {
BioAssayDimension baDim = BioAssayDimension.Factory.newInstance(ee.getShortName() + "_" + RandomStringUtils.randomAlphanumeric(20), null, bioAssays);
Collection<RawExpressionDataVector> vectors = new HashSet<>();
for (QuantitationType quantType : quantitationTypes) {
for (CompositeSequence cs : ad.getCompositeSequences()) {
RawExpressionDataVector vector = RawExpressionDataVector.Factory.newInstance();
byte[] bdata = this.getDoubleData();
vector.setData(bdata);
vector.setDesignElement(cs);
assert cs.getArrayDesign() != null;
vector.setExpressionExperiment(ee);
vector.setQuantitationType(quantType);
vector.setBioAssayDimension(baDim);
vectors.add(vector);
}
}
return vectors;
}
use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class PersistentDummyObjectHelper method getTestExpressionExperimentWithAllDependencies.
/**
* Add an expressionExperiment to the database for testing purposes. Includes associations
*
* @param doSequence Should the array design get all the sequence information filled in? (true = slower)
* @return EE
*/
public ExpressionExperiment getTestExpressionExperimentWithAllDependencies(boolean doSequence) {
ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance();
ee.setShortName(RandomStringUtils.randomAlphanumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
ee.setName("Expression Experiment " + RandomStringUtils.randomNumeric(PersistentDummyObjectHelper.RANDOM_STRING_LENGTH));
ee.setDescription("A test expression experiment");
ee.setSource("https://www.ncbi.nlm.nih.gov/geo/");
DatabaseEntry de1 = this.getTestPersistentDatabaseEntry(PersistentDummyObjectHelper.geo);
ee.setAccession(de1);
LocalFile file = LocalFile.Factory.newInstance();
try {
file.setLocalURL(new URL("file:///just/a/placeholder/" + ee.getShortName()));
} catch (MalformedURLException e) {
log.error("Malformed URL");
}
ee.setRawDataFile(file);
ArrayDesign adA = this.getTestPersistentArrayDesign(this.getTestElementCollectionSize(), false, doSequence);
ArrayDesign adB = this.getTestPersistentArrayDesign(this.getTestElementCollectionSize(), false, doSequence);
Collection<FactorValue> allFactorValues = new HashSet<>();
ExperimentalDesign ed = this.getExperimentalDesign(allFactorValues);
ee.setExperimentalDesign(ed);
ee.setOwner(this.getTestPersistentContact());
Collection<BioAssay> bioAssays = new HashSet<>();
Collection<BioMaterial> bioMaterials = this.getBioMaterials(allFactorValues);
List<BioAssay> bioAssaysA = this.getBioAssays(bioMaterials, adA);
List<BioAssay> bioAssaysB = this.getBioAssays(bioMaterials, adB);
bioAssays.addAll(bioAssaysA);
bioAssays.addAll(bioAssaysB);
ee.setBioAssays(bioAssays);
log.debug("expression experiment => design element data vectors");
Collection<RawExpressionDataVector> vectors = new HashSet<>();
Collection<QuantitationType> quantitationTypes = this.addQuantitationTypes(new HashSet<QuantitationType>());
assert quantitationTypes.size() > 0;
vectors.addAll(this.getDesignElementDataVectors(ee, quantitationTypes, bioAssaysA, adA));
vectors.addAll(this.getDesignElementDataVectors(ee, quantitationTypes, bioAssaysB, adB));
ee.setQuantitationTypes(quantitationTypes);
ee.setRawExpressionDataVectors(vectors);
ArrayDesignsForExperimentCache c = persisterHelper.prepare(ee);
ee = persisterHelper.persist(ee, c);
return ee;
}
use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class TwoChannelMissingValueTaskImpl method execute.
@Override
public TaskResult execute() {
ExpressionExperiment ee = taskCommand.getExpressionExperiment();
Collection<RawExpressionDataVector> missingValueVectors = twoChannelMissingValues.computeMissingValues(ee, taskCommand.getS2n(), taskCommand.getExtraMissingValueIndicators());
System.out.println("MVs: " + missingValueVectors.size());
return new TaskResult(taskCommand, missingValueVectors.size());
}
use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.
the class ExpressionDataDoubleMatrixTest method testConstructExpressionDataDoubleMatrixWithGeoValues.
/**
* This is a self-contained test. That is, it does not depend on the setup in onSetUpInTransaction}. It tests
* creating an {@link ExpressionDataDoubleMatrix} using real values from the Gene Expression Omnibus (GEO). That is,
* we have obtained information from GSE994. The probe sets used are 218120_s_at and 121_at, and the samples used
* are GSM15697 and GSM15744. Specifically, we the Gemma objects that correspond to the GEO objects are:
* DesignElement 1 = 218120_s_at, DesignElement 2 = 121_at
* BioAssay 1 = "Current Smoker 73", BioAssay 2 = "Former Smoker 34"
* BioMaterial 1 = "GSM15697", BioMaterial 2 = "GSM15744"
* BioAssayDimension = "GSM15697, GSM15744" (the names of all the biomaterials).
*/
@Test
public void testConstructExpressionDataDoubleMatrixWithGeoValues() {
ByteArrayConverter bac = new ByteArrayConverter();
ee = ExpressionExperiment.Factory.newInstance();
QuantitationType qt = QuantitationType.Factory.newInstance();
qt.setName("VALUE");
qt.setIsBackgroundSubtracted(false);
qt.setIsNormalized(false);
qt.setIsBackground(false);
qt.setIsRatio(false);
qt.setIsPreferred(true);
qt.setIsMaskedPreferred(false);
qt.setRepresentation(PrimitiveType.DOUBLE);
BioAssayDimension bioAssayDimension = BioAssayDimension.Factory.newInstance();
bioAssayDimension.setName("GSM15697, GSM15744");
List<BioAssay> assays = new ArrayList<>();
BioAssay assay1 = BioAssay.Factory.newInstance();
assay1.setName("Current Smoker 73");
BioMaterial sample1 = BioMaterial.Factory.newInstance();
sample1.setName("GSM15697");
assay1.setSampleUsed(sample1);
assays.add(assay1);
BioAssay assay2 = BioAssay.Factory.newInstance();
assay2.setName("Former Smoker 34");
BioMaterial sample2 = BioMaterial.Factory.newInstance();
sample2.setName("GSM15744");
assay2.setSampleUsed(sample2);
assays.add(assay2);
bioAssayDimension.setBioAssays(assays);
RawExpressionDataVector vector1 = RawExpressionDataVector.Factory.newInstance();
double[] ddata1 = { 74.9, 101.7 };
byte[] bdata1 = bac.doubleArrayToBytes(ddata1);
vector1.setData(bdata1);
vector1.setQuantitationType(qt);
vector1.setBioAssayDimension(bioAssayDimension);
RawExpressionDataVector vector2 = RawExpressionDataVector.Factory.newInstance();
double[] ddata2 = { 404.6, 318.7 };
byte[] bdata2 = bac.doubleArrayToBytes(ddata2);
vector2.setData(bdata2);
vector2.setQuantitationType(qt);
vector2.setBioAssayDimension(bioAssayDimension);
ArrayDesign ad = ArrayDesign.Factory.newInstance();
ad.setName("test ar");
CompositeSequence de1 = CompositeSequence.Factory.newInstance();
de1.setName("218120_s_at");
vector1.setDesignElement(de1);
BioSequence bs1 = BioSequence.Factory.newInstance();
bs1.setName("test1");
de1.setBiologicalCharacteristic(bs1);
de1.setArrayDesign(ad);
CompositeSequence de2 = CompositeSequence.Factory.newInstance();
de2.setName("121_at");
BioSequence bs2 = BioSequence.Factory.newInstance();
bs2.setName("test2");
de2.setBiologicalCharacteristic(bs2);
de2.setArrayDesign(ad);
vector2.setDesignElement(de2);
Collection<RawExpressionDataVector> eeVectors = new LinkedHashSet<>();
eeVectors.add(vector1);
eeVectors.add(vector2);
ee.setRawExpressionDataVectors(eeVectors);
ExpressionDataDoubleMatrix expressionDataMatrix = new ExpressionDataDoubleMatrix(eeVectors);
assertNotNull(expressionDataMatrix);
assertEquals(expressionDataMatrix.rows(), 2);
assertEquals(expressionDataMatrix.columns(), 2);
}
Aggregations