Search in sources :

Example 21 with BioMaterial

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

the class BatchInfoPopulationServiceImpl method getBatchDataFromRawFiles.

/**
 * @param files Local copies of raw data files obtained from the data provider (e.g. GEO), adds audit event.
 * @param ee    ee
 * @return boolean
 */
private boolean getBatchDataFromRawFiles(ExpressionExperiment ee, Collection<LocalFile> files) {
    BatchInfoParser batchInfoParser = new BatchInfoParser();
    ee = expressionExperimentService.thaw(ee);
    if (ee.getAccession() == null) {
        // in fact, currently it has to be from GEO.
        throw new IllegalArgumentException("The experiment does not seem to be from an external source that would have batch information available.");
    }
    Map<BioMaterial, Date> dates = batchInfoParser.getBatchInfo(ee, files);
    this.removeExistingBatchFactor(ee);
    ExperimentalFactor factor = batchInfoPopulationHelperService.createBatchFactor(ee, dates);
    if (!dates.isEmpty()) {
        int numberOfBatches = factor == null || factor.getFactorValues().size() == 0 ? 0 : factor.getFactorValues().size();
        List<Date> allDates = new ArrayList<>(dates.values());
        Collections.sort(allDates);
        String datesString = StringUtils.join(allDates, "\n");
        BatchInfoPopulationServiceImpl.log.info("Got batch information for: " + ee.getShortName() + ", with " + numberOfBatches + " batches.");
        this.auditTrailService.addUpdateEvent(ee, BatchInformationFetchingEvent.class, batchInfoParser.getScanDateExtractor().getClass().getSimpleName() + "; " + numberOfBatches + " batches.", "Dates of sample runs: " + datesString);
        return true;
    }
    return false;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) ExperimentalFactor(ubic.gemma.model.expression.experiment.ExperimentalFactor)

Example 22 with BioMaterial

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

the class SVDServiceHelperImpl method svd.

@Override
public SVDValueObject svd(ExpressionExperiment ee) {
    assert ee != null;
    Collection<ProcessedExpressionDataVector> vectors = processedExpressionDataVectorService.getProcessedDataVectors(ee);
    if (vectors.isEmpty()) {
        throw new IllegalArgumentException("Experiment must have processed data already to do SVD");
    }
    processedExpressionDataVectorService.thaw(vectors);
    ExpressionDataDoubleMatrix mat = new ExpressionDataDoubleMatrix(vectors);
    SVDServiceHelperImpl.log.info("Starting SVD");
    ExpressionDataSVD svd = new ExpressionDataSVD(mat);
    SVDServiceHelperImpl.log.info("SVD done, postprocessing and storing results.");
    /*
         * Save the results
         */
    DoubleMatrix<Integer, BioMaterial> v = svd.getV();
    BioAssayDimension b = mat.getBestBioAssayDimension();
    PrincipalComponentAnalysis pca = this.updatePca(ee, svd, v, b);
    return this.svdFactorAnalysis(pca);
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) PrincipalComponentAnalysis(ubic.gemma.model.analysis.expression.pca.PrincipalComponentAnalysis) ExpressionDataDoubleMatrix(ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix) ProcessedExpressionDataVector(ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector)

Example 23 with BioMaterial

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

the class GeoDatasetServiceTest method testFetchAndLoadGSE13657.

/*
     * Left out quantitation types due to bug in how quantitation types were cached during persisting, if the QTs didn't
     * have descriptions.
     */
@Test
public void testFetchAndLoadGSE13657() throws Exception {
    try {
        geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath()));
        Collection<?> results = geoService.fetchAndLoad("GSE13657", false, true, false);
        ee = (ExpressionExperiment) results.iterator().next();
    } catch (AlreadyExistsInSystemException e) {
        log.info("Test skipped because GSE13657 was already loaded - clean the DB before running the test");
        return;
    }
    ee = this.eeService.thawLite(ee);
    aclTestUtils.checkEEAcls(ee);
    Collection<QuantitationType> qts = eeService.getQuantitationTypes(ee);
    assertEquals(13, qts.size());
    // make sure we got characteristics and treatments for both channels.
    for (BioAssay ba : ee.getBioAssays()) {
        BioMaterial bm = ba.getSampleUsed();
        assertNotNull(bm);
        log.info(bm + " " + bm.getDescription());
        assertEquals(9, bm.getCharacteristics().size());
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Example 24 with BioMaterial

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

the class ExperimentalDesignImporterTest method testParseWhereExtraValue.

/*
     * test case where the design file has extra information not relevant to the current samples.
     */
@Test
public final void testParseWhereExtraValue() throws Exception {
    try (InputStream is = this.getClass().getResourceAsStream("/data/loader/expression/experimentalDesignTestExtra.txt")) {
        experimentalDesignImporter.importDesign(ee, is);
    }
    ee = this.eeService.thawLite(ee);
    Collection<BioMaterial> bms = new HashSet<>();
    for (BioAssay ba : ee.getBioAssays()) {
        BioMaterial bm = ba.getSampleUsed();
        bms.add(bm);
    }
    this.aclTestUtils.checkEEAcls(ee);
    this.checkResults(bms);
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) InputStream(java.io.InputStream) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) HashSet(java.util.HashSet) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 25 with BioMaterial

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

the class DifferentialExpressionAnalyzerServiceTest method setup.

@Before
public void setup() throws Exception {
    ee = expressionExperimentService.findByShortName("GSE1611");
    if (ee == null) {
        geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("gds994Short")));
        Collection<?> results = geoService.fetchAndLoad("GSE1611", false, true, false);
        ee = (ExpressionExperiment) results.iterator().next();
    }
    processedDataVectorService.createProcessedDataVectors(ee);
    ee = expressionExperimentService.findByShortName("GSE1611");
    ee = expressionExperimentService.thawLite(ee);
    differentialExpressionAnalyzerService.deleteAnalyses(ee);
    assertEquals(2, ee.getExperimentalDesign().getExperimentalFactors().size());
    for (BioAssay ba : ee.getBioAssays()) {
        BioMaterial bm = ba.getSampleUsed();
        assertEquals(bm + " " + ba, 2, bm.getFactorValues().size());
    }
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) Before(org.junit.Before)

Aggregations

BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)132 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)67 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)27 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)22 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)19 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)15 HashSet (java.util.HashSet)13 Test (org.junit.Test)13 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)12 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)12 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)10 InputStream (java.io.InputStream)7 DenseDoubleMatrix (ubic.basecode.dataStructure.matrix.DenseDoubleMatrix)7 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)7 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)7 Characteristic (ubic.gemma.model.common.description.Characteristic)6 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)6 DoubleArrayList (cern.colt.list.DoubleArrayList)5 DoubleMatrix1D (cern.colt.matrix.DoubleMatrix1D)5 ArrayList (java.util.ArrayList)5