annotate execute_dwt_var_perClass.R @ 1:0c1388b563a8 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 18:12:51 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
1 ######################################################################
0c1388b563a8 "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
0c1388b563a8 "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
0c1388b563a8 "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
0c1388b563a8 "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
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
6 ######################################################################
0c1388b563a8 "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");
0c1388b563a8 "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");
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
9
0c1388b563a8 "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)
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
11
0c1388b563a8 "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
0c1388b563a8 "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) {
0c1388b563a8 "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);
0c1388b563a8 "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) {
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
17 }
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
19 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
20
0c1388b563a8 "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") {
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
28
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
30
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
32
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
34
0c1388b563a8 "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");
0c1388b563a8 "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)) {
0c1388b563a8 "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 = "_"));
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
38 }
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
40
0c1388b563a8 "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
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
43
0c1388b563a8 "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))) {
0c1388b563a8 "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))) {
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
50
0c1388b563a8 "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));
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
53
0c1388b563a8 "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) {
0c1388b563a8 "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);
0c1388b563a8 "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");
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
58 } else {
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
59
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
61
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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];
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
65
0c1388b563a8 "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 :
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
72
0c1388b563a8 "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];
0c1388b563a8 "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)) {
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
79
0c1388b563a8 "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);
0c1388b563a8 "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;
0c1388b563a8 "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));
0c1388b563a8 "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);
0c1388b563a8 "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];
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
86 }
0c1388b563a8 "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);
0c1388b563a8 "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, ];
0c1388b563a8 "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, ];
0c1388b563a8 "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));
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
91
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
92 ## plot
0c1388b563a8 "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);
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
95
0c1388b563a8 "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
0c1388b563a8 "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]);
0c1388b563a8 "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))) {
0c1388b563a8 "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 = " "));
0c1388b563a8 "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 = " "));
0c1388b563a8 "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 = " "));
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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));
0c1388b563a8 "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]) {
0c1388b563a8 "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
0c1388b563a8 "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");
0c1388b563a8 "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";
0c1388b563a8 "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])));
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
110
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
111 } else {
0c1388b563a8 "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
0c1388b563a8 "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");
0c1388b563a8 "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";
0c1388b563a8 "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])));
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
116 }
0c1388b563a8 "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);
0c1388b563a8 "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);
0c1388b563a8 "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);
0c1388b563a8 "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
0c1388b563a8 "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
0c1388b563a8 "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]) {
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
124 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
125 }
0c1388b563a8 "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);
0c1388b563a8 "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)
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
128 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
129 ## labels
0c1388b563a8 "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) {
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
132 }
0c1388b563a8 "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) {
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
135 }
0c1388b563a8 "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)) {
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
138 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
139 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
140 }
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
142
0c1388b563a8 "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
0c1388b563a8 "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();
0c1388b563a8 "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))) {
0c1388b563a8 "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 = "_")
0c1388b563a8 "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)
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
148 }
0c1388b563a8 "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;
0c1388b563a8 "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);
0c1388b563a8 "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;
0c1388b563a8 "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));
0c1388b563a8 "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))) {
0c1388b563a8 "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) {
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
156 } else{
0c1388b563a8 "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, ])];
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
158 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
159 }
0c1388b563a8 "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);
0c1388b563a8 "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);
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
163 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
164
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
165 ## execute
0c1388b563a8 "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
0c1388b563a8 "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)
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
168
0c1388b563a8 "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;
0c1388b563a8 "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]);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
171
0c1388b563a8 "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)
0c1388b563a8 "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));
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
174
0c1388b563a8 "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
0c1388b563a8 "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) {
0c1388b563a8 "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")
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
179 }else{
0c1388b563a8 "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")
0c1388b563a8 "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
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
182 }
0c1388b563a8 "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"))
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
184
0c1388b563a8 "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);
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
186
0c1388b563a8 "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
0c1388b563a8 "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;
0c1388b563a8 "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)) {
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
194
0c1388b563a8 "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);
0c1388b563a8 "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;
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
197
0c1388b563a8 "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) {
0c1388b563a8 "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)];
0c1388b563a8 "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];
0c1388b563a8 "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]));
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
202 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
203 else{
0c1388b563a8 "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))];
0c1388b563a8 "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)];
0c1388b563a8 "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]));
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
207 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
208 }
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
209
0c1388b563a8 "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();
0c1388b563a8 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/dwt_var_perclass commit f929353ffb0623f2218d7dec459c7da62f3b0d24"
devteam
parents:
diff changeset
211
0c1388b563a8 "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);