annotate execute_dwt_var_perClass.R @ 1:781e68074f84 draft default tip

"planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
author devteam
date Mon, 06 Jul 2020 20:34:10 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
1 ######################################################################
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
2 ## plot power spectra, i.e. wavelet variance by class
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
3 ## add code to create null bands by permuting the original data series
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
4 ## get class of maximum significant variance per feature
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
5 ## generate plots and table matrix of variance including p-values
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
6 ######################################################################
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
7 library("wavethresh");
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
8 library("waveslim");
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
9
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
10 options(echo = FALSE)
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
11
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
12 ## normalize data
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
13 norm <- function(data) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
14 v <- (data - mean(data)) / sd(data);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
15 if (sum(is.na(v)) >= 1) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
16 v <- data;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
17 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
18 return(v);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
19 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
20
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
21 dwt_var_permut_get_max <- function(data, names, outfile, filter = 4, bc = "symmetric", method = "kendall", wf = "haar", boundary = "reflection") {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
22 max_var <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
23 matrix <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
24 title <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
25 final_pvalue <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
26 short_levels <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
27 scale <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
28
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
29 print(names);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
30
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
31 par(mfcol = c(length(names), length(names)), mar = c(0, 0, 0, 0), oma = c(4, 3, 3, 2), xaxt = "s", cex = 1, las = 1);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
32
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
33 short_levels <- wavethresh::wd(data[, 1], filter.number = filter, bc = bc)$nlevels;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
34
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
35 title <- c("motif");
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
36 for (i in seq_len(short_levels)) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
37 title <- c(title, paste(i, "var", sep = "_"), paste(i, "pval", sep = "_"), paste(i, "test", sep = "_"));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
38 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
39 print(title);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
40
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
41 ## normalize the raw data
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
42 data <- apply(data, 2, norm);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
43
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
44 for (i in seq_len(length(names))) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
45 for (j in seq_len(length(names))) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
46 temp <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
47 results <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
48 wave1_dwt <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
49 out <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
50
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
51 out <- vector(length = length(title));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
52 temp <- vector(length = short_levels);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
53
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
54 if (i != j) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
55 plot(temp, type = "n", axes = FALSE, xlab = NA, ylab = NA);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
56 box(col = "grey");
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
57 grid(ny = 0, nx = NULL);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
58 } else {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
59
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
60 wave1_dwt <- waveslim::dwt(data[, i], wf = wf, short_levels, boundary = boundary);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
61
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
62 temp_row <- (short_levels + 1) * -1;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
63 temp_col <- 1;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
64 temp <- waveslim::wave.variance(wave1_dwt)[temp_row, temp_col];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
65
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
66 ##permutations code :
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
67 feature1 <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
68 null <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
69 var_25 <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
70 var_975 <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
71 med <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
72
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
73 feature1 <- data[, i];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
74 for (k in seq_len(1000)) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
75 nk_1 <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
76 null_levels <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
77 var <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
78 null_wave1 <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
79
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
80 nk_1 <- sample(feature1, length(feature1), replace = FALSE);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
81 null_levels <- wavethresh::wd(nk_1, filter.number = filter, bc = bc)$nlevels;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
82 var <- vector(length = length(null_levels));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
83 null_wave1 <- waveslim::dwt(nk_1, wf = wf, short_levels, boundary = boundary);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
84 var <- waveslim::wave.variance(null_wave1)[-8, 1];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
85 null <- rbind(null, var);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
86 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
87 null <- apply(null, 2, sort, na.last = TRUE);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
88 var_25 <- null[25, ];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
89 var_975 <- null[975, ];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
90 med <- (apply(null, 2, median, na.rm = TRUE));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
91
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
92 ## plot
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
93 results <- cbind(temp, var_25, var_975);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
94 matplot(results, type = "b", pch = "*", lty = 1, col = c(1, 2, 2), axes = F);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
95
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
96 ## get pvalues by comparison to null distribution
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
97 out <- (names[i]);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
98 for (m in seq_len(length(temp))) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
99 print(paste("scale", m, sep = " "));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
100 print(paste("var", temp[m], sep = " "));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
101 print(paste("med", med[m], sep = " "));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
102 pv <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
103 tail <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
104 out <- c(out, format(temp[m], digits = 3));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
105 if (temp[m] >= med[m]) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
106 ## R tail test
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
107 print("R");
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
108 tail <- "R";
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
109 pv <- (length(which(null[, m] >= temp[m]))) / (length(na.exclude(null[, m])));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
110
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
111 } else {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
112 ## L tail test
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
113 print("L");
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
114 tail <- "L";
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
115 pv <- (length(which(null[, m] <= temp[m]))) / (length(na.exclude(null[, m])));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
116 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
117 out <- c(out, pv);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
118 print(pv);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
119 out <- c(out, tail);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
120 ## get variances outside null bands by comparing temp to null
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
121 ### temp stores variance for each scale, and null stores permuted variances for null bands
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
122 if (temp[m] <= var_975[m]) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
123 temp[m] <- NA;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
124 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
125 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
126 final_pvalue <- rbind(final_pvalue, out);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
127 matrix <- rbind(matrix, temp)
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
128 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
129 ## labels
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
130 if (i == 1) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
131 mtext(names[j], side = 2, line = 0.5, las = 3, cex = 0.25);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
132 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
133 if (j == 1) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
134 mtext(names[i], side = 3, line = 0.5, cex = 0.25);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
135 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
136 if (j == length(names)) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
137 axis(1, at = (1:short_levels), las = 3, cex.axis = 0.5);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
138 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
139 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
140 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
141 colnames(final_pvalue) <- title;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
142
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
143 ## get maximum variance larger than expectation by comparison to null bands
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
144 varnames <- vector();
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
145 for (i in seq_len(length(names))) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
146 name1 <- paste(names[i], "var", sep = "_")
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
147 varnames <- c(varnames, name1)
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
148 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
149 rownames(matrix) <- varnames;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
150 colnames(matrix) <- (1:short_levels);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
151 max_var <- names;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
152 scale <- vector(length = length(names));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
153 for (x in seq_len(nrow(matrix))) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
154 if (length(which.max(matrix[x, ])) == 0) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
155 scale[x] <- NA;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
156 } else{
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
157 scale[x] <- colnames(matrix)[which.max(matrix[x, ])];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
158 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
159 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
160 max_var <- cbind(max_var, scale);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
161 write.table(max_var, file = outfile, sep = "\t", quote = FALSE, row.names = FALSE, append = TRUE);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
162 return(final_pvalue);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
163 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
164
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
165 ## execute
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
166 ## read in data
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
167 args <- commandArgs(trailingOnly = TRUE)
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
168
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
169 data_test <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
170 data_test <- read.delim(args[1]);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
171
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
172 count <- ncol(data_test)
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
173 print(paste("The number of columns in the input file is: ", count));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
174
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
175 # check if the number of motifs is not a multiple of 12, and round up is so
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
176 if (count %% 12 != 0) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
177 print("the number of motifs is not a multiple of 12")
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
178 count2 <- ceiling(count / 12);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
179 }else{
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
180 print("the number of motifs is a multiple of 12")
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
181 count2 <- count / 12
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
182 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
183 print(paste("There will be", count2, "subfiles"))
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
184
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
185 pdf(file = args[4], width = 11, height = 8);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
186
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
187 ## loop to read and execute on all count2 subfiles
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
188 final <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
189 for (x in seq_len(count2)) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
190 sub <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
191 sub_names <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
192 a <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
193 b <- NULL;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
194
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
195 a <- ((x - 1) * 12 + 1);
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
196 b <- x * 12;
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
197
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
198 if (x < count2) {
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
199 sub <- data_test[, +c(a:b)];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
200 sub_names <- colnames(data_test)[a:b];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
201 final <- rbind(final, dwt_var_permut_get_max(sub, sub_names, args[2]));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
202 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
203 else{
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
204 sub <- data_test[, +c(a:ncol(data_test))];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
205 sub_names <- colnames(data_test)[a:ncol(data_test)];
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
206 final <- rbind(final, dwt_var_permut_get_max(sub, sub_names, args[2]));
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
207 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
208 }
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
209
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
210 dev.off();
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
211
781e68074f84 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
212 write.table(final, file = args[3], sep = "\t", quote = FALSE, row.names = FALSE);