Search in sources :

Example 61 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class ExpressionExperimentServiceTest method testGetQuantitationTypesForArrayDesign.

@Test
public final void testGetQuantitationTypesForArrayDesign() {
    ArrayDesign ad = ee.getRawExpressionDataVectors().iterator().next().getDesignElement().getArrayDesign();
    Collection<QuantitationType> types = expressionExperimentService.getQuantitationTypes(ee, ad);
    assertEquals(2, types.size());
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 62 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class ExpressionExperimentPlatformSwitchService method locateMergedDesign.

private ArrayDesign locateMergedDesign(ExpressionExperiment expExp) {
    // get the array designs for this EE
    ArrayDesign arrayDesign = null;
    Collection<ArrayDesign> oldArrayDesigns = expressionExperimentService.getArrayDesignsUsed(expExp);
    // find the AD they have been merged into, make sure it is exists and they are all merged into the same AD.
    for (ArrayDesign design : oldArrayDesigns) {
        ArrayDesign mergedInto = design.getMergedInto();
        mergedInto = arrayDesignService.thaw(mergedInto);
        if (mergedInto == null) {
            throw new IllegalArgumentException(design + " used by " + expExp + " is not merged into another design");
        }
        if (arrayDesign == null) {
            arrayDesign = mergedInto;
            arrayDesign = arrayDesignService.thaw(arrayDesign);
        }
        if (!mergedInto.equals(arrayDesign)) {
            throw new IllegalArgumentException(design + " used by " + expExp + " is not merged into " + arrayDesign);
        }
    }
    return arrayDesign;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign)

Example 63 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class ExpressionExperimentPlatformSwitchService method switchExperimentToArrayDesign.

/**
 * If you know the arraydesigns are already in a merged state, you should use switchExperimentToMergedPlatform
 *
 * @param ee          ee
 * @param arrayDesign The array design to switch to. If some samples already use that array design, nothing will be
 *                    changed for them.
 */
public ExpressionExperiment switchExperimentToArrayDesign(ExpressionExperiment ee, ArrayDesign arrayDesign) {
    assert arrayDesign != null;
    // remove stuff that will be in the way.
    processedExpressionDataVectorService.removeProcessedDataVectors(ee);
    sampleCoexpressionMatrixService.delete(ee);
    for (ExpressionExperimentSubSet subset : expressionExperimentService.getSubSets(ee)) {
        subsetService.remove(subset);
    }
    // get relation between sequence and designelements.
    Map<BioSequence, Collection<CompositeSequence>> designElementMap = new HashMap<>();
    Collection<CompositeSequence> elsWithNoSeq = new HashSet<>();
    this.populateCSeq(arrayDesign, designElementMap, elsWithNoSeq);
    ee = expressionExperimentService.thaw(ee);
    ExpressionExperimentPlatformSwitchService.log.info(elsWithNoSeq.size() + " elements on the new platform have no associated sequence.");
    designElementMap.put(ExpressionExperimentPlatformSwitchService.NULL_BIOSEQUENCE, elsWithNoSeq);
    boolean multiPlatformPerSample = this.checkMultiPerSample(ee, arrayDesign);
    /*
         * For a multiplatform-per-sample case: (note that some samples might just be on one platform...)
         * 1. Pick a BAD that can be used for all DataVectors (it has all BioAssays in it).
         * 2. Switch vectors to use it - may require adding NaNs and reordering the vectors
         * 3. Delete the Bioassays that are using other BADs
         */
    /*
         * Now we have to get the BADs. Problem to watch out for: they might not be the same length, we need one that
         * includes all BioMaterials.
         */
    Collection<BioAssayDimension> unusedBADs = new HashSet<>();
    BioAssayDimension maxBAD = null;
    int maxSize = 0;
    if (multiPlatformPerSample) {
        maxBAD = this.doMultiSample(ee, unusedBADs, maxSize);
    }
    Collection<ArrayDesign> oldArrayDesigns = expressionExperimentService.getArrayDesignsUsed(ee);
    Map<CompositeSequence, Collection<BioAssayDimension>> usedDesignElements = new HashMap<>();
    for (ArrayDesign oldAd : oldArrayDesigns) {
        this.runOldAd(ee, arrayDesign, designElementMap, maxBAD, usedDesignElements, oldAd);
    }
    ee.setDescription(ee.getDescription() + " [Switched to use " + arrayDesign.getShortName() + " by Gemma]");
    helperService.persist(ee, arrayDesign);
    /*
         * This might need to be done inside the transaction we're using to make the switch.
         */
    if (maxBAD != null && !unusedBADs.isEmpty()) {
        this.checkUnused(unusedBADs, maxBAD);
    }
    return ee;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ExpressionExperimentSubSet(ubic.gemma.model.expression.experiment.ExpressionExperimentSubSet) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension)

Example 64 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class GeoServiceImpl method updateReports.

private void updateReports(Collection<?> entities) {
    Collection<ArrayDesign> adsToUpdate = new HashSet<>();
    for (Object entity : entities) {
        if (entity instanceof ExpressionExperiment) {
            ExpressionExperiment expressionExperiment = (ExpressionExperiment) entity;
            expressionExperiment = this.expressionExperimentService.thaw(expressionExperiment);
            this.expressionExperimentReportService.generateSummary(expressionExperiment.getId());
            expressionExperiment = this.expressionExperimentService.thaw(expressionExperiment);
            for (BioAssay ba : expressionExperiment.getBioAssays()) {
                adsToUpdate.add(ba.getArrayDesignUsed());
            }
        } else if (entity instanceof ArrayDesign) {
            adsToUpdate.add((ArrayDesign) entity);
        }
    }
    for (ArrayDesign arrayDesign : adsToUpdate) {
        this.arrayDesignReportService.generateArrayDesignReport(arrayDesign.getId());
    }
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 65 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class GeoServiceImpl method matchToExistingPlatform.

private void matchToExistingPlatform(GeoConverter geoConverter, GeoPlatform rawGEOPlatform, ArrayDesignsForExperimentCache c) {
    // we have to populate this.
    Map<String, String> probeNamesInGemma = rawGEOPlatform.getProbeNamesInGemma();
    // do a partial conversion. We will throw this away;
    ArrayDesign geoArrayDesign = (ArrayDesign) geoConverter.convert(rawGEOPlatform);
    if (geoArrayDesign == null) {
        if (!rawGEOPlatform.useDataFromGeo()) {
            // MPSS, exon arrays
            return;
        }
        throw new IllegalStateException("Platform is missing");
    }
    // find in our system. Note we only use the short name. The full name can change in GEO, causing trouble.
    ArrayDesign existing = arrayDesignService.findByShortName(geoArrayDesign.getShortName());
    if (existing == null) {
        AbstractGeoService.log.info(rawGEOPlatform + " looks new to Gemma");
        for (CompositeSequence cs : geoArrayDesign.getCompositeSequences()) {
            String geoProbeName = cs.getName();
            probeNamesInGemma.put(geoProbeName, geoProbeName);
        // no mapping needed. NB the converter fills
        // this in already, we're just being defensive
        // here.
        }
    } else {
        AbstractGeoService.log.info("Platform " + rawGEOPlatform.getGeoAccession() + " exists in Gemma, checking for correct probe names and re-matching if necessary ...");
        String columnWithGeoNames;
        columnWithGeoNames = this.getGEOIDColumnName(rawGEOPlatform, geoArrayDesign);
        if (columnWithGeoNames == null) {
            // no problem: this means the design has no elements, so it is actually a placeholder (e.g., MPSS)
            return;
        }
        AbstractGeoService.log.info("Loading probes ...");
        Map<CompositeSequence, BioSequence> m = arrayDesignService.getBioSequences(existing);
        c.add(existing, m);
        this.getGemmaIDColumnNameInGEO(rawGEOPlatform, m, columnWithGeoNames);
    }
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Aggregations

ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)186 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)43 Test (org.junit.Test)32 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)26 InputStream (java.io.InputStream)25 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)24 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)24 Taxon (ubic.gemma.model.genome.Taxon)23 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)19 HashSet (java.util.HashSet)16 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)16 Collection (java.util.Collection)14 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)13 StopWatch (org.apache.commons.lang3.time.StopWatch)12 Before (org.junit.Before)12 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)12 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)9 GZIPInputStream (java.util.zip.GZIPInputStream)8 SimpleExpressionExperimentMetaData (ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData)8 File (java.io.File)7