changeset 1:2d8c23e32839 default tip

2015-04-21 fixed <NA> values bug
author eric
date Wed, 22 Apr 2015 10:35:33 +0200
parents f21d51d28d8d
children
files vennerable/Vennerable.R vennerable/Vennerable.xml
diffstat 2 files changed, 30 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/vennerable/Vennerable.R	Tue Mar 31 13:18:31 2015 +0200
+++ b/vennerable/Vennerable.R	Wed Apr 22 10:35:33 2015 +0200
@@ -2,19 +2,24 @@
 
 # R script to call Vennerable package from galaxy
 # info: alex.bossers@wur.nl
+#
+# version:
+#   2015-04-21 fixed <NA> values bug
+#   .......... Initial version
+#
 
 # R --slave --vanilla --file=PlotBar.R --args inputFile x_data weighting outputFile plottype resolution imagetype
 # 1     2       3             4           5       6        7       8         9        10        11         12
 
 #get cmd line args
 args <- commandArgs()
-	in.file	<- args[6]
-	xData		<- args[7]   # data labels xData of format "a, b, c" and can include spaces
-	weighting	<- args[8] 
-	out.file	<- args[9]
-	plottype	<- args[10]
-	resolution	<- args[11] # in dpi
-	imagetype	<- args[12] # svg, pdf or png
+in.file <- args[6]
+xData       <- args[7]   # data labels xData of format "a, b, c" and can include spaces
+weighting   <- args[8]
+out.file    <- args[9]
+plottype    <- args[10]
+resolution  <- args[11] # in dpi
+imagetype   <- args[12] # svg, pdf or png
 
 #open lib
 library(Vennerable)
@@ -23,12 +28,14 @@
 # for labels of bars or bar groups presume column names from data
 if (xData != "default") {
 	# read without header input file (must be tabular)
-	annot_data <- read.table(in.file, header=F, sep="\t")
-	colnames (annot_data) <- strsplit(xData,",")[[1]]
+	a_data <- read.delim(in.file, header=F, na.strings="")      # replace empty by <NA> for TAB delimited file
+	colnames (a_data) <- strsplit(xData,",")[[1]]               # insert headers from galaxy input
+	annot_data <- lapply(a_data, na.omit)                       # remove empty values for counting
 	Vannot <- Venn(annot_data)
 } else {
-	# read without header input file (must be tabular)
-	annot_data <- read.table(in.file, header=T, sep="\t")
+	# read with header input file (must be tabular)
+	a_data <- read.delim(in.file, na.strings="")                # replace any empty values by <NA> for AB delimited headered file
+	annot_data <- lapply(a_data, na.omit)                       # remove empty values for counting
 	Vannot <- Venn(annot_data)
 }
 
@@ -36,32 +43,32 @@
 #R 3.0.2 and default cairo libs should handle it all ok
 #it could be that X11 should be loaded for non-pdf
 if (imagetype == "svg") {
-    svg(out.file)
+	svg(out.file)
 } else if (imagetype == "png") {
-    png(out.file, width = 1600, height = 1600, res = resolution)
+	png(out.file, width = 1600, height = 1600, res = resolution)
 } else {
-    pdf(out.file)
+	pdf(out.file)
 }
 
 # plot it
 if (plottype == "ChowRuskey") {
 	plot(Vannot, type = plottype)
-
+	
 } else if (plottype == "AWFE") {
 	plot(Vannot, doWeights = weighting, type = plottype)
-
+	
 } else if (plottype == "circles") {
 	plot(Vannot)
-
+	
 } else if (plottype == "ellipses"){
 	plot(Vannot, type = "ellipses")
-
+	
 } else if (plottype == "squares"){
 	plot(Vannot, type = "squares")
-
+	
 } else if (plottype == "battle"){
-        plot(Vannot, type = "battle")
+	plot(Vannot, type = "battle")
 }
 
-cat ("Wrapper version 1.2, running Vennerable v3.0-82\n Info/bugs: alex.bossers@wur.nl\n")
-dev.off()
+cat ("Wrapper version 1.2c (empty value bug fixed), running Vennerable v3.0-82\n Info/bugs: alex.bossers@wur.nl\n")
+dev.off()
\ No newline at end of file
--- a/vennerable/Vennerable.xml	Tue Mar 31 13:18:31 2015 +0200
+++ b/vennerable/Vennerable.xml	Wed Apr 22 10:35:33 2015 +0200
@@ -115,7 +115,7 @@
 
 **Example**
 
-.. image:: ../static/images/WURtools/VennerablePlot.png 
+.. image:: VennerablePlot.png 
 
 -----