Search in sources :

Example 46 with RawExpressionDataVector

use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.

the class DataUpdater method addAffyData.

/**
 * For 3' arrays. This only works for single-platform experiments.
 *
 * @param ee                  ee
 * @param pathToAptOutputFile file
 */
public void addAffyData(ExpressionExperiment ee, String pathToAptOutputFile) throws IOException {
    Collection<ArrayDesign> ads = experimentService.getArrayDesignsUsed(ee);
    if (ads.size() > 1) {
        throw new IllegalArgumentException("Can't handle experiments with more than one platform when passing APT output file.");
    }
    ArrayDesign ad = ads.iterator().next();
    ad = arrayDesignService.thaw(ad);
    ee = experimentService.thawLite(ee);
    AffyPowerToolsProbesetSummarize apt = new AffyPowerToolsProbesetSummarize();
    Collection<RawExpressionDataVector> vectors = apt.processData(ee, pathToAptOutputFile, ad);
    if (vectors.isEmpty()) {
        throw new IllegalStateException("No vectors were returned for " + ee);
    }
    experimentService.replaceRawVectors(ee, vectors);
    this.audit(ee, "Data vector input from APT output file " + pathToAptOutputFile + " on " + ad, true);
    this.postprocess(ee);
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) AffyPowerToolsProbesetSummarize(ubic.gemma.core.loader.expression.AffyPowerToolsProbesetSummarize)

Example 47 with RawExpressionDataVector

use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.

the class ExperimentPlatformSwitchHelperServiceImpl method persist.

@Override
@Transactional
public void persist(ExpressionExperiment ee, ArrayDesign arrayDesign) {
    expressionExperimentService.update(ee);
    analysisUtilService.deleteOldAnalyses(ee);
    procVectorService.update(ee.getProcessedExpressionDataVectors());
    rawVectorService.update(ee.getRawExpressionDataVectors());
    this.audit(ee, "Switch to use " + arrayDesign.getShortName());
    for (RawExpressionDataVector v : ee.getRawExpressionDataVectors()) {
        if (!arrayDesign.equals(v.getDesignElement().getArrayDesign())) {
            throw new IllegalStateException("A raw vector for QT =" + v.getQuantitationType() + " was not correctly switched to the target platform " + arrayDesign);
        }
    }
    ExperimentPlatformSwitchHelperServiceImpl.log.info(// flush of transaction happens after this, can take a while.
    "Completing switching " + ee);
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) Transactional(org.springframework.transaction.annotation.Transactional)

Example 48 with RawExpressionDataVector

use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.

the class TwoChannelMissingValuesTest method testMissingValueGSE11017.

/**
 * Was giving all missing values.
 */
@Test
public void testMissingValueGSE11017() throws Exception {
    ExpressionExperiment old = eeService.findByShortName("GSE11017");
    if (old != null)
        eeService.remove(old);
    InputStream is = new GZIPInputStream(this.getClass().getResourceAsStream("/data/loader/expression/geo/GSE11017.soft.gz"));
    GeoFamilyParser parser = new GeoFamilyParser();
    parser.parse(is);
    GeoSeries series = ((GeoParseResult) parser.getResults().iterator().next()).getSeriesMap().get("GSE11017");
    DatasetCombiner datasetCombiner = new DatasetCombiner();
    GeoSampleCorrespondence correspondence = datasetCombiner.findGSECorrespondence(series);
    series.setSampleCorrespondence(correspondence);
    Object result = this.gc.convert(series);
    assertNotNull(result);
    ExpressionExperiment expExp = (ExpressionExperiment) ((Collection<?>) result).iterator().next();
    expExp = persisterHelper.persist(expExp, persisterHelper.prepare(expExp));
    Collection<RawExpressionDataVector> calls = tcmv.computeMissingValues(expExp, 2.0, new ArrayList<Double>());
    // print( calls );
    assertEquals(20, calls.size());
    boolean hasNewQT = false;
    Collection<QuantitationType> qts = eeService.getQuantitationTypes(expExp);
    for (QuantitationType qt : qts) {
        if (qt.getType().equals(StandardQuantitationType.PRESENTABSENT)) {
            hasNewQT = true;
            break;
        }
    }
    assertTrue(hasNewQT);
    ExpressionDataMatrixBuilder builder = new ExpressionDataMatrixBuilder(calls);
    ExpressionDataBooleanMatrix missingValues = builder.getMissingValueData();
    assertTrue(missingValues.getQuantitationTypes().iterator().next().getDescription().contains("signal threshold"));
    Boolean[][] mm = missingValues.getRawMatrix();
    boolean hasPresent = false;
    for (Boolean[] aMm : mm) {
        for (Boolean anAMm : aMm) {
            if (anAMm) {
                hasPresent = true;
                break;
            }
        }
    }
    assertTrue(hasPresent);
}
Also used : GeoSeries(ubic.gemma.core.loader.expression.geo.model.GeoSeries) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GZIPInputStream(java.util.zip.GZIPInputStream) ExpressionDataBooleanMatrix(ubic.gemma.core.datastructure.matrix.ExpressionDataBooleanMatrix) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) Collection(java.util.Collection) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) StandardQuantitationType(ubic.gemma.model.common.quantitationtype.StandardQuantitationType) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 49 with RawExpressionDataVector

use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.

the class TwoChannelMissingValuesTest method testMissingValueGSE523.

