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;
}
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);
}
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;
}
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");
}
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;
}
Aggregations