annotate masigpro.R @ 5:401e7c9e09f2 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:57:16 +0000
parents 0e5ddeb06378
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
6bc58c43b997 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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
2
6bc58c43b997 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
6bc58c43b997 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.
6bc58c43b997 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
6bc58c43b997 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.
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
7
6bc58c43b997 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
5
401e7c9e09f2 "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() {
401e7c9e09f2 "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());
401e7c9e09f2 "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)
401e7c9e09f2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
12 }
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
14
6bc58c43b997 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.
6bc58c43b997 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")
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
17
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
18 suppressPackageStartupMessages({
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
19 library("maSigPro")
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
20 library("optparse")
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
21 library("mclust")
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
22 })
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
23
6bc58c43b997 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
5
401e7c9e09f2 "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
401e7c9e09f2 "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
6bc58c43b997 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
6bc58c43b997 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.
5
401e7c9e09f2 "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) {
401e7c9e09f2 "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
6bc58c43b997 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)
6bc58c43b997 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)
6bc58c43b997 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) {
6bc58c43b997 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) {
5
401e7c9e09f2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
35 max <- 0
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
37 }
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
38 }
6bc58c43b997 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) {
5
401e7c9e09f2 "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
6bc58c43b997 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)
6bc58c43b997 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]
6bc58c43b997 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) {
6bc58c43b997 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)
5
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
46 }
6bc58c43b997 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))) {
6bc58c43b997 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)
6bc58c43b997 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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
50 }
5
401e7c9e09f2 "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
6bc58c43b997 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)
6bc58c43b997 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)
6bc58c43b997 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) {
6bc58c43b997 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]
6bc58c43b997 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) {
5
401e7c9e09f2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 7dc16d5d4169a8fbfb3fad3b2212fd8b6d481f5f"
iuc
parents: 2
diff changeset
57 max <- 0
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
59 }
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
60 }
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
61 }
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
62 return(lm1)
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
63 }
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
64
6bc58c43b997 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"))
5
401e7c9e09f2 "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
6bc58c43b997 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"))
6bc58c43b997 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"))
6bc58c43b997 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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
70
6bc58c43b997 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)
6bc58c43b997 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)
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
73
6bc58c43b997 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
6bc58c43b997 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
6bc58c43b997 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,
6bc58c43b997 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")
6bc58c43b997 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(
5
401e7c9e09f2 "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",
401e7c9e09f2 "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"),
401e7c9e09f2 "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"),
401e7c9e09f2 "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"),
401e7c9e09f2 "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"),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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"),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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"),
401e7c9e09f2 "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"),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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"),
401e7c9e09f2 "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"),
401e7c9e09f2 "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"),
401e7c9e09f2 "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),
401e7c9e09f2 "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"),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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),
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
107 )
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
108
6bc58c43b997 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,
6bc58c43b997 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
5
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
112
6bc58c43b997 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
6bc58c43b997 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)) {
6bc58c43b997 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")
5
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
117 }
6bc58c43b997 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)) {
6bc58c43b997 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")
5
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
121 }
6bc58c43b997 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)) {
6bc58c43b997 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")
5
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
125 }
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
126
6bc58c43b997 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)) {
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
128 TRUE
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
129 } else {
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
130 FALSE
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
131 }
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
132
5
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
134
5
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
136
6bc58c43b997 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,
6bc58c43b997 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,
6bc58c43b997 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,
6bc58c43b997 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,
6bc58c43b997 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,
6bc58c43b997 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,
6bc58c43b997 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,
6bc58c43b997 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,
6bc58c43b997 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,
6bc58c43b997 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,
6bc58c43b997 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)
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
148
2
0e5ddeb06378 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) {
5
401e7c9e09f2 "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))) {
401e7c9e09f2 "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 = "_")
401e7c9e09f2 "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] <- ""
401e7c9e09f2 "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`))] <-
401e7c9e09f2 "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
0e5ddeb06378 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents: 1
diff changeset
155 }
0e5ddeb06378 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents: 1
diff changeset
156 }
0e5ddeb06378 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents: 1
diff changeset
157
1
6bc58c43b997 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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
159
5
401e7c9e09f2 "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,
401e7c9e09f2 "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
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
162
6bc58c43b997 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")
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
164
6bc58c43b997 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents: 0
diff changeset
165 sessionInfo()