comparison masigpro.R @ 1:cc96abdef027 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/masigpro commit c4510bf402d10e8e3a3c4c90c2d96666c987a256
author iuc
date Thu, 01 Jun 2017 11:10:22 -0400
parents c8c290f3ea7d
children db04ba860dab
comparison
equal deleted inserted replaced
0:c8c290f3ea7d 1:cc96abdef027
14 suppressPackageStartupMessages({ 14 suppressPackageStartupMessages({
15 library("maSigPro") 15 library("maSigPro")
16 library("optparse") 16 library("optparse")
17 library("mclust") 17 library("mclust")
18 }) 18 })
19
20 # The following code fixes an error in the stepback function
21 # of the maSigPro package. This code is hopefully temporary
22 # and can be removed if the fix is included in a future
23 # version. The stepback function in the maSigPro namespace
24 # will be overwritten by the following function.
25 stepback <- function (y = y, d = d, alfa = 0.05, family = gaussian() , epsilon=0.00001)
26 {
27 lm1 <- glm(y ~ ., data = d, family=family, epsilon=epsilon)
28 result <- summary(lm1)
29 max <- max(result$coefficients[, 4][-1], na.rm = TRUE)
30 if (length(result$coefficients[, 4][-1]) == 1) {
31 if (max > alfa) {
32 max = 0
33 lm1 <- glm(y ~ 1, family=family, epsilon=epsilon)
34 }
35 }
36 while (max > alfa) {
37 varout <- names(result$coefficients[, 4][-1])[result$coefficients[,
38 4][-1] == max][1]
39 pos <- position(matrix = d, vari = varout)
40 d <- d[, -pos]
41 if (length(result$coefficients[, 4][-1]) == 2) {
42 min <- min(result$coefficients[, 4][-1], na.rm = TRUE)
43 lastname <- names(result$coefficients[, 4][-1])[result$coefficients[,4][-1] == min]
44 }
45 if (is.null(dim(d))) {
46 d <- as.data.frame(d)
47 colnames(d) <- lastname
48 }
49 lm1 <- glm(y ~ ., data = d, family=family, epsilon=epsilon)
50 result <- summary(lm1)
51 max <- max(result$coefficients[, 4][-1], na.rm = TRUE)
52 if (length(result$coefficients[, 4][-1]) == 1) {
53 max <- result$coefficients[, 4][-1]
54 if (max > alfa) {
55 max = 0
56 lm1 <- glm(y ~ 1, family=family, epsilon=epsilon)
57 }
58 }
59 }
60 return(lm1)
61 }
62
63 unlockBinding("stepback", as.environment("package:maSigPro"))
64 assignInNamespace("stepback", stepback, ns="maSigPro", envir=as.environment("package:maSigPro"))
65 assign("stepback", stepback, as.environment("package:maSigPro"))
66 lockBinding("stepback", as.environment("package:maSigPro"))
67 # End of temporary code to fix stepback.R
19 68
20 options(stringAsFactors = FALSE, useFancyQuotes = FALSE) 69 options(stringAsFactors = FALSE, useFancyQuotes = FALSE)
21 args <- commandArgs(trailingOnly = TRUE) 70 args <- commandArgs(trailingOnly = TRUE)
22 71
23 # specify our desired options in a list 72 # specify our desired options in a list
78 FALSE 127 FALSE
79 } 128 }
80 129
81 edesign <- as.matrix(read.table(opt$edesign, header=TRUE, row.names = 1)) 130 edesign <- as.matrix(read.table(opt$edesign, header=TRUE, row.names = 1))
82 131
83 data <- read.table(opt$data, header=TRUE) 132 data <- read.table(opt$data, header=TRUE, check.names=FALSE)
84 133
85 results <- maSigPro(data, edesign, degree = opt$degree, time.col = opt$time_col, 134 results <- maSigPro(data, edesign, degree = opt$degree, time.col = opt$time_col,
86 repl.col = opt$repl_col, Q = opt$qvalue, min.obs = opt$min_obs, 135 repl.col = opt$repl_col, Q = opt$qvalue, min.obs = opt$min_obs,
87 step.method = opt$step_method, nvar.correction = opt$nvar_correction, 136 step.method = opt$step_method, nvar.correction = opt$nvar_correction,
88 alfa = opt$alfa, rsq = opt$rsq, vars = opt$vars, 137 alfa = opt$alfa, rsq = opt$rsq, vars = opt$vars,