@Test
public final void testMissingValueGSE523() throws Exception {
    ExpressionExperiment old = eeService.findByShortName("GSE523");
    if (old != null)
        eeService.remove(old);
    InputStream is = new GZIPInputStream(this.getClass().getResourceAsStream("/data/loader/expression/geo/GSE523_family.soft.gz"));
    GeoFamilyParser parser = new GeoFamilyParser();
    parser.parse(is);
    GeoSeries series = ((GeoParseResult) parser.getResults().iterator().next()).getSeriesMap().get("GSE523");
    DatasetCombiner datasetCombiner = new DatasetCombiner();
    GeoSampleCorrespondence correspondence = datasetCombiner.findGSECorrespondence(series);
    series.setSampleCorrespondence(correspondence);
    Object result = this.gc.convert(series);
    assertNotNull(result);
    ExpressionExperiment expExp = (ExpressionExperiment) ((Collection<?>) result).iterator().next();
    expExp = persisterHelper.persist(expExp, persisterHelper.prepare(expExp));
    Collection<RawExpressionDataVector> calls = tcmv.computeMissingValues(expExp, 2.0, new ArrayList<Double>());
    assertEquals(30, calls.size());
}
Also used : GeoSeries(ubic.gemma.core.loader.expression.geo.model.GeoSeries) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GZIPInputStream(java.util.zip.GZIPInputStream) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) Collection(java.util.Collection) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 50 with RawExpressionDataVector

use of ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector in project Gemma by PavlidisLab.

the class LinkAnalysisServiceTest method testLoadAnalyzeSaveAndCoexpSearch.

@Test
public void testLoadAnalyzeSaveAndCoexpSearch() {
    ee = this.getTestPersistentCompleteExpressionExperimentWithSequences();
    processedExpressionDataVectorService.computeProcessedExpressionData(ee);
    tableMaintenanceUtil.disableEmail();
    tableMaintenanceUtil.updateGene2CsEntries();
    linkAnalysisConfig.setCdfCut(0.1);
    linkAnalysisConfig.setSingularThreshold(SingularThreshold.cdfcut);
    linkAnalysisConfig.setProbeDegreeThreshold(25);
    linkAnalysisConfig.setCheckCorrelationDistribution(false);
    linkAnalysisConfig.setCheckForBatchEffect(false);
    filterConfig.setIgnoreMinimumSampleThreshold(true);
    // first time.
    // noinspection UnusedAssignment // we still want to do this for the testing sake
    LinkAnalysis la = linkAnalysisService.process(ee, filterConfig, linkAnalysisConfig);
    // test remove is clean; to check this properly requires checking the db.
    linkAnalysisPersisterService.deleteAnalyses(ee);
    this.checkUnsupportedLinksHaveNoSupport();
    assertEquals(0, geneCoexpressionService.getCoexpression(ee, true).size());
    la = linkAnalysisService.process(ee, filterConfig, linkAnalysisConfig);
    CoexpressionAnalysis analysisObj = la.getAnalysisObj();
    assertEquals(151, analysisObj.getNumberOfElementsAnalyzed().intValue());
    assertTrue(analysisObj.getNumberOfLinks() > 0);
    assertNotNull(analysisObj.getCoexpCorrelationDistribution());
    Collection<BioAssaySet> ees = new HashSet<>();
    ees.add(ee);
    this.updateNodeDegree();
    int totalLinksFirstPass = this.checkResults(ees, 1);
    // should be ~1140.
    assertTrue(totalLinksFirstPass > 1000);
    // test redo
    linkAnalysisService.process(ee, filterConfig, linkAnalysisConfig);
    this.updateNodeDegree();
    int totalLinksRedo = this.checkResults(ees, 1);
    assertEquals(totalLinksFirstPass, totalLinksRedo);
    // now add another experiment that has overlapping links (same data...
    Map<CompositeSequence, byte[]> dataMap = new HashMap<>();
    ee = eeService.thaw(ee);
    for (RawExpressionDataVector v : ee.getRawExpressionDataVectors()) {
        dataMap.put(v.getDesignElement(), v.getData());
    }
    ExpressionExperiment ee2 = this.getTestPersistentCompleteExpressionExperimentWithSequences(ee);
    // eeService.thawRawAndProcessed( ee2 );
    for (RawExpressionDataVector v : ee2.getRawExpressionDataVectors()) {
        assert dataMap.get(v.getDesignElement()) != null;
        v.setData(dataMap.get(v.getDesignElement()));
    }
    eeService.update(ee2);
    processedExpressionDataVectorService.computeProcessedExpressionData(ee2);
    linkAnalysisService.process(ee2, filterConfig, linkAnalysisConfig);
    this.updateNodeDegree();
    // expect to get at least one links with support >1
    ees.add(ee2);
    this.checkResults(ees, 2);
}
Also used : CoexpressionAnalysis(ubic.gemma.model.analysis.expression.coexpression.CoexpressionAnalysis) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) BioAssaySet(ubic.gemma.model.expression.experiment.BioAssaySet) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Aggregations

RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)53 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)18 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)16 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)16 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)16 Test (org.junit.Test)15 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)13 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)12 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)9 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)7 InputStream (java.io.InputStream)6 Collection (java.util.Collection)6 HashSet (java.util.HashSet)6 GZIPInputStream (java.util.zip.GZIPInputStream)6 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)6 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)6 GeoSeries (ubic.gemma.core.loader.expression.geo.model.GeoSeries)6 DesignElementDataVector (ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)6 ProcessedExpressionDataVector (ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector)5 Transactional (org.springframework.transaction.annotation.Transactional)4