0
|
1 #!/usr/bin/R
|
|
2
|
|
3 # R script to call Vennerable package from galaxy
|
|
4 # info: alex.bossers@wur.nl
|
1
|
5 #
|
|
6 # version:
|
|
7 # 2015-04-21 fixed <NA> values bug
|
|
8 # .......... Initial version
|
|
9 #
|
0
|
10
|
|
11 # R --slave --vanilla --file=PlotBar.R --args inputFile x_data weighting outputFile plottype resolution imagetype
|
|
12 # 1 2 3 4 5 6 7 8 9 10 11 12
|
|
13
|
|
14 #get cmd line args
|
|
15 args <- commandArgs()
|
1
|
16 in.file <- args[6]
|
|
17 xData <- args[7] # data labels xData of format "a, b, c" and can include spaces
|
|
18 weighting <- args[8]
|
|
19 out.file <- args[9]
|
|
20 plottype <- args[10]
|
|
21 resolution <- args[11] # in dpi
|
|
22 imagetype <- args[12] # svg, pdf or png
|
0
|
23
|
|
24 #open lib
|
|
25 library(Vennerable)
|
|
26 options(bitmapType='cairo')
|
|
27
|
|
28 # for labels of bars or bar groups presume column names from data
|
|
29 if (xData != "default") {
|
|
30 # read without header input file (must be tabular)
|
1
|
31 a_data <- read.delim(in.file, header=F, na.strings="") # replace empty by <NA> for TAB delimited file
|
|
32 colnames (a_data) <- strsplit(xData,",")[[1]] # insert headers from galaxy input
|
|
33 annot_data <- lapply(a_data, na.omit) # remove empty values for counting
|
0
|
34 Vannot <- Venn(annot_data)
|
|
35 } else {
|
1
|
36 # read with header input file (must be tabular)
|
|
37 a_data <- read.delim(in.file, na.strings="") # replace any empty values by <NA> for AB delimited headered file
|
|
38 annot_data <- lapply(a_data, na.omit) # remove empty values for counting
|
0
|
39 Vannot <- Venn(annot_data)
|
|
40 }
|
|
41
|
|
42 #set output imagetype (svg pdf or png)
|
|
43 #R 3.0.2 and default cairo libs should handle it all ok
|
|
44 #it could be that X11 should be loaded for non-pdf
|
|
45 if (imagetype == "svg") {
|
1
|
46 svg(out.file)
|
0
|
47 } else if (imagetype == "png") {
|
1
|
48 png(out.file, width = 1600, height = 1600, res = resolution)
|
0
|
49 } else {
|
1
|
50 pdf(out.file)
|
0
|
51 }
|
|
52
|
|
53 # plot it
|
|
54 if (plottype == "ChowRuskey") {
|
|
55 plot(Vannot, type = plottype)
|
1
|
56
|
0
|
57 } else if (plottype == "AWFE") {
|
|
58 plot(Vannot, doWeights = weighting, type = plottype)
|
1
|
59
|
0
|
60 } else if (plottype == "circles") {
|
|
61 plot(Vannot)
|
1
|
62
|
0
|
63 } else if (plottype == "ellipses"){
|
|
64 plot(Vannot, type = "ellipses")
|
1
|
65
|
0
|
66 } else if (plottype == "squares"){
|
|
67 plot(Vannot, type = "squares")
|
1
|
68
|
0
|
69 } else if (plottype == "battle"){
|
1
|
70 plot(Vannot, type = "battle")
|
0
|
71 }
|
|
72
|
1
|
73 cat ("Wrapper version 1.2c (empty value bug fixed), running Vennerable v3.0-82\n Info/bugs: alex.bossers@wur.nl\n")
|
|
74 dev.off() |