annotate masigpro.R @ 4:402e0b9cfd87 draft default tip

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
author iuc
date Sat, 27 Nov 2021 09:58:07 +0000
parents db04ba860dab
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
1 #!/usr/bin/env Rscript
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
2
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
3 # A command-line interface to maSigPro for use with Galaxy
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
4 # written by Clemens Blank.
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
5 # Thanks to Bjoern Gruening and Michael Love for their DESeq2
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
6 # wrapper as a basis to build upon.
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
7
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
8 # setup R error handling to go to stderr
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
9 error_foo <- function() {
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
10 cat(geterrmessage(), file = stderr());
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
11 q("no", 1, F)
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
12 }
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
13 options(show.error.messages = F, error = error_foo)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
14
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
15 # we need that to not crash galaxy with an UTF8 error on German LC settings.
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
16 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
17
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
18 suppressPackageStartupMessages({
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
19 library("maSigPro")
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
20 library("optparse")
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
21 library("mclust")
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
22 })
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
23
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
24 # The following code fixes an error in the stepback function
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
25 # of the maSigPro package. This code is hopefully temporary
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
26 # and can be removed if the fix is included in a future
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
27 # version. The stepback function in the maSigPro namespace
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
28 # will be overwritten by the following function.
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
29 stepback <- function(y = y, d = d, alfa = 0.05, family = gaussian(), epsilon=0.00001) {
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
30 lm1 <- glm(y ~ ., data = d, family = family, epsilon = epsilon)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
31 result <- summary(lm1)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
32 max <- max(result$coefficients[, 4][-1], na.rm = TRUE)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
33 if (length(result$coefficients[, 4][-1]) == 1) {
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
34 if (max > alfa) {
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
35 max <- 0
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
36 lm1 <- glm(y ~ 1, family = family, epsilon = epsilon)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
37 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
38 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
39 while (max > alfa) {
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
40 varout <- names(result$coefficients[, 4][-1])[result$coefficients[, 4][-1] == max][1]
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
41 pos <- position(matrix = d, vari = varout)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
42 d <- d[, -pos]
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
43 if (length(result$coefficients[, 4][-1]) == 2) {
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
44 min <- min(result$coefficients[, 4][-1], na.rm = TRUE)
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
45 lastname <- names(result$coefficients[, 4][-1])[result$coefficients[, 4][-1] == min]
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
46 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
47 if (is.null(dim(d))) {
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
48 d <- as.data.frame(d)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
49 colnames(d) <- lastname
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
50 }
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
51 lm1 <- glm(y ~ ., data = d, family = family, epsilon = epsilon)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
52 result <- summary(lm1)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
53 max <- max(result$coefficients[, 4][-1], na.rm = TRUE)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
54 if (length(result$coefficients[, 4][-1]) == 1) {
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
55 max <- result$coefficients[, 4][-1]
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
56 if (max > alfa) {
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
57 max <- 0
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
58 lm1 <- glm(y ~ 1, family = family, epsilon = epsilon)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
59 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
60 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
61 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
62 return(lm1)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
63 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
64
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
65 unlockBinding("stepback", as.environment("package:maSigPro"))
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
66 assignInNamespace("stepback", stepback, ns = "maSigPro", envir = as.environment("package:maSigPro"))
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
67 assign("stepback", stepback, as.environment("package:maSigPro"))
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
68 lockBinding("stepback", as.environment("package:maSigPro"))
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
69 # End of temporary code to fix stepback.R
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
70
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
71 options(stringAsFactors = FALSE, useFancyQuotes = FALSE)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
72 args <- commandArgs(trailingOnly = TRUE)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
73
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
74 # specify our desired options in a list
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
75 # by default OptionParser will add an help option equivalent to
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
76 # make_option(c("-h", "--help"), action="store_true", default=FALSE,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
77 # help="Show this help message and exit")
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
78 option_list <- list(
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
79 make_option(c("-q", "--quiet"), action = "store_false",
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
80 dest = "verbose", help = "Print little output"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
81 make_option(c("-e", "--edesign"), type = "character"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
82 make_option(c("-d", "--data"), type = "character"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
83 make_option(c("-o", "--outfile"), type = "character"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
84 make_option("--degree", type = "integer", default = 1),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
85 make_option("--time_col", type = "integer", default = 1),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
86 make_option("--repl_col", type = "integer", default = 2),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
87 make_option("--qvalue", type = "double", default = 0.05),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
88 make_option("--min_obs", type = "integer", default = 6),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
89 make_option("--step_method", type = "character", default = "backward"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
90 make_option("--nvar_correction", type = "logical", default = FALSE),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
91 make_option("--alfa", type = "double", default = 0.05),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
92 make_option("--rsq", type = "double", default = 0.7),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
93 make_option("--vars", type = "character", default = "groups"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
94 make_option("--significant_intercept", type = "character", default = "dummy"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
95 make_option("--cluster_data", type = "integer", default = 1),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
96 make_option(c("-k", "--k"), type = "integer", default = 9),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
97 make_option("--print_cluster", type = "logical", default = FALSE),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
98 make_option("--cluster_method", type = "character", default = "hclust"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
99 make_option("--distance", type = "character", default = "cor"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
100 make_option("--agglo_method", type = "character", default = "ward.D"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
101 make_option("--iter_max", type = "integer", default = 500),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
102 make_option("--color_mode", type = "character", default = "rainbow"),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
103 make_option("--show_fit", type = "logical", default = TRUE),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
104 make_option("--show_lines", type = "logical", default = TRUE),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
105 make_option("--cexlab", type = "double", default = 0.8),
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
106 make_option("--legend", type = "logical", default = TRUE)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
107 )
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
108
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
109 # get command line options, if help option encountered print help and exit,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
110 # otherwise if options not found on command line then set defaults
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
111 opt <- parse_args(OptionParser(option_list = option_list))
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
112
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
113 # enforce the following required arguments
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
114 if (is.null(opt$edesign)) {
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
115 cat("'edesign' is required\n")
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
116 q(status = 1)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
117 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
118 if (is.null(opt$data)) {
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
119 cat("'data' is required\n")
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
120 q(status = 1)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
121 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
122 if (is.null(opt$outfile)) {
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
123 cat("'outfile' is required\n")
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
124 q(status = 1)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
125 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
126
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
127 verbose <- if (is.null(opt$quiet)) {
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
128 TRUE
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
129 } else {
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
130 FALSE
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
131 }
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
132
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
133 edesign <- as.matrix(read.table(opt$edesign, header = TRUE, row.names = 1))
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
134
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
135 data <- read.table(opt$data, header = TRUE, check.names = FALSE)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
136
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
137 results <- maSigPro(data, edesign, degree = opt$degree, time.col = opt$time_col,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
138 repl.col = opt$repl_col, Q = opt$qvalue, min.obs = opt$min_obs,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
139 step.method = opt$step_method, nvar.correction = opt$nvar_correction,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
140 alfa = opt$alfa, rsq = opt$rsq, vars = opt$vars,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
141 significant.intercept = opt$significant_intercept,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
142 cluster.data = opt$cluster_data, k = opt$k,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
143 cluster.method = opt$cluster_method, distance = opt$distance,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
144 agglo.method = opt$agglo_method, iter.max = opt$iter_max,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
145 color.mode = opt$color_mode, show.fit = opt$show_fit,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
146 show.lines = opt$show_lines, cexlab = opt$cexlab,
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
147 legend = opt$legend)
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
148
2
db04ba860dab planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents: 1
diff changeset
149 if (opt$print_cluster) {
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
150 for (i in seq_len(length(results$sig.genes))) {
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
151 colname <- paste(names(results$sig.genes)[i], "cluster", sep = "_")
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
152 results$summary[colname] <- ""
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
153 results$summary[[colname]][seq_len(length(results$sig.genes[[i]]$sig.profiles$`cluster$cut`))] <-
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
154 results$sig.genes[[i]]$sig.profiles$`cluster$cut`
2
db04ba860dab planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents: 1
diff changeset
155 }
db04ba860dab planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents: 1
diff changeset
156 }
db04ba860dab planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents: 1
diff changeset
157
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
158 filename <- opt$outfile
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
159
4
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
160 write.table((results$summary), file = filename, sep = "\t", quote = FALSE,
402e0b9cfd87 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
161 row.names = FALSE, col.names = TRUE)
1
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
162
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
163 cat("Session information:\n\n")
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
164
cc96abdef027 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
165 sessionInfo()