diff plot_rna.R @ 10:33e625bef2b9 draft

Uploaded
author nikos
date Wed, 05 Nov 2014 09:09:03 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plot_rna.R	Wed Nov 05 09:09:03 2014 -0500
@@ -0,0 +1,41 @@
+#Setup R error handling to go to stderr
+options( show.error.messages = FALSE, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
+
+# we need that to not crash galaxy with an UTF8 error on German LC settings.
+Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
+
+suppressMessages(library('getopt'))
+
+#get options, using the spec as defined by the enclosed list.
+#we read the options from the default: commandArgs(TRUE).
+spec = matrix(c(
+    'help' , 'h', 0, "logical",
+    'input', 'i', 1, "character",
+    'transcript', 't', 1, "character",
+    'method', 'm', 2, "character",
+    'cutoff', 'c', 2, "double",
+    'type', 'p', 2, "character",
+    'output', 'o', 1, "character"
+), byrow=TRUE, ncol=4);
+
+opt = getopt(spec);
+
+suppressMessages(require(RNAprobR))
+
+#Read and convert input to GRanges object
+data <- read.table(opt$input, header = TRUE)
+dataGR <- norm_df2GR(data)
+
+#Check if given transcript exists in input file
+if ( ! opt$transcript %in% data$RNAid ) { stop("Transript not found. Check input file.") }
+
+pdf(opt$output)
+for (method in strsplit(opt$method, ",")[[1]] ) {
+
+    #Check if columns exists in data file
+    if (! method %in% colnames(data)) { next } 
+
+    plotRNA(dataGR, opt$transcript, method, stat_cutoff = opt$cutoff, type = opt$type,
+        main=paste(opt$transcript,": ", method, sep=""))
+}
+dev.off()