Mercurial > repos > iuc > masigpro
annotate masigpro.R @ 3:83f8b5ceff43 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 60951bbe9b08fa6eb2762db9ee15c88e8acf1a1f"
author | iuc |
---|---|
date | Tue, 03 Dec 2019 06:18:47 -0500 |
parents | db04ba860dab |
children | 402e0b9cfd87 |
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 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
9 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
10 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
11 # 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
|
12 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
|
13 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
14 suppressPackageStartupMessages({ |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
15 library("maSigPro") |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
16 library("optparse") |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
17 library("mclust") |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
18 }) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
19 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
20 # The following code fixes an error in the stepback function |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
21 # of the maSigPro package. This code is hopefully temporary |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
22 # and can be removed if the fix is included in a future |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
23 # 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
|
24 # will be overwritten by the following function. |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
25 stepback <- function (y = y, d = d, alfa = 0.05, family = gaussian() , epsilon=0.00001) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
26 { |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
27 lm1 <- glm(y ~ ., data = d, family=family, epsilon=epsilon) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 if (max > alfa) { |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
32 max = 0 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
33 lm1 <- glm(y ~ 1, family=family, epsilon=epsilon) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
34 } |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
35 } |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
36 while (max > alfa) { |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
37 varout <- names(result$coefficients[, 4][-1])[result$coefficients[, |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
38 4][-1] == max][1] |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 min <- min(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
|
43 lastname <- names(result$coefficients[, 4][-1])[result$coefficients[,4][-1] == min] |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
44 } |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
45 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
|
46 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
|
47 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
|
48 } |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
49 lm1 <- glm(y ~ ., data = d, family=family, epsilon=epsilon) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 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
|
54 if (max > alfa) { |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
55 max = 0 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
56 lm1 <- glm(y ~ 1, family=family, epsilon=epsilon) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
57 } |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
58 } |
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 return(lm1) |
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 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
63 unlockBinding("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
|
64 assignInNamespace("stepback", stepback, ns="maSigPro", envir=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
|
65 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
|
66 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
|
67 # 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
|
68 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
69 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
|
70 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
|
71 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
72 # 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
|
73 # 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
|
74 # 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
|
75 # 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
|
76 option_list <- list( |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
77 make_option(c("-q", "--quiet"), action="store_false", |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
78 dest="verbose", help="Print little output"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
79 make_option(c("-e", "--edesign"), type="character"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
80 make_option(c("-d", "--data"), type="character"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
81 make_option(c("-o", "--outfile"), type="character"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
82 make_option("--degree", type="integer", default=1), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
83 make_option("--time_col", type="integer", default=1), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
84 make_option("--repl_col", type="integer", default=2), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
85 make_option("--qvalue", type="double", default=0.05), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
86 make_option("--min_obs", type="integer", default=6), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
87 make_option("--step_method", type="character", default="backward"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
88 make_option("--nvar_correction", type="logical", default=FALSE), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
89 make_option("--alfa", type="double", default=0.05), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
90 make_option("--rsq", type="double", default=0.7), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
91 make_option("--vars", type="character", default="groups"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
92 make_option("--significant_intercept", type="character", default="dummy"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
93 make_option("--cluster_data", type="integer", default=1), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
94 make_option(c("-k", "--k"), type="integer", default=9), |
2
db04ba860dab
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents:
1
diff
changeset
|
95 make_option("--print_cluster", type="logical", default=FALSE), |
1
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
96 make_option("--cluster_method", type="character", default="hclust"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
97 make_option("--distance", type="character", default="cor"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
98 make_option("--agglo_method", type="character", default="ward.D"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
99 make_option("--iter_max", type="integer", default=500), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
100 make_option("--color_mode", type="character", default="rainbow"), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
101 make_option("--show_fit", type="logical", default=TRUE), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
102 make_option("--show_lines", type="logical", default=TRUE), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
103 make_option("--cexlab", type="double", default=0.8), |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
104 make_option("--legend", type="logical", default=TRUE) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
105 ) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
106 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
107 # 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
|
108 # otherwise if options not found on command line then set defaults |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
109 opt <- parse_args(OptionParser(option_list=option_list)) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
110 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
111 # 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
|
112 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
|
113 cat("'edesign' is required\n") |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
114 q(status=1) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
115 } |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
116 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
|
117 cat("'data' is required\n") |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
118 q(status=1) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
119 } |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
120 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
|
121 cat("'outfile' is required\n") |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
122 q(status=1) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
123 } |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
124 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
125 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
|
126 TRUE |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
127 } else { |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
128 FALSE |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
129 } |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
130 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
131 edesign <- as.matrix(read.table(opt$edesign, header=TRUE, row.names = 1)) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
132 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
133 data <- read.table(opt$data, header=TRUE, check.names=FALSE) |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
134 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 |
2
db04ba860dab
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents:
1
diff
changeset
|
147 if (opt$print_cluster) { |
db04ba860dab
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents:
1
diff
changeset
|
148 for (i in 1:length(results$sig.genes)) { |
db04ba860dab
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents:
1
diff
changeset
|
149 |
db04ba860dab
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents:
1
diff
changeset
|
150 colname <- paste(names(results$sig.genes)[i], "cluster", sep = "_") |
db04ba860dab
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents:
1
diff
changeset
|
151 |
db04ba860dab
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents:
1
diff
changeset
|
152 results$summary[colname] <- "" |
db04ba860dab
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents:
1
diff
changeset
|
153 results$summary[[colname]][1:length(results$sig.genes[[i]]$sig.profiles$`cluster$cut`)] <- |
db04ba860dab
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit 54ebbdebc9861af600371928cb9915095941c231
iuc
parents:
1
diff
changeset
|
154 results$sig.genes[[i]]$sig.profiles$`cluster$cut` |
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 |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
160 write.table((results$summary), file=filename, sep="\t", quote=FALSE, |
cc96abdef027
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
iuc
parents:
0
diff
changeset
|
161 row.names=FALSE, col.names=TRUE) |
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() |