comparison scatterplot.py @ 1:b4102b163488 draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/scatterplot commit 1b68ca3d083c5879e996a9df5e22963dfc9c3f90-dirty
author mvdbeek
date Wed, 14 Sep 2016 12:42:56 -0400
parents 11627baf830e
children
comparison
equal deleted inserted replaced
0:11627baf830e 1:b4102b163488
2 # Greg Von Kuster 2 # Greg Von Kuster
3 3
4 import sys 4 import sys
5 5
6 from numpy import array 6 from numpy import array
7 from rpy import r 7 import rpy2.rpy_classic as rpy
8 from rpy2.robjects.numpy2ri import numpy2ri
9
10
11 rpy.set_default_mode(rpy.NO_CONVERSION)
12 r = rpy.r
8 13
9 14
10 def stop_err(msg): 15 def stop_err(msg):
11 sys.stderr.write(msg) 16 sys.stderr.write(msg)
12 sys.exit() 17 sys.exit()
63 if valid: 68 if valid:
64 matrix.append( row ) 69 matrix.append( row )
65 70
66 if skipped_lines < i: 71 if skipped_lines < i:
67 try: 72 try:
73 a = numpy2ri(array( matrix ))
68 r.pdf( out_fname, 8, 8 ) 74 r.pdf( out_fname, 8, 8 )
69 r.plot( array( matrix ), type="p", main=title, xlab=xlab, ylab=ylab, col="blue", pch=19 ) 75 r.plot( a, type="p", main=title, xlab=xlab, ylab=ylab, col="blue", pch=19 )
70 r.dev_off() 76 r.dev_off()
71 except Exception, exc: 77 except Exception, exc:
72 stop_err( "%s" % str( exc ) ) 78 stop_err( "%s" % str( exc ) )
73 else: 79 else:
74 stop_err( "All values in both columns %s and %s are non-numeric or empty." % ( sys.argv[3], sys.argv[4] ) ) 80 stop_err( "All values in both columns %s and %s are non-numeric or empty." % ( sys.argv[3], sys.argv[4] ) )
75 81
76 print "Scatter plot on columns %s, %s. " % ( sys.argv[3], sys.argv[4] ) 82 print "Scatter plot on columns %s, %s. " % ( sys.argv[3], sys.argv[4] )
77 if skipped_lines > 0: 83 if skipped_lines > 0:
78 print "Skipped %d lines starting with line #%d, value '%s' in column %d is not numeric." % ( skipped_lines, first_invalid_line, invalid_value, invalid_column ) 84 print "Skipped %d lines starting with line #%d, value '%s' in column %d is not numeric." % ( skipped_lines, first_invalid_line, invalid_value, invalid_column )
79 85
80 r.quit( save="no" )
81
82 if __name__ == "__main__": 86 if __name__ == "__main__":
83 main() 87 main()