comparison plot_barplot.R @ 0:de039abf9641 draft

planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/plot_barplot commit ec57288980629acd7768b28d1fbc94fc12f23561-dirty
author bebatut
date Tue, 23 Feb 2016 05:17:12 -0500
parents
children f8cec112f5f9
comparison
equal deleted inserted replaced
-1:000000000000 0:de039abf9641
1 library('getopt')
2
3 option_specification = matrix(c(
4 'input_file', 'i', 2, 'character',
5 'output_pdf_file', 'p', 2, 'character',
6 'output_png_file', 'o', 2, 'character',
7 'output_svg_file', 's', 2, 'character',
8 'data_column', 'd', 2, 'integer',
9 'names_column', 'n', 2, 'integer',
10 'xlab', 'x', 2, 'character',
11 'col', 'c', 2, 'character',
12 'bottom_margin', 'b', 2, 'integer',
13 'left_margin', 'l', 2, 'integer',
14 'top_margin', 't', 2, 'integer',
15 'right_margin', 'r', 2, 'integer'
16 ), byrow=TRUE, ncol=4);
17
18 options = getopt(option_specification);
19
20 data = read.table(options$input_file, sep = '\t', h = T)
21
22 data_column = 2
23 if(!is.null(options$data_column)) data_column = options$data_column
24 names_column = 1
25 if(!is.null(options$names_column)) names_column = options$names_column
26
27 margin = c(5,19,1,1)
28 if(!is.null(options$bottom_margin)) margin[1] = options$bottom_margin
29 if(!is.null(options$left_margin)) margin[2] = options$left_margin
30 if(!is.null(options$top_margin)) margin[3] = options$top_margin
31 if(!is.null(options$right_margin)) margin[4] = options$right_margin
32
33 xlab = ""
34 if(!is.null(options$xlab)) xlab = options$xlab
35
36 col = "grey"
37 if(!is.null(options$col)) col = options$col
38
39 plot_barplot <- function(){
40 par(las=2)
41 par(mar=margin)
42 barplot(data[, data_column], horiz = T, xlab = xlab,
43 names.arg = data[, names_column], col = col, cex.names=0.7,
44 cex.axis = 0.8)
45 }
46
47 if(!is.null(options$output_pdf_file)){
48 pdf(options$output_pdf_file)
49 plot_barplot()
50 dev.off()
51 }
52
53 if(!is.null(options$output_svg_file)){
54 svg(options$output_svg_file)
55 plot_barplot()
56 dev.off()
57 }