Mercurial > repos > ethevenot > univariate
annotate univariate_script.R @ 3:140290de7986 draft
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
author | ethevenot |
---|---|
date | Sun, 30 Oct 2016 14:17:09 -0400 |
parents | 09799fc16bc6 |
children |
rev | line source |
---|---|
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
1 univariateF <- function(datMN, |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
2 samDF, |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
3 varDF, |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
4 facC, |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
5 tesC = c("ttest", "wilcoxon", "anova", "kruskal", "pearson", "spearman")[1], |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
6 adjC = c("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none")[7], |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
7 thrN = 0.05, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
8 pdfC) { |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
9 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
10 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
11 ## Option |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
12 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
13 strAsFacL <- options()$stringsAsFactors |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
14 options(stingsAsFactors = FALSE) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
15 options(warn = -1) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
16 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
17 ## Getting the response (either a factor or a numeric) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
18 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
19 if(mode(samDF[, facC]) == "character") { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
20 facFcVn <- factor(samDF[, facC]) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
21 facLevVc <- levels(facFcVn) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
22 } else |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
23 facFcVn <- samDF[, facC] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
24 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
25 cat("\nPerforming '", tesC, "'\n", sep="") |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
26 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
27 varPfxC <- paste0(make.names(facC), "_", tesC, "_") |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
28 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
29 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
30 if(tesC %in% c("ttest", "wilcoxon", "pearson", "spearman")) { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
31 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
32 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
33 switch(tesC, |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
34 ttest = { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
35 staF <- function(y) diff(tapply(y, facFcVn, function(x) mean(x, na.rm = TRUE))) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
36 tesF <- function(y) t.test(y ~ facFcVn)[["p.value"]] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
37 }, |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
38 wilcoxon = { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
39 staF <- function(y) diff(tapply(y, facFcVn, function(x) median(x, na.rm = TRUE))) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
40 tesF <- function(y) wilcox.test(y ~ facFcVn)[["p.value"]] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
41 }, |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
42 pearson = { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
43 staF <- function(y) cor(facFcVn, y, method = "pearson", use = "pairwise.complete.obs") |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
44 tesF <- function(y) cor.test(facFcVn, y, method = "pearson", use = "pairwise.complete.obs")[["p.value"]] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
45 }, |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
46 spearman = { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
47 staF <- function(y) cor(facFcVn, y, method = "spearman", use = "pairwise.complete.obs") |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
48 tesF <- function(y) cor.test(facFcVn, y, method = "spearman", use = "pairwise.complete.obs")[["p.value"]] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
49 }) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
50 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
51 staVn <- apply(datMN, 2, staF) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
52 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
53 adjVn <- p.adjust(apply(datMN, |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
54 2, |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
55 tesF), |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
56 method = adjC) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
57 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
58 sigVn <- as.numeric(adjVn < thrN) |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
59 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
60 if(tesC %in% c("ttest", "wilcoxon")) |
2
09799fc16bc6
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 2c0d4d97c208edca1ada2035a7b7af9c4eb31afe
ethevenot
parents:
0
diff
changeset
|
61 varPfxC <- paste0(varPfxC, paste(rev(facLevVc), collapse = "."), "_") |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
62 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
63 varDF[, paste0(varPfxC, ifelse(tesC %in% c("ttest", "wilcoxon"), "dif", "cor"))] <- staVn |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
64 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
65 varDF[, paste0(varPfxC, adjC)] <- adjVn |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
66 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
67 varDF[, paste0(varPfxC, "sig")] <- sigVn |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
68 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
69 ## graphic |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
70 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
71 pdf(pdfC, onefile = TRUE) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
72 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
73 varVi <- which(sigVn > 0) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
74 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
75 if(tesC %in% c("ttest", "wilcoxon")) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
76 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
77 facVc <- as.character(facFcVn) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
78 names(facVc) <- rownames(samDF) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
79 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
80 for(varI in varVi) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
81 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
82 varC <- rownames(varDF)[varI] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
83 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
84 boxF(facFcVn, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
85 datMN[, varI], |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
86 paste0(varC, " (", adjC, " = ", signif(adjVn[varI], 2), ")"), |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
87 facVc) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
88 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
89 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
90 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
91 } else { ## pearson or spearman |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
92 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
93 for(varI in varVi) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
94 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
95 varC <- rownames(varDF)[varI] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
96 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
97 mod <- lm(datMN[, varI] ~ facFcVn) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
98 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
99 plot(facFcVn, datMN[, varI], |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
100 xlab = facC, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
101 ylab = "", |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
102 pch = 18, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
103 main = paste0(varC, " (", adjC, " = ", signif(adjVn[varI], 2), ", R2 = ", signif(summary(mod)$r.squared, 2), ")")) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
104 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
105 abline(mod, col = "red") |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
106 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
107 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
108 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
109 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
110 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
111 dev.off() |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
112 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
113 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
114 } else if(tesC == "anova") { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
115 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
116 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
117 ## getting the names of the pairwise comparisons 'class1Vclass2' |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
118 prwVc <- rownames(TukeyHSD(aov(datMN[, 1] ~ facFcVn))[["facFcVn"]]) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
119 |
2
09799fc16bc6
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 2c0d4d97c208edca1ada2035a7b7af9c4eb31afe
ethevenot
parents:
0
diff
changeset
|
120 prwVc <- gsub("-", ".", prwVc, fixed = TRUE) ## 2016-08-05: '-' character in dataframe column names seems not to be converted to "." by write.table on ubuntu R-3.3.1 |
09799fc16bc6
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 2c0d4d97c208edca1ada2035a7b7af9c4eb31afe
ethevenot
parents:
0
diff
changeset
|
121 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
122 ## omnibus and post-hoc tests |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
123 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
124 aovMN <- t(apply(datMN, 2, function(varVn) { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
125 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
126 aovMod <- aov(varVn ~ facFcVn) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
127 pvaN <- summary(aovMod)[[1]][1, "Pr(>F)"] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
128 hsdMN <- TukeyHSD(aovMod)[["facFcVn"]] |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
129 c(pvaN, c(hsdMN[, c("diff", "p adj")])) |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
130 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
131 })) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
132 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
133 difVi <- 1:length(prwVc) + 1 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
134 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
135 ## difference of the means for each pairwise comparison |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
136 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
137 difMN <- aovMN[, difVi] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
138 colnames(difMN) <- paste0(varPfxC, prwVc, "_dif") |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
139 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
140 ## correction for multiple testing |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
141 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
142 aovMN <- aovMN[, -difVi, drop = FALSE] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
143 aovMN <- apply(aovMN, 2, function(pvaVn) p.adjust(pvaVn, method = adjC)) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
144 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
145 ## significance coding (0 = not significant, 1 = significant) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
146 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
147 adjVn <- aovMN[, 1] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
148 sigVn <- as.numeric(adjVn < thrN) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
149 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
150 aovMN <- aovMN[, -1, drop = FALSE] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
151 colnames(aovMN) <- paste0(varPfxC, prwVc, "_", adjC) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
152 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
153 aovSigMN <- aovMN < thrN |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
154 mode(aovSigMN) <- "numeric" |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
155 colnames(aovSigMN) <- paste0(varPfxC, prwVc, "_sig") |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
156 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
157 ## final aggregated table |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
158 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
159 resMN <- cbind(adjVn, sigVn, difMN, aovMN, aovSigMN) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
160 colnames(resMN)[1:2] <- paste0(varPfxC, c(adjC, "sig")) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
161 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
162 varDF <- cbind.data.frame(varDF, as.data.frame(resMN)) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
163 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
164 ## graphic |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
165 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
166 pdf(pdfC, onefile = TRUE) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
167 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
168 for(varI in 1:nrow(varDF)) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
169 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
170 if(sum(aovSigMN[varI, ]) > 0) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
171 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
172 varC <- rownames(varDF)[varI] |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
173 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
174 boxplot(datMN[, varI] ~ facFcVn, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
175 main = paste0(varC, " (", adjC, " = ", signif(adjVn[varI], 2), ")")) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
176 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
177 for(prwI in 1:length(prwVc)) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
178 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
179 if(aovSigMN[varI, paste0(varPfxC, prwVc[prwI], "_sig")] == 1) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
180 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
181 claVc <- unlist(strsplit(prwVc[prwI], ".", fixed = TRUE)) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
182 aovClaVl <- facFcVn %in% claVc |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
183 aovFc <- facFcVn[aovClaVl, drop = TRUE] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
184 aovVc <- as.character(aovFc) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
185 names(aovVc) <- rownames(samDF)[aovClaVl] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
186 boxF(aovFc, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
187 datMN[aovClaVl, varI], |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
188 paste0(varC, " (", adjC, " = ", signif(aovMN[varI, paste0(varPfxC, prwVc[prwI], "_", adjC)], 2), ")"), |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
189 aovVc) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
190 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
191 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
192 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
193 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
194 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
195 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
196 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
197 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
198 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
199 dev.off() |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
200 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
201 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
202 } else if(tesC == "kruskal") { |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
203 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
204 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
205 ## getting the names of the pairwise comparisons 'class1.class2' |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
206 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
207 nemMN <- posthoc.kruskal.nemenyi.test(datMN[, 1], facFcVn, "Tukey")[["p.value"]] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
208 nemVl <- c(lower.tri(nemMN, diag = TRUE)) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
209 nemClaMC <- cbind(rownames(nemMN)[c(row(nemMN))][nemVl], |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
210 colnames(nemMN)[c(col(nemMN))][nemVl]) |
2
09799fc16bc6
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 2c0d4d97c208edca1ada2035a7b7af9c4eb31afe
ethevenot
parents:
0
diff
changeset
|
211 nemNamVc <- paste0(nemClaMC[, 1], ".", nemClaMC[, 2]) |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
212 pfxNemVc <- paste0(varPfxC, nemNamVc) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
213 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
214 ## omnibus and post-hoc tests |
2
09799fc16bc6
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 2c0d4d97c208edca1ada2035a7b7af9c4eb31afe
ethevenot
parents:
0
diff
changeset
|
215 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
216 nemMN <- t(apply(datMN, 2, function(varVn) { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
217 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
218 pvaN <- kruskal.test(varVn ~ facFcVn)[["p.value"]] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
219 varNemMN <- posthoc.kruskal.nemenyi.test(varVn, facFcVn, "Tukey")[["p.value"]] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
220 c(pvaN, c(varNemMN)) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
221 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
222 })) |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
223 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
224 ## correction for multiple testing |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
225 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
226 nemMN <- apply(nemMN, 2, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
227 function(pvaVn) p.adjust(pvaVn, method = adjC)) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
228 adjVn <- nemMN[, 1] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
229 sigVn <- as.numeric(adjVn < thrN) |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
230 nemMN <- nemMN[, c(FALSE, nemVl)] |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
231 colnames(nemMN) <- paste0(pfxNemVc, "_", adjC) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
232 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
233 ## significance coding (0 = not significant, 1 = significant) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
234 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
235 nemSigMN <- nemMN < thrN |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
236 mode(nemSigMN) <- "numeric" |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
237 colnames(nemSigMN) <- paste0(pfxNemVc, "_sig") |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
238 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
239 ## difference of the medians for each pairwise comparison |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
240 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
241 difMN <- sapply(1:nrow(nemClaMC), function(prwI) { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
242 prwVc <- nemClaMC[prwI, ] |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
243 prwVi <- which(facFcVn %in% prwVc) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
244 prwFacFc <- factor(as.character(facFcVn)[prwVi], levels = prwVc) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
245 apply(datMN[prwVi, ], 2, function(varVn) -diff(as.numeric(tapply(varVn, prwFacFc, function(x) median(x, na.rm = TRUE))))) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
246 }) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
247 colnames(difMN) <- gsub("_sig", "_dif", colnames(nemSigMN)) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
248 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
249 ## final aggregated table |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
250 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
251 resMN <- cbind(adjVn, sigVn, difMN, nemMN, nemSigMN) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
252 colnames(resMN)[1:2] <- paste0(varPfxC, c(adjC, "sig")) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
253 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
254 varDF <- cbind.data.frame(varDF, as.data.frame(resMN)) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
255 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
256 ## graphic |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
257 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
258 pdf(pdfC, onefile = TRUE) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
259 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
260 for(varI in 1:nrow(varDF)) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
261 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
262 if(sum(nemSigMN[varI, ]) > 0) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
263 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
264 varC <- rownames(varDF)[varI] |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
265 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
266 boxplot(datMN[, varI] ~ facFcVn, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
267 main = paste0(varC, " (", adjC, " = ", signif(adjVn[varI], 2), ")")) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
268 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
269 for(nemI in 1:length(nemNamVc)) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
270 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
271 if(nemSigMN[varI, paste0(varPfxC, nemNamVc[nemI], "_sig")] == 1) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
272 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
273 nemClaVc <- nemClaMC[nemI, ] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
274 nemClaVl <- facFcVn %in% nemClaVc |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
275 nemFc <- facFcVn[nemClaVl, drop = TRUE] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
276 nemVc <- as.character(nemFc) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
277 names(nemVc) <- rownames(samDF)[nemClaVl] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
278 boxF(nemFc, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
279 datMN[nemClaVl, varI], |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
280 paste0(varC, " (", adjC, " = ", signif(nemMN[varI, paste0(varPfxC, nemNamVc[nemI], "_", adjC)], 2), ")"), |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
281 nemVc) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
282 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
283 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
284 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
285 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
286 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
287 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
288 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
289 } |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
290 |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
291 dev.off() |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
292 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
293 } |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
294 |
0
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
295 names(sigVn) <- rownames(varDF) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
296 sigSumN <- sum(sigVn, na.rm = TRUE) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
297 if(sigSumN) { |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
298 cat("\nThe following ", sigSumN, " variable", ifelse(sigSumN > 1, "s", ""), " (", round(sigSumN / length(sigVn) * 100), "%) ", ifelse(sigSumN > 1, "were", "was"), " found significant at the ", thrN, " level:\n", sep = "") |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
299 cat(paste(rownames(varDF)[sigVn > 0], collapse = "\n"), "\n", sep = "") |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
300 } else |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
301 cat("\nNo significant variable found at the selected ", thrN, " level\n", sep = "") |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
302 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
303 options(stingsAsFactors = strAsFacL) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
304 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
305 return(varDF) |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
306 |
ef64d3752050
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab
ethevenot
parents:
diff
changeset
|
307 } |
3
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
308 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
309 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
310 boxF <- function(xFc, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
311 yVn, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
312 maiC, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
313 xVc) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
314 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
315 boxLs <- boxplot(yVn ~ xFc, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
316 main = maiC) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
317 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
318 outVn <- boxLs[["out"]] |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
319 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
320 if(length(outVn)) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
321 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
322 for(outI in 1:length(outVn)) { |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
323 levI <- which(levels(xFc) == xVc[names(outVn)[outI]]) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
324 text(levI, |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
325 outVn[outI], |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
326 labels = names(outVn)[outI], |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
327 pos = ifelse(levI == 2, 2, 4)) |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
328 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
329 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
330 } |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
331 |
140290de7986
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 27bc6157f43574f038b3fb1be1f46ce4786e24b1
ethevenot
parents:
2
diff
changeset
|
332 } |