Package ubic.basecode.graphics
Class ColorMatrix<A,B>
java.lang.Object
ubic.basecode.graphics.ColorMatrix<A,B>
- All Implemented Interfaces:
Cloneable
Creates a color matrix from a matrix of doubles
- Author:
- Will Braynen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color[]
protected Color[][]
protected double
protected double
Min and max values to display, which might not be the actual min and max values in the matrix.protected DoubleMatrixReader
protected int[]
to be able to sort the rows by an arbitrary keyprotected int
protected int
protected double
protected DoubleMatrix
<A, B> protected double
protected Color
-
Constructor Summary
ConstructorsConstructorDescriptionColorMatrix
(DoubleMatrix<A, B> matrix) ColorMatrix
(DoubleMatrix<A, B> matrix, Color[] colorMap, Color missingColor) -
Method Summary
Modifier and TypeMethodDescriptionclone()
protected int[]
To be able to sort the rows by an arbitrary key.getColor
(int row, int column) Color[]
Color[][]
int
getColumnName
(int column) String[]
double
double
double
getMax()
double
getMin()
double[]
getRow
(int row) double[]
getRowByName
(A rowName) int
int
getRowIndexByName
(A rowName) getRowName
(int row) String[]
protected int
getTrueRowIndex
(int row) double
getValue
(int row, int column) void
static <R,
C> ColorMatrix <R, C> newInstance
(DoubleMatrix<R, C> matrix) void
void
void
setColorMap
(Color[] colorMap) void
setDisplayRange
(double min, double max) Standardized display rangeprotected void
setRow
(int row, double[] values) Changes values in a row, clipping if there are more values than columns.void
setRowKeys
(int[] rowKeys) void
Normalizes the elements of a matrix to variance one and mean zero, ignoring missing values todo move this to matrixstats or something.
-
Field Details
-
colorMap
-
colors
-
displayMax
protected double displayMax -
displayMin
protected double displayMinMin and max values to display, which might not be the actual min and max values in the matrix. For instance, we might want to clip values, or show a bigger color range for equal comparison with other rows or matrices. -
m_matrixReader
-
m_rowKeys
protected int[] m_rowKeysto be able to sort the rows by an arbitrary key -
m_totalRows
protected int m_totalRows -
m_totalColumns
protected int m_totalColumns -
max
protected double max -
maxtrix
-
min
protected double min -
missingColor
-
-
Constructor Details
-
ColorMatrix
-
ColorMatrix
- Parameters:
matrix
- the matrixcolorMap
- the simplest color map is one with just two colors: { minColor, maxColor }missingColor
- values missing from the matrix or non-numeric entries will be displayed using this color
-
-
Method Details
-
newInstance
-
clone
-
getColor
- Throws:
ArrayIndexOutOfBoundsException
-
getColorMap
-
getColors
-
getColumnCount
public int getColumnCount() -
getColumnName
- Throws:
ArrayIndexOutOfBoundsException
-
getColumnNames
-
getDisplayMax
public double getDisplayMax() -
getDisplayMin
public double getDisplayMin() -
getMatrix
- Returns:
- a DenseDoubleMatrix2DNamed object
-
getMax
public double getMax() -
getMaxtrix
-
getMin
public double getMin() -
getMissingColor
-
getRow
- Throws:
ArrayIndexOutOfBoundsException
-
getRowByName
-
getRowCount
public int getRowCount() -
getRowIndexByName
-
getRowName
- Throws:
ArrayIndexOutOfBoundsException
-
getRowNames
-
getValue
- Throws:
ArrayIndexOutOfBoundsException
-
mapValuesToColors
public void mapValuesToColors() -
resetRowKeys
public void resetRowKeys() -
setColor
- Parameters:
row
-column
-newColor
-- Throws:
ArrayIndexOutOfBoundsException
-
setColorMap
- Parameters:
colorMap
- an array of colors which define the midpoints in the color map; this can be one of the constants defined in the ColorMap class, like ColorMap.REDGREEN_COLORMAP and ColorMap.BLACKBODY_COLORMAP- Throws:
IllegalArgumentException
- if the colorMap array argument contains less than two colors.
-
setDisplayRange
public void setDisplayRange(double min, double max) Standardized display range -
setRowKeys
public void setRowKeys(int[] rowKeys) - Parameters:
rowKeys
-
-
standardize
public void standardize()Normalizes the elements of a matrix to variance one and mean zero, ignoring missing values todo move this to matrixstats or something. -
createRowKeys
protected int[] createRowKeys()To be able to sort the rows by an arbitrary key. Createsm_rowKeys
array and initializes it in ascending order from 0 tom_totalRows
-1, so that by default it matches the physical order of the columns: [0,1,2,...,m_totalRows-1]- Returns:
- int[]
-
getTrueRowIndex
protected int getTrueRowIndex(int row) -
setRow
protected void setRow(int row, double[] values) Changes values in a row, clipping if there are more values than columns.- Parameters:
row
- row whose values we want to changevalues
- new row values
-