Mercurial > repos > kuyt002 > vennerable_r
comparison vennerable/Vennerable.R @ 0:77bbf955e8de default tip
initial commit
author | eric |
---|---|
date | Thu, 06 Nov 2014 15:07:54 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:77bbf955e8de |
---|---|
1 #!/usr/bin/R | |
2 | |
3 # R script to call Vennerable package from galaxy | |
4 # info: alex.bossers@wur.nl | |
5 | |
6 # R --slave --vanilla --file=PlotBar.R --args inputFile x_data weighting outputFile plottype resolution imagetype | |
7 # 1 2 3 4 5 6 7 8 9 10 11 12 | |
8 | |
9 #get cmd line args | |
10 args <- commandArgs() | |
11 in.file <- args[6] | |
12 xData <- args[7] # data labels xData of format "a, b, c" and can include spaces | |
13 weighting <- args[8] | |
14 out.file <- args[9] | |
15 plottype <- args[10] | |
16 resolution <- args[11] # in dpi | |
17 imagetype <- args[12] # svg, pdf or png | |
18 | |
19 #open lib | |
20 library(Vennerable) | |
21 options(bitmapType='cairo') | |
22 | |
23 # for labels of bars or bar groups presume column names from data | |
24 if (xData != "default") { | |
25 # read without header input file (must be tabular) | |
26 annot_data <- read.table(in.file, header=F, sep="\t") | |
27 colnames (annot_data) <- strsplit(xData,",")[[1]] | |
28 Vannot <- Venn(annot_data) | |
29 } else { | |
30 # read without header input file (must be tabular) | |
31 annot_data <- read.table(in.file, header=T, sep="\t") | |
32 Vannot <- Venn(annot_data) | |
33 } | |
34 | |
35 #set output imagetype (svg pdf or png) | |
36 #R 3.0.2 and default cairo libs should handle it all ok | |
37 #it could be that X11 should be loaded for non-pdf | |
38 if (imagetype == "svg") { | |
39 svg(out.file) | |
40 } else if (imagetype == "png") { | |
41 png(out.file, width = 1600, height = 1600, res = resolution) | |
42 } else { | |
43 pdf(out.file) | |
44 } | |
45 | |
46 # plot it | |
47 if (plottype == "ChowRuskey") { | |
48 plot(Vannot, type = plottype) | |
49 | |
50 } else if (plottype == "AWFE") { | |
51 plot(Vannot, doWeights = weighting, type = plottype) | |
52 | |
53 } else if (plottype == "circles") { | |
54 plot(Vannot) | |
55 | |
56 } else if (plottype == "ellipses"){ | |
57 plot(Vannot, type = "ellipses") | |
58 | |
59 } else if (plottype == "squares"){ | |
60 plot(Vannot, type = "squares") | |
61 | |
62 } else if (plottype == "battle"){ | |
63 plot(Vannot, type = "battle") | |
64 } | |
65 | |
66 cat ("Wrapper version 1.2, running Vennerable v3.0-82\n Info/bugs: alex.bossers@wur.nl\n") | |
67 dev.off() |