diff masigpro.R @ 0:c8c290f3ea7d draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 5798bd978553dee97521c39920d263dd750e0755
author iuc
date Mon, 15 May 2017 07:29:03 -0400
parents
children cc96abdef027
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/masigpro.R	Mon May 15 07:29:03 2017 -0400
@@ -0,0 +1,104 @@
+#!/usr/bin/env Rscript
+
+# A command-line interface to maSigPro for use with Galaxy
+# written by Clemens Blank.
+# Thanks to Bjoern Gruening and Michael Love for their DESeq2
+# wrapper as a basis to build upon.
+
+# 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 that to not crash galaxy with an UTF8 error on German LC settings.
+loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
+
+suppressPackageStartupMessages({
+  library("maSigPro")
+  library("optparse")
+  library("mclust")
+})
+
+options(stringAsFactors = FALSE, useFancyQuotes = FALSE)
+args <- commandArgs(trailingOnly = TRUE)
+
+# specify our desired options in a list
+# by default OptionParser will add an help option equivalent to
+# make_option(c("-h", "--help"), action="store_true", default=FALSE,
+# help="Show this help message and exit")
+option_list <- list(
+ make_option(c("-q", "--quiet"), action="store_false",
+ dest="verbose", help="Print little output"),
+ make_option(c("-e", "--edesign"), type="character"),
+ make_option(c("-d", "--data"), type="character"),
+ make_option(c("-o", "--outfile"), type="character"),
+ make_option("--degree", type="integer", default=1),
+ make_option("--time_col", type="integer", default=1),
+ make_option("--repl_col", type="integer", default=2),
+ make_option("--qvalue", type="double", default=0.05),
+ make_option("--min_obs", type="integer", default=6),
+ make_option("--step_method", type="character", default="backward"),
+ make_option("--nvar_correction", type="logical", default=FALSE),
+ make_option("--alfa", type="double", default=0.05),
+ make_option("--rsq", type="double", default=0.7),
+ make_option("--vars", type="character", default="groups"),
+ make_option("--significant_intercept", type="character", default="dummy"),
+ make_option("--cluster_data", type="integer", default=1),
+ make_option(c("-k", "--k"), type="integer", default=9),
+ make_option("--cluster_method", type="character", default="hclust"),
+ make_option("--distance", type="character", default="cor"),
+ make_option("--agglo_method", type="character", default="ward.D"),
+ make_option("--iter_max", type="integer", default=500),
+ make_option("--color_mode", type="character", default="rainbow"),
+ make_option("--show_fit", type="logical", default=TRUE),
+ make_option("--show_lines", type="logical", default=TRUE),
+ make_option("--cexlab", type="double", default=0.8),
+ make_option("--legend", type="logical", default=TRUE)
+)
+
+# get command line options, if help option encountered print help and exit,
+# otherwise if options not found on command line then set defaults
+opt <- parse_args(OptionParser(option_list=option_list))
+
+# enforce the following required arguments
+if (is.null(opt$edesign)) {
+  cat("'edesign' is required\n")
+  q(status=1)
+}
+if (is.null(opt$data)) {
+  cat("'data' is required\n")
+  q(status=1)
+}
+if (is.null(opt$outfile)) {
+  cat("'outfile' is required\n")
+  q(status=1)
+}
+
+verbose <- if (is.null(opt$quiet)) {
+  TRUE
+} else {
+  FALSE
+}
+
+edesign <- as.matrix(read.table(opt$edesign, header=TRUE, row.names = 1))
+
+data <- read.table(opt$data, header=TRUE)
+
+results <- maSigPro(data, edesign, degree = opt$degree, time.col = opt$time_col,
+         repl.col = opt$repl_col, Q = opt$qvalue, min.obs = opt$min_obs,
+         step.method = opt$step_method, nvar.correction = opt$nvar_correction,
+         alfa = opt$alfa, rsq = opt$rsq, vars = opt$vars,
+         significant.intercept = opt$significant_intercept,
+         cluster.data = opt$cluster_data, k = opt$k,
+         cluster.method = opt$cluster_method, distance = opt$distance,
+         agglo.method = opt$agglo_method, iter.max = opt$iter_max,
+         color.mode = opt$color_mode, show.fit = opt$show_fit,
+         show.lines = opt$show_lines, cexlab = opt$cexlab,
+         legend = opt$legend)
+
+filename <- opt$outfile
+
+write.table((results$summary), file=filename, sep="\t", quote=FALSE,
+            row.names=FALSE, col.names=TRUE)
+
+cat("Session information:\n\n")
+
+sessionInfo()
\ No newline at end of file