Matrix2png
From Christoph's Personal Wiki
- The correct title of this article is matrix2png. The initial letter is capitalized due to technical restrictions.
matrix2png is a simple but powerful programme for making visualizations of microarray data and many other data types. It generates PNG formatted images from text files of data. It is fast, easy to use, and reasonably flexible. It can be used to generate publication-quality images, or to act as a image generator for web applications. It is useful for imaging all kinds of matrix-based data, not just microarray data. Matrix2png is open source.
The current version of matrix2png is 1.2.2 (February 2012).
Usage
see: here for detailed usage and examples.
-data <file>
- (required)
-desctext <file>
- (optional)
-range
- values assigned to mincolor and maxcolor as min:max (default is data range)
-con
- contrast (default = 1.0; applies only when not using -range option)
-size
- pixel dimensions per value as x:y (default = 2:2)
-numcolors
- number of colours (default = 64)
-minsize
- minimum image size as x:y pixels
-mincolor
- colour used at lowest value (name or r:g:b triplet) (default = blue)
-maxcolor
- colour used at highest value (name or r:g:b triplet) (default = red)
-bkgcolor
- colour used as background (name or r:g:b triplet) (default = white)
-missingcolor
- colour used for missing values (name or r:g:b triplet) (default = grey)
-map
- colour choices from preset maps: overrides min/max colours and -b (default = 0 (none))
-discrete
- Use discretized mapping of values to colors; use -dmap to assign a mapping file
-dmap <mapping file>
- Discrete colour mapping file to use for discrete mapping (default = preset)
-numr
- Number of rows to process starting from the top of the matrix by default
-numc
- Number of columns to process starting from the left edge of the matrix by default
-startrow
- Index of the first row to be processed; can combine with numr (default=1)
-startcol
- Index of the first column to be processed; can combine with numc (default=1)
-trim
- Trim this percent of data extremes when determining data range (only without the -range option)
-verbose
- Verbosity of the output
1|2|3|4|5
(default=2) -title <title>
- Add a title
-z
- Row-normalize the data to mean 0 and variance 1
-b
- Middle of colour range is black
-d
- Add cell dividers
-s
- Add scale bar
-r
- Add row names
-c
- Add column names
-f
- Data file has a format line
-e
- Draw ellipses instead of rectangles
-l
- Log transform the data (base 2)
Example
If, for an example, you have a matrix file ('foo.mat
') that has something like the following matrix:
foo A1 A2 A3 B1 4 3 9 B2 3 2 1 B3 7 5 8
Note: All entries must be tab delimited.
You can convert this to a PNG like so:
matrix2png -data foo.mat -size 18:18 -mincolor darkred -maxcolor white -c -r -s -con 1.0 >foo.png
Example with Gnuplot
Note: There should be no field names in the rows or columns.
set palette rgbformula 7,-2,7 p 'foo.mat' matrix u 1:(-$2):3 w image
Documentation
-mincolor <value>
- (ignored if using "
-map
"),-maxcolor
(ignored if using "-map
"),-bkgcolor
: The colors which are used for the image scale. The smallest value in the image (or values less than or equal to theminvalue
) are represented bymincolor
, same idea formaxcolor
. The background color is used for areas of the image not covered by the matrix data - which means that you may not see the background color at all. Colors can be selected by name or byred:green:blue
triplets (values ranging from 0 to 255). Thus pure red is indicated by255:0:0
while medium grey would be128:128:128
. Colors which can be selected by name are:- red, darkred, blue, darkblue, green, darkgreen, yellow, magenta, cyan, black, white, grey (or gray), orange, violet
- Other colors are generated by interpolating between the min and max colors; by using color maps (below), you can use preset mappings that are more complex. (Defaults:
mincolor=blue; maxcolor=red; bkgcolor=white
.)
Reference
- Pavlidis P, Noble WS (2003). "Matrix2png: A Utility for Visualizing Matrix Data". Bioinformatics 19:295-296.
External links
- Official site
- Web interface to matrix2png
- ColorBrewer — colour schemes used in matrix2png