Search in sources :

Example 1 with ExpressionDataMatrixRowElement

use of ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement in project Gemma by PavlidisLab.

the class AbstractMatrixRowPairAnalysis method getNumComputed.

private int getNumComputed(int numrows, int numcols, boolean docalcs, double[][] data, StopWatch timer, ExpressionDataMatrixRowElement itemA, double[] vectorA, int numComputed, int i) {
    ExpressionDataMatrixRowElement itemB;
    for (int j = i + 1; j < numrows; j++) {
        itemB = this.dataMatrix.getRowElement(j);
        if (!this.hasGene(itemB))
            continue;
        if (!docalcs || results.get(i, j) != 0.0) {
            // second pass over matrix. Don't calculate it
            // if we
            // already have it. Just do the requisite checks.
            this.keepCorrellation(i, j, results.get(i, j), numcols);
            continue;
        }
        double[] vectorB = data[j];
        this.setCorrel(i, j, this.correlFast(vectorA, vectorB, i, j), numcols);
        ++numComputed;
    }
    this.computeRow(timer, itemA, numComputed, i);
    return numComputed;
}
Also used : ExpressionDataMatrixRowElement(ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement)

Example 2 with ExpressionDataMatrixRowElement

use of ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement in project Gemma by PavlidisLab.

the class AbstractMatrixRowPairAnalysis method crossHybridizes.

/**
 * Determine if the probes at this location in the matrix assay any of the same gene(s). This has nothing to do with
 * whether the probes are specific, though non-specific probes (which hit more than one gene) are more likely to be
 * affected by this.
 *
 * @return true if the probes hit the same gene; false otherwise. If the probes hit more than one gene, and any of
 * the genes are in common, the result is 'true'.
 */
private boolean crossHybridizes(int i, int j) {
    if (this.dataMatrix == null)
        // can happen in tests.
        return false;
    ExpressionDataMatrixRowElement itemA = this.dataMatrix.getRowElement(i);
    ExpressionDataMatrixRowElement itemB = this.dataMatrix.getRowElement(j);
    Collection<Gene> genesA = this.probeToGeneMap.get(itemA.getDesignElement());
    Collection<Gene> genesB = this.probeToGeneMap.get(itemB.getDesignElement());
    return CollectionUtils.containsAny(genesA, genesB);
}
Also used : ExpressionDataMatrixRowElement(ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement) Gene(ubic.gemma.model.genome.Gene)

Example 3 with ExpressionDataMatrixRowElement

use of ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement in project Gemma by PavlidisLab.

the class AbstractMatrixRowPairAnalysis method computeMetrics.

int computeMetrics(int numrows, int numcols, boolean docalcs, StopWatch timer, int skipped, int numComputed, double[][] data) {
    ExpressionDataMatrixRowElement itemA;
    double[] vectorA = null;
    for (int i = 0; i < numrows; i++) {
        itemA = this.dataMatrix.getRowElement(i);
        if (!this.hasGene(itemA)) {
            skipped++;
            continue;
        }
        if (docalcs) {
            vectorA = data[i];
        }
        numComputed = this.getNumComputed(numrows, numcols, docalcs, data, timer, itemA, vectorA, numComputed, i);
    }
    return skipped;
}
Also used : ExpressionDataMatrixRowElement(ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement)

Example 4 with ExpressionDataMatrixRowElement

use of ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement 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 5 with ExpressionDataMatrixRowElement

use of ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement in project Gemma by PavlidisLab.

the class TwoChannelMissingValuesImpl method computeSignalThreshold.

/**
 * Determine a threshold based on the data.
 */
private Double computeSignalThreshold(ExpressionDataDoubleMatrix preferred, ExpressionDataDoubleMatrix signalChannelA, ExpressionDataDoubleMatrix signalChannelB, ExpressionDataDoubleMatrix baseChannel) {
    Double min = Double.MAX_VALUE;
    Double max = Double.MIN_VALUE;
    for (ExpressionDataMatrixRowElement element : baseChannel.getRowElements()) {
        CompositeSequence designElement = element.getDesignElement();
        int numCols = preferred.columns(designElement);
        for (int col = 0; col < numCols; col++) {
            Double[] signalA = null;
            if (signalChannelA != null) {
                signalA = signalChannelA.getRow(designElement);
            }
            Double[] signalB = null;
            if (signalChannelB != null) {
                signalB = signalChannelB.getRow(designElement);
            }
            Double sigAV = (signalA == null || signalA[col] == null) ? Double.NaN : signalA[col];
            Double sigBV = (signalB == null || signalB[col] == null) ? Double.NaN : signalB[col];
            if (!sigAV.isNaN() && sigAV < min) {
                min = sigAV;
            } else if (!sigBV.isNaN() && sigBV < min) {
                min = sigBV;
            } else if (!sigAV.isNaN() && sigAV > max) {
                max = sigAV;
            } else if (!sigBV.isNaN() && sigBV > max) {
                max = sigBV;
            }
        }
    }
    Histogram h = new Histogram("range", 100, min, max);
    for (ExpressionDataMatrixRowElement element : baseChannel.getRowElements()) {
        CompositeSequence designElement = element.getDesignElement();
        int numCols = preferred.columns(designElement);
        for (int col = 0; col < numCols; col++) {
            Double[] signalA = null;
            if (signalChannelA != null) {
                signalA = signalChannelA.getRow(designElement);
            }
            Double[] signalB = null;
            if (signalChannelB != null) {
                signalB = signalChannelB.getRow(designElement);
            }
            Double sigAV = (signalA == null || signalA[col] == null) ? Double.NaN : signalA[col];
            Double sigBV = (signalB == null || signalB[col] == null) ? Double.NaN : signalB[col];
            if (!sigAV.isNaN())
                h.fill(sigAV);
            if (!sigBV.isNaN())
                h.fill(sigBV);
        }
    }
    Double thresh = h.getApproximateQuantile(TwoChannelMissingValuesImpl.QUANTILE_OF_SIGNAL_TO_USE_IF_NO_BKG_AVAILABLE);
    TwoChannelMissingValuesImpl.log.info("Threshold based on signal=" + thresh);
    return thresh;
}
Also used : ExpressionDataMatrixRowElement(ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement) Histogram(ubic.basecode.math.distribution.Histogram) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Aggregations

ExpressionDataMatrixRowElement (ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixRowElement)8 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)2 Gene (ubic.gemma.model.genome.Gene)2 HashSet (java.util.HashSet)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)1 Histogram (ubic.basecode.math.distribution.Histogram)1 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)1 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)1