# HG changeset patch # User bebatut # Date 1460988505 14400 # Node ID 6c9aac0d6ca24f27167198d719fa48b3cd08f085 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/plot_grouped_barplot commit c6ba903395dc6d41cb318c7d95a2d9cf3ca65313-dirty diff -r 000000000000 -r 6c9aac0d6ca2 plot_grouped_barplot.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot_grouped_barplot.R Mon Apr 18 10:08:25 2016 -0400 @@ -0,0 +1,87 @@ +library('getopt') + +option_specification = matrix(c( + 'input_file', 'i', 2, 'character', + 'output_pdf_file', 'p', 2, 'character', + 'output_png_file', 'o', 2, 'character', + 'output_svg_file', 's', 2, 'character', + 'data_columns', 'd', 2, 'list', + 'names', 'a', 2, 'character', + 'names_column', 'n', 2, 'integer', + 'xlab', 'x', 2, 'character', + 'log', 'g', 2, 'logical', + 'col', 'c', 2, 'list', + 'bottom_margin', 'b', 2, 'integer', + 'left_margin', 'l', 2, 'integer', + 'top_margin', 't', 2, 'integer', + 'right_margin', 'r', 2, 'integer', + 'legend_pos','e',2,'character', + 'replace_null','u',2,'logical', + 'order','w',2,'logical', + 'header','y',2,'logical' +), byrow=TRUE, ncol=4); + +options = getopt(option_specification); + +header = TRUE +if(!is.null(options$header)) header = options$header + +data = read.table(options$input_file, sep = '\t', h = header) +if(!is.null(options$replace_null) && options$replace_null){ + data[data == 0] = NA +} +if(!is.null(options$order) && options$order){ + order = order(data[,2]) + data = data[order,] +} + + +data_columns = c(2,3) +if(!is.null(options$data_columns)){ + data_columns = unlist(strsplit(options$data_columns, split=",")) + data_columns = sapply(data_columns,as.integer) + } +names_column = 1 +if(!is.null(options$names_column)) names_column = options$names_column + +margin = c(5,19,1,1) +if(!is.null(options$bottom_margin)) margin[1] = options$bottom_margin +if(!is.null(options$left_margin)) margin[2] = options$left_margin +if(!is.null(options$top_margin)) margin[3] = options$top_margin +if(!is.null(options$right_margin)) margin[4] = options$right_margin + +xlab = "" +if(!is.null(options$xlab)) xlab = options$xlab + +col = c('blue','red') +if(!is.null(options$col)) col = unlist(strsplit(options$col, split=",")) + +log = "" +if(!is.null(options$log) && options$log) log = "x" + +legend_pos="topright" +if(!is.null(options$legend_pos)) legend_pos = options$legend_pos + +names = c('Sample1','Sample2') + +if(!is.null(options$names)) names = unlist(strsplit(options$names, split=",")) +plot_barplot <- function(){ + par(las=2) + par(mar=margin) + barplot(t(data[, data_columns]), horiz = T, xlab = xlab, beside=TRUE, + names.arg = data[, names_column], col = col, cex.names=0.7, + cex.axis = 0.8, log = log) + legend(legend_pos, legend = names, fill = col, cex = 0.7) +} + +if(!is.null(options$output_pdf_file)){ + pdf(options$output_pdf_file) + plot_barplot() + dev.off() +} + +if(!is.null(options$output_svg_file)){ + svg(options$output_svg_file) + plot_barplot() + dev.off() +} \ No newline at end of file diff -r 000000000000 -r 6c9aac0d6ca2 plot_grouped_barplot.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot_grouped_barplot.xml Mon Apr 18 10:08:25 2016 -0400 @@ -0,0 +1,145 @@ + + with R + + + R + r-getopt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + output_format=="pdf" + + + output_format=="png" + + + output_format=="svg" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 000000000000 -r 6c9aac0d6ca2 static/images/output.pdf Binary file static/images/output.pdf has changed diff -r 000000000000 -r 6c9aac0d6ca2 static/images/output.png Binary file static/images/output.png has changed diff -r 000000000000 -r 6c9aac0d6ca2 test-data/input_file.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/input_file.txt Mon Apr 18 10:08:25 2016 -0400 @@ -0,0 +1,18 @@ +Replication initiation protein, truncated 0.195633 0.0431745 +Resolvase, putative 0.00060098 0.183306 +UniRef50_Q8CU99 0.173071 0.0296448 +Integrase 0.303569 0.0580151 +Replication initiation protein 0.857353 0.165635 +UniRef50_Z6ILY0 0.202075 0.0208634 +UniRef50_W1W6K4 0.248059 0.0318689 +UniRef50_F0RR64 0.000754535 0.152705 +Tetracycline resistance protein 0.51126 0.101236 +Plasmid recombination enzyme 0.214064 0.0334602 +Transposase, putative 0.00200612 0.562101 +putative transposase 0.000927295 0.113753 +Plasmid recombination enzyme type 3 0.660463 0.123898 +Toxin antitoxin system, antitoxin component 0 0.142345 +Transposase IS4 family protein 0.00381025 0.4416 +hypothetical protein DR_1761 0.00032663 0.185976 +UniRef50_Q9RV33 0.000328875 0.144057 +Rep 0.365541 0.06664 diff -r 000000000000 -r 6c9aac0d6ca2 test-data/output_file.pdf Binary file test-data/output_file.pdf has changed diff -r 000000000000 -r 6c9aac0d6ca2 tool_dependencies.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_dependencies.xml Mon Apr 18 10:08:25 2016 -0400 @@ -0,0 +1,9 @@ + + + + + + + + +