Rpy: Difference between revisions
From Biowerkzeug Wiki
Jump to navigationJump to search
from Woolf Wiki |
mNo edit summary |
||
Line 22: | Line 22: | ||
r.dev_off() # close file output | r.dev_off() # close file output | ||
</python> | </python> | ||
[[Category:Analysis]] | |||
[[Category:Statistics]] | |||
[[Category:Python]] |
Latest revision as of 19:42, 30 June 2008
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>
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>