annotate ASCA.PlotScoresPerLevel_w4m.R @ 0:93312041f1d5 draft default tip

planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
author marie-tremblay-metatoul
date Fri, 21 Sep 2018 05:51:14 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
1 ASCA.PlotScoresPerLevel_w4m <- function (asca, ee, pcs="1,2", interaction=0, factorName="", factorModalite)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
2 {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
3 pcs <- as.numeric(strsplit(pcs, split=",")[[1]])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
4 y <- (asca[[ee]]$means.matrix + asca$remainder) %*% asca[[ee]]$svd$v
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
5 t.list.x <- list()
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
6 t.list.y <- list()
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
7 list.color.pattern <- list()
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
8 color.per.variable <- rep(0, dim(asca$data)[1])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
9 pattern.per.variable <- rep(0, dim(asca$data)[1])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
10 kColOptions <- c(24, 552, 254, 26, 84, 51, 652, 68, 76, 96,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
11 10, 60, 33, 245, 147, 12, 26, 164, 181, 52, 512, 344,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
12 201, 111)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
13 kPointOptions <- 1:30
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
14 for (p in 1:dim(asca[[ee]]$level.combinations$row.pattern)[1]) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
15 if (length(asca[[ee]]$level.combinations$row.pattern[p,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
16 ]) == 1) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
17 list.color.pattern[[p]] <- c(kColOptions[p], kPointOptions[p])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
18 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
19 else if (length(asca[[ee]]$level.combinations$row.pattern[p,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
20 ]) == 2) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
21 list.color.pattern[[p]] <- c(kColOptions[asca[[ee]]$level.combinations$row.pattern[p,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
22 1]], kPointOptions[asca[[ee]]$level.combinations$row.pattern[p,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
23 2]])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
24 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
25 else {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
26 list.color.pattern[[p]] <- c(kColOptions[asca[[ee]]$level.combinations$row.pattern[p,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
27 1]]%%9, floor(kPointOptions[asca[[ee]]$level.combinations$row.pattern[p,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
28 2]]/9))
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
29 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
30 color.per.variable[asca[[ee]]$level.combinations$indices.per.pattern[[p]]] <- list.color.pattern[[p]][1]
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
31 pattern.per.variable[asca[[ee]]$level.combinations$indices.per.pattern[[p]]] <- list.color.pattern[[p]][2]
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
32 t.list.x[[p]] <- y[asca[[ee]]$level.combinations$indices.per.pattern[[p]],
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
33 pcs[1]]
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
34 t.list.y[[p]] <- y[asca[[ee]]$level.combinations$indices.per.pattern[[p]],
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
35 pcs[2]]
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
36 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
37 legend.colors.patterns <- do.call(rbind, list.color.pattern)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
38 if (interaction != 1){
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
39 titre <- paste("PC", pcs[1], " vs PC", pcs[2], " - Factor ", factorName, sep="")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
40 }else {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
41 titre <- paste("PC", pcs[1], " vs PC", pcs[2], " - Interaction", sep="")
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
42 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
43 plot(asca[[ee]]$svd$t[, pcs[1]], asca[[ee]]$svd$t[, pcs[2]],
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
44 xlim=range(c(min(unlist(t.list.x)), max(unlist(t.list.x)))),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
45 ylim=range(c(min(unlist(t.list.y)), max(unlist(t.list.y)))),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
46 main=titre,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
47 xlab=paste("PC", pcs[1], " (", formatC(asca[[ee]]$svd$var.explained[pcs[1]] * 100, digits=2, format="f"), "%)", sep=""),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
48 ylab=paste("PC", pcs[2], " (", formatC(asca[[ee]]$svd$var.explained[pcs[2]] * 100, digits=2, format="f"), "%)", sep=""),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
49 cex=1.5, lwd=3, col=colors()[color.per.variable],
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
50 pch=pattern.per.variable)
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
51 # if (interaction != 1){
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
52 legend(x="bottomright", legend=factorModalite,
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
53 cex=0.8, col=colors()[legend.colors.patterns[, 1]], pch=legend.colors.patterns[, 2])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
54 # }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
55 # else {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
56 # legend(x="bottomright", apply(asca[[ee]]$level.combinations$row.patterns, 1, paste, collapse=" "),
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
57 # cex=0.8, col=colors()[legend.colors.patterns[, 1]], pch=legend.colors.patterns[, 2])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
58 # }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
59
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
60 for (p in 1:length(t.list.x)) {
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
61 points(t.list.x[[p]], t.list.y[[p]], col=colors()[list.color.pattern[[p]][1]],
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
62 pch=list.color.pattern[[p]][2])
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
63 }
93312041f1d5 planemo upload for repository https://github.com/workflow4metabolomics/ascaw4m commit 7ea9b0f8abc5a60c2c04fd2098788497f14766b6
marie-tremblay-metatoul
parents:
diff changeset
64 }