Class ExpressionDataDoubleMatrixUtil
- java.lang.Object
-
- ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrixUtil
-
public class ExpressionDataDoubleMatrixUtil extends Object
Perform various computations on ExpressionDataMatrices (usually in-place).- Author:
- pavlidis
-
-
Constructor Summary
Constructors Constructor Description ExpressionDataDoubleMatrixUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addMatrices(ExpressionDataDoubleMatrix a, ExpressionDataDoubleMatrix b)
Add two matrices.static void
detectSuspiciousValues(ExpressionDataDoubleMatrix a, QuantitationType qt)
Detect suspicious values for a given quantitation type.static ExpressionDataDoubleMatrix
ensureLog2Scale(ExpressionDataDoubleMatrix expressionData)
static ExpressionDataDoubleMatrix
ensureLog2Scale(ExpressionDataDoubleMatrix dmatrix, boolean ignoreQuantitationMismatch)
Ensures that the given matrix is on a Log2 scale.static ExpressionDataDoubleMatrix
filterAndLog2Transform(ExpressionDataDoubleMatrix dmatrix)
Log2 transform if necessary, do any required filtering prior to analysis.static QuantitationType
inferQuantitationType(ExpressionDataDoubleMatrix expressionDataDoubleMatrix)
Infer aQuantitationType
from expression data.static void
logTransformMatrix(ExpressionDataDoubleMatrix matrix)
Log-transform the values in the matrix (base 2).static void
maskMatrix(ExpressionDataDoubleMatrix matrix, ExpressionDataBooleanMatrix mask)
Use the mask matrix to turn some values in a matrix to NaN.static void
scalarDivideMatrix(ExpressionDataDoubleMatrix matrix, double dividend)
Divide all values by the dividendstatic void
subtractMatrices(ExpressionDataDoubleMatrix a, ExpressionDataDoubleMatrix b)
Subtract two matrices.
-
-
-
Method Detail
-
filterAndLog2Transform
public static ExpressionDataDoubleMatrix filterAndLog2Transform(ExpressionDataDoubleMatrix dmatrix)
Log2 transform if necessary, do any required filtering prior to analysis. Count data is converted to log2CPM (but we store log2cpm as the processed data, so that is what would generally be used).- Parameters:
dmatrix
- matrix- Returns:
- ee data double matrix
-
ensureLog2Scale
@CheckReturnValue public static ExpressionDataDoubleMatrix ensureLog2Scale(ExpressionDataDoubleMatrix dmatrix, boolean ignoreQuantitationMismatch) throws QuantitationMismatchException
Ensures that the given matrix is on a Log2 scale. ! Does not update the QT !- Parameters:
dmatrix
- the matrix to be transformed to a log2 scale if necessary.ignoreQuantitationMismatch
- if true, ignore mismatch between matrix quantitation types and that inferred from data- Returns:
- a data matrix that is guaranteed to be on a log2 scale or the original input matrix if it was already the case
- Throws:
QuantitationTypeConversionException
- if transformation to log2 scale is impossibleInferredQuantitationMismatchException
- if the inferred scale type differs that inferred from dataQuantitationMismatchException
-
ensureLog2Scale
public static ExpressionDataDoubleMatrix ensureLog2Scale(ExpressionDataDoubleMatrix expressionData)
-
inferQuantitationType
public static QuantitationType inferQuantitationType(ExpressionDataDoubleMatrix expressionDataDoubleMatrix)
Infer aQuantitationType
from expression data.
-
detectSuspiciousValues
public static void detectSuspiciousValues(ExpressionDataDoubleMatrix a, QuantitationType qt) throws SuspiciousValuesForQuantitationException
Detect suspicious values for a given quantitation type.- Throws:
SuspiciousValuesForQuantitationException
- if there are any suspicious values
-
subtractMatrices
public static void subtractMatrices(ExpressionDataDoubleMatrix a, ExpressionDataDoubleMatrix b)
Subtract two matrices. Ideally, they matrices are conformant, but if they are not (as some rows are sometimes missing for some quantitation types), this method attempts to handle it anyway (see below). The rows and columns do not have to be in the same order, but they do have to have the same column keys and row keys (with the exception of missing rows). The result is stored in a. (a - b). If the number of rows are not the same, and/or the rows have different keys in the two matrices, some rows will simply not get subtracted and a warning will be issued.- Parameters:
a
- matrix ab
- matrix b- Throws:
IllegalArgumentException
- if the matrices are not column-conformant.
-
logTransformMatrix
public static void logTransformMatrix(ExpressionDataDoubleMatrix matrix)
Log-transform the values in the matrix (base 2). Non-positive values (which have no logarithm defined) are entered as NaN.- Parameters:
matrix
- matrix
-
addMatrices
public static void addMatrices(ExpressionDataDoubleMatrix a, ExpressionDataDoubleMatrix b)
Add two matrices. Ideally, they matrices are conformant, but if they are not (as some rows are sometimes missing for some quantitation types), this method attempts to handle it anyway (see below). The rows and columns do not have to be in the same order, but they do have to have the same column keys and row keys (with the exception of missing rows). The result is stored in a. If the number of rows are not the same, and/or the rows have different keys in the two matrices, some rows will simply not get added and a warning will be issued.- Parameters:
a
- matrix ab
- matrix b- Throws:
IllegalArgumentException
- if the matrices are not column-conformant.
-
scalarDivideMatrix
public static void scalarDivideMatrix(ExpressionDataDoubleMatrix matrix, double dividend)
Divide all values by the dividend- Parameters:
matrix
- matrixdividend
- dividend- Throws:
IllegalArgumentException
- if dividend == 0.
-
maskMatrix
public static void maskMatrix(ExpressionDataDoubleMatrix matrix, ExpressionDataBooleanMatrix mask)
Use the mask matrix to turn some values in a matrix to NaN. Ideally, they matrices are conformant, but if they are not (as some rows are sometimes missing for some quantitation types), this method attempts to handle it anyway (see below). The rows and columns do not have to be in the same order, but they do have to have the same column keys and row keys (with the exception of missing rows). The result is stored in matrix.- Parameters:
matrix
- matrixmask
- if null, masking is not attempted.
-
-