changeset 1:643e309dcd11 draft

Uploaded
author moheydarian
date Mon, 13 Mar 2017 10:52:22 -0400
parents 25701d50da89
children 29110e59067f
files cast.R
diffstat 1 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cast.R	Mon Mar 13 10:52:22 2017 -0400
@@ -0,0 +1,34 @@
+# Setup R error handling to go to stderr
+options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)})
+
+# We need to not crash galaxy with an UTF8 error on German LC settings.
+loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
+
+
+# Import library
+library("getopt")
+library("reshape2")
+options(stringAsfactors = FALSE, useFancyQuotes = FALSE)
+# Take in trailing command line arguments
+args <- commandArgs(trailingOnly = TRUE)
+
+
+# get options, using the spec as defined by the enclosed list.
+# we read the options from the default: commandArgs(TRUE).
+option_specification = matrix(c(
+  'input', 'i', 2, 'character',
+  'output', 'o', 2, 'character'
+  ), byrow=TRUE, ncol=4);
+
+# Parse options
+options = getopt(option_specification);
+
+
+
+# Print options to see what is going on
+cat("\n input: ",options$input)
+cat("\n output: ",options$output)
+
+input <- read.csv(options$input,sep='\t',header=TRUE)
+cinput <- cast(input, ... ~ variable)
+write.table(cinput, "output.tabular", sep="\t", quote=FALSE, row.names=FALSE)