annotate vennerable/Vennerable.R @ 0:f21d51d28d8d

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