# HG changeset patch # User iuc # Date 1496329822 14400 # Node ID cc96abdef027533377583544fd102f1e108f5260 # Parent c8c290f3ea7d3c71eca9e637f59e5e98719de71d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256 diff -r c8c290f3ea7d -r cc96abdef027 masigpro.R --- a/masigpro.R Mon May 15 07:29:03 2017 -0400 +++ b/masigpro.R Thu Jun 01 11:10:22 2017 -0400 @@ -1,104 +1,153 @@ -#!/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 +#!/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") +}) + +# The following code fixes an error in the stepback function +# of the maSigPro package. This code is hopefully temporary +# and can be removed if the fix is included in a future +# version. The stepback function in the maSigPro namespace +# will be overwritten by the following function. +stepback <- function (y = y, d = d, alfa = 0.05, family = gaussian() , epsilon=0.00001) +{ + lm1 <- glm(y ~ ., data = d, family=family, epsilon=epsilon) + result <- summary(lm1) + max <- max(result$coefficients[, 4][-1], na.rm = TRUE) + if (length(result$coefficients[, 4][-1]) == 1) { + if (max > alfa) { + max = 0 + lm1 <- glm(y ~ 1, family=family, epsilon=epsilon) + } + } + while (max > alfa) { + varout <- names(result$coefficients[, 4][-1])[result$coefficients[, + 4][-1] == max][1] + pos <- position(matrix = d, vari = varout) + d <- d[, -pos] + if (length(result$coefficients[, 4][-1]) == 2) { + min <- min(result$coefficients[, 4][-1], na.rm = TRUE) + lastname <- names(result$coefficients[, 4][-1])[result$coefficients[,4][-1] == min] + } + if (is.null(dim(d))) { + d <- as.data.frame(d) + colnames(d) <- lastname + } + lm1 <- glm(y ~ ., data = d, family=family, epsilon=epsilon) + result <- summary(lm1) + max <- max(result$coefficients[, 4][-1], na.rm = TRUE) + if (length(result$coefficients[, 4][-1]) == 1) { + max <- result$coefficients[, 4][-1] + if (max > alfa) { + max = 0 + lm1 <- glm(y ~ 1, family=family, epsilon=epsilon) + } + } + } + return(lm1) +} + +unlockBinding("stepback", as.environment("package:maSigPro")) +assignInNamespace("stepback", stepback, ns="maSigPro", envir=as.environment("package:maSigPro")) +assign("stepback", stepback, as.environment("package:maSigPro")) +lockBinding("stepback", as.environment("package:maSigPro")) +# End of temporary code to fix stepback.R + +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, check.names=FALSE) + +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() diff -r c8c290f3ea7d -r cc96abdef027 masigpro.xml --- a/masigpro.xml Mon May 15 07:29:03 2017 -0400 +++ b/masigpro.xml Thu Jun 01 11:10:22 2017 -0400 @@ -1,430 +1,430 @@ - - Significant Gene Expression Profile Differences in Time Course Gene Expression Data - - bioconductor-masigpro - r-optparse - sed - - - - - - - - /dev/null | grep -v -i "WARNING: ") - ]]> - - - data && sed -i '1i$header' data && - #if $source.enable_output: - ln -f data $data_out && ln -f $design_matrix $edesign_out && - #end if - #set $data = 'data' - #set $edesign = $design_matrix - #else: - #set $data = $source.data - #set $edesign = $source.edesign - #end if - Rscript '${__tool_directory__}/masigpro.R' - -e '$edesign' - -d '$data' - -o '$masigpro_out' - #if str($source.source_selector) == "defaults": - --time_col $source.time_col - --repl_col $source.repl_col - #end if - --degree $makeDesignMatrix.degree - --qvalue $p_vector.qvalue - --min_obs $p_vector.min_obs - --step_method '$Tfit.step_method' - --nvar_correction $Tfit.nvar_correction - --alfa $Tfit.alfa - --rsq $getSiggenes.rsq - --vars '$getSiggenes.vars' - --significant_intercept '$getSiggenes.significant_intercept' - #if $pdf.pdf_selector: - --cluster_data $pdf.seeGenes.clusterData - -k $pdf.seeGenes.k - --cluster_method $pdf.seeGenes.clustering.clusterMethod - #if str($pdf.seeGenes.clustering.clusterMethod) == "hclust": - --distance $pdf.seeGenes.clustering.distance - --agglo_method $pdf.seeGenes.clustering.aggloMethod - #end if - #if str($pdf.seeGenes.clustering.clusterMethod) == "kmeans": - --iter_max $pdf.seeGenes.clustering.iterMax - #end if - --color_mode $pdf.seeGenes.colorMode - --show_fit $pdf.seeGenes.showFit - --show_lines $pdf.seeGenes.showLines - --cexlab $pdf.seeGenes.cexlab - --legend $pdf.seeGenes.legend - #end if - ]]> - - -#if str($source.source_selector) == "advanced": -#set $header = "Name Time Replicate" -#for $group in $source.rep_groups: - #set $header = $header + ' ' + str($group.name) -#end for -$header -#set $c = len($source.rep_repl) + 1 -#for $time in $source.rep_time: - #for $file in $time.files: - #set $is_repl = False - #for $i, $repl in enumerate($source.rep_repl): - #if str($file) in str($repl.files): - #set $r = $i + 1 - #set $is_repl = True - #end if - #end for - #if $is_repl == False: - #set $r = $c - #set $c += 1 - #end if - #set $line = '"' + str($file.name) + '" ' + str($time.time) + ' ' + str($r) - #for $group in $source.rep_groups: - #if str($file) in str($group.files): - #set $line += " 1" - #else - #set $line += " 0" - #end if - #end for -$line - #end for -#end for -#end if - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- - -
-
- - - - - - - - - - - -
-
- - - - - - - - - - - -
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
- - - - - - (( - source['source_selector'] == 'advanced' and - source['enable_output'] == True - )) - - - - - (( - source['source_selector'] == 'advanced' and - source['enable_output'] == True - )) - - - - - (( - pdf['pdf_selector'] == True - )) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10.1093/bioinformatics/btl056 - -
\ No newline at end of file + + Significant Gene Expression Profile Differences in Time Course Gene Expression Data + + bioconductor-masigpro + r-optparse + sed + + + + + + + + /dev/null | grep -v -i "WARNING: ") + ]]> + + + data && sed -i '1i$header' data && + #if $source.enable_output: + ln -f data $data_out && ln -f $design_matrix $edesign_out && + #end if + #set $data = 'data' + #set $edesign = $design_matrix + #else: + #set $data = $source.data + #set $edesign = $source.edesign + #end if + Rscript '${__tool_directory__}/masigpro.R' + -e '$edesign' + -d '$data' + -o '$masigpro_out' + #if str($source.source_selector) == "defaults": + --time_col $source.time_col + --repl_col $source.repl_col + #end if + --degree $makeDesignMatrix.degree + --qvalue $p_vector.qvalue + --min_obs $p_vector.min_obs + --step_method '$Tfit.step_method' + --nvar_correction $Tfit.nvar_correction + --alfa $Tfit.alfa + --rsq $getSiggenes.rsq + --vars '$getSiggenes.vars' + --significant_intercept '$getSiggenes.significant_intercept' + #if $pdf.pdf_selector: + --cluster_data $pdf.seeGenes.clusterData + -k $pdf.seeGenes.k + --cluster_method $pdf.seeGenes.clustering.clusterMethod + #if str($pdf.seeGenes.clustering.clusterMethod) == "hclust": + --distance $pdf.seeGenes.clustering.distance + --agglo_method $pdf.seeGenes.clustering.aggloMethod + #end if + #if str($pdf.seeGenes.clustering.clusterMethod) == "kmeans": + --iter_max $pdf.seeGenes.clustering.iterMax + #end if + --color_mode $pdf.seeGenes.colorMode + --show_fit $pdf.seeGenes.showFit + --show_lines $pdf.seeGenes.showLines + --cexlab $pdf.seeGenes.cexlab + --legend $pdf.seeGenes.legend + #end if + ]]> + + +#if str($source.source_selector) == "advanced": +#set $header = "Name Time Replicate" +#for $group in $source.rep_groups: + #set $header = $header + ' ' + str($group.name) +#end for +$header +#set $c = len($source.rep_repl) + 1 +#for $time in $source.rep_time: + #for $file in $time.files: + #set $is_repl = False + #for $i, $repl in enumerate($source.rep_repl): + #if str($file) in str($repl.files): + #set $r = $i + 1 + #set $is_repl = True + #end if + #end for + #if $is_repl == False: + #set $r = $c + #set $c += 1 + #end if + #set $line = '"' + str($file.name) + '" ' + str($time.time) + ' ' + str($r) + #for $group in $source.rep_groups: + #if str($file) in str($group.files): + #set $line += " 1" + #else + #set $line += " 0" + #end if + #end for +$line + #end for +#end for +#end if + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + +
+
+ + + + + + + + + + + +
+
+ + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + + + (( + source['source_selector'] == 'advanced' and + source['enable_output'] == True + )) + + + + + (( + source['source_selector'] == 'advanced' and + source['enable_output'] == True + )) + + + + + (( + pdf['pdf_selector'] == True + )) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10.1093/bioinformatics/btl056 + +
diff -r c8c290f3ea7d -r cc96abdef027 test-data/Results.pdf Binary file test-data/Results.pdf has changed