From Biowerkzeug Wiki
Jump to: navigation, search

rpy is a python interface to the statistics package R.

An example to plot a heat map, based on a very nice example of how to use R from python to draw a heat map from micro array data.

<python>from rpy import r import numpy data = numpy.random.randn(100,30) # fake data

r.X11() # use windowing system X11 r.heatmap(a) </python>

File:Hm gauss2.png
Example heat map from a Gaussian (mean=0, sd=1) 100x30 matrix of fake data.

Using an appropriate output device (pdf, png, ...) one can directly produce publication-quality images: <python>r.library('gplots') # loads a library for heatmap.2 r.pdf('hm_gauss2.pdf') # output to file r.heatmap_2(a,col=r.topo_colors(100),trace="none") # plot heatmap r.dev_off() # close file output </python>