Search in sources :

Example 86 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class AbstractMatrixRowPairAnalysis method init.

/**
 * Initialize caches.
 */
private void init() {
    this.initGeneToProbeMap();
    List<ExpressionDataMatrixRowElement> rowElements = this.dataMatrix.getRowElements();
    hasGenesCache = new boolean[rowElements.size()];
    for (ExpressionDataMatrixRowElement element : rowElements) {
        CompositeSequence de = element.getDesignElement();
        rowMapCache.put(element, de);
        Set<Gene> geneIdSet = this.probeToGeneMap.get(de);
        Integer i = element.getIndex();
        hasGenesCache[i] = geneIdSet != null && geneIdSet.size() > 0;
    }
    assert rowMapCache.size() > 0;
    AbstractMatrixRowPairAnalysis.log.info("Initialized caches for probe/gene information");
}
Also used : ExpressionDataMatrixRowElement(ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement) Gene(ubic.gemma.model.genome.Gene) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 87 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class DiffExMetaAnalyzerServiceImpl method checkAndAddResultSet.

private void checkAndAddResultSet(Collection<DifferentialExpressionAnalysisResult> resultsToUse, Collection<CompositeSequence> probes, ExpressionAnalysisResultSet rs) {
    Collection<DifferentialExpressionAnalysisResult> results = rs.getResults();
    DiffExMetaAnalyzerServiceImpl.log.info(results.size() + " results to check ...");
    for (DifferentialExpressionAnalysisResult r : results) {
        assert r != null;
        CompositeSequence probe = r.getProbe();
        assert probe != null;
        probes.add(probe);
        boolean added = resultsToUse.add(r);
        assert added : "Failed to add: " + r;
    }
    DiffExMetaAnalyzerServiceImpl.log.info(results.size() + " results checked for resultset with ID=" + rs.getId() + ", found " + probes.size() + " probes/elements so far for " + resultsToUse.size() + " results in total ...");
}
Also used : CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 88 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class AffyPowerToolsProbesetSummarize method convertDesignElementDataVectors.

/**
 * Stolen from SimpleExpressionDataLoaderService
 *
 * @param expressionExperiment ee
 * @param bioAssayDimension    BA dim
 * @param arrayDesign          target design
 * @param matrix               matrix
 * @return raw data vectors
 */
private Collection<RawExpressionDataVector> convertDesignElementDataVectors(ExpressionExperiment expressionExperiment, BioAssayDimension bioAssayDimension, ArrayDesign arrayDesign, DoubleMatrix<String, String> matrix) {
    ByteArrayConverter bArrayConverter = new ByteArrayConverter();
    Collection<RawExpressionDataVector> vectors = new HashSet<>();
    Map<String, CompositeSequence> csMap = new HashMap<>();
    for (CompositeSequence cs : arrayDesign.getCompositeSequences()) {
        csMap.put(cs.getName(), cs);
    }
    for (int i = 0; i < matrix.rows(); i++) {
        byte[] bdata = bArrayConverter.doubleArrayToBytes(matrix.getRow(i));
        RawExpressionDataVector vector = RawExpressionDataVector.Factory.newInstance();
        vector.setData(bdata);
        CompositeSequence cs = csMap.get(matrix.getRowName(i));
        if (cs == null) {
            continue;
        }
        vector.setDesignElement(cs);
        vector.setQuantitationType(this.quantitationType);
        vector.setExpressionExperiment(expressionExperiment);
        vector.setBioAssayDimension(bioAssayDimension);
        vectors.add(vector);
    }
    AffyPowerToolsProbesetSummarize.log.info("Setup " + vectors.size() + " data vectors for " + matrix.rows() + " results from APT");
    return vectors;
}
Also used : ByteArrayConverter(ubic.basecode.io.ByteArrayConverter) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 89 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class ArrayDesignMergeServiceImpl method makeBioSeqMap.

/**
 * If we're merging into an existing platform, it is important that this method is called for that platform first.
 *
 * @param globalBsMap Map that tells us, in effect, how many probes to make for the sequence. Modified by this.
 */
private ArrayDesign makeBioSeqMap(Map<BioSequence, Collection<CompositeSequence>> globalBsMap, ArrayDesign arrayDesign) {
    Map<BioSequence, Collection<CompositeSequence>> bsMap = new HashMap<>();
    arrayDesign = this.arrayDesignService.thaw(arrayDesign);
    int count = 0;
    for (CompositeSequence cs : arrayDesign.getCompositeSequences()) {
        BioSequence bs = cs.getBiologicalCharacteristic();
        if (bs == null) {
            // this is common. We could try to match them up based on the probe name, because there is nothing else
            // to go on.
            bs = ExpressionExperimentPlatformSwitchService.NULL_BIOSEQUENCE;
        }
        if (!globalBsMap.containsKey(bs)) {
            globalBsMap.put(bs, new HashSet<CompositeSequence>());
        }
        if (!bsMap.containsKey(bs)) {
            bsMap.put(bs, new HashSet<CompositeSequence>());
        }
        bsMap.get(bs).add(cs);
        /*
             * We need at one probe for each time the sequence appears on one platform. Here we ensure that the global
             * map has enough 'slots'.
             */
        if (globalBsMap.get(bs).size() < bsMap.get(bs).size()) {
            globalBsMap.get(bs).add(cs);
        }
    }
    if (++count % 10000 == 0) {
        ArrayDesignMergeServiceImpl.log.info("Processed " + count + " probes");
    }
    return arrayDesign;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) HashMap(java.util.HashMap) Collection(java.util.Collection) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 90 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class ArrayDesignMergeServiceImpl method makeNewProbes.

/**
 * Makes the new or additional probes (non-persistent) for the merged array design. If mergeWithExisting=true,
 * probes from arrayDesign will not be included; just the ones that we need to add to it will be returned.
 *
 * @param globalBsMap Map that tells us, in effect, how many probes to make for the sequence.
 */
private Collection<CompositeSequence> makeNewProbes(ArrayDesign arrayDesign, Map<BioSequence, Collection<CompositeSequence>> globalBsMap, boolean mergeWithExisting) {
    Collection<CompositeSequence> newProbes = new HashSet<>();
    ArrayDesignMergeServiceImpl.log.info(globalBsMap.size() + " unique sequences");
    Collection<String> probeNames = new HashSet<>();
    for (BioSequence bs : globalBsMap.keySet()) {
        // should be the placeholder NULL_BIOSEQUENCE
        assert bs != null;
        for (CompositeSequence cs : globalBsMap.get(bs)) {
            if (mergeWithExisting && cs.getArrayDesign().equals(arrayDesign)) {
                assert arrayDesign.getId() != null;
                /*
                     * Only add probes from the _other_ array designs.
                     */
                continue;
            }
            CompositeSequence newCs = CompositeSequence.Factory.newInstance();
            if (!bs.equals(ExpressionExperimentPlatformSwitchService.NULL_BIOSEQUENCE)) {
                newCs.setBiologicalCharacteristic(bs);
            }
            String name = this.getProbeName(probeNames, cs);
            probeNames.add(name);
            newCs.setName(name);
            newCs.setDescription((cs.getDescription() == null ? "" : cs.getDescription()) + " (via merge)");
            newCs.setArrayDesign(arrayDesign);
            newProbes.add(newCs);
            if (ArrayDesignMergeServiceImpl.log.isDebugEnabled())
                ArrayDesignMergeServiceImpl.log.debug("Made merged probe for " + bs + ": " + newCs + " for old probe on " + cs.getArrayDesign().getShortName());
        }
    }
    ArrayDesignMergeServiceImpl.log.info("Made " + newProbes.size() + " new probes");
    return newProbes;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) HashSet(java.util.HashSet)

Aggregations

CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)206 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)43 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)40 Gene (ubic.gemma.model.genome.Gene)32 Test (org.junit.Test)30 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)19 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)18 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)18 DesignElementDataVector (ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)18 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)18 StopWatch (org.apache.commons.lang3.time.StopWatch)17 HashSet (java.util.HashSet)15 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)15 CompositeSequenceValueObject (ubic.gemma.model.expression.designElement.CompositeSequenceValueObject)15 ArrayList (java.util.ArrayList)14 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)14 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)13 Taxon (ubic.gemma.model.genome.Taxon)12 Collection (java.util.Collection)11 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)11