Mercurial > repos > ethevenot > transformation
annotate transformation_script.R @ 2:0ccfc3e15710 draft
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit b0373e2f4702a572450205419e2d64579c24c9ae
| author | ethevenot |
|---|---|
| date | Tue, 06 Jun 2017 11:55:21 -0400 |
| parents | d9e05021553c |
| children |
| rev | line source |
|---|---|
|
0
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
1 ## Etienne Thevenot |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
2 ## W4M Core Development Team |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
3 ## etienne.thevenot@cea.fr |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
4 ## 2015-04-25 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
5 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
6 transformF <- function(datMN, |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
7 metC) { |
|
1
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
8 |
|
0
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
9 ## options |
|
1
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
10 |
|
0
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
11 optStrAsFacL <- options()[["stringsAsFactors"]] |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
12 options(stringsAsFactors = FALSE) |
|
1
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
13 |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
14 ## checking |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
15 |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
16 if(length(which(datMN < 0))) { |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
17 cat("\nThe 'dataMatrix' contains negative values\n") |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
18 sink() |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
19 stop("The 'dataMatrix' contains negative values", call. = FALSE) |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
20 } |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
21 |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
22 ## Number of missing values |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
23 nasN <- length(which(is.na(datMN))) |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
24 cat("\nMissing values in the 'dataMatrix': ", |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
25 nasN, |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
26 " (", |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
27 round(nasN / cumprod(dim(datMN))[2] * 100), |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
28 "%)\n", |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
29 sep="") |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
30 |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
31 ## Number of zero values |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
32 zerN <- length(which(datMN == 0)) |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
33 cat("\nZero values in the 'dataMatrix': ", |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
34 zerN, |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
35 " (", |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
36 round(zerN / cumprod(dim(datMN))[2] * 100), |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
37 "%)\n", |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
38 sep="") |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
39 |
|
0
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
40 ## transformation |
|
1
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
41 |
|
0
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
42 switch(metC, |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
43 log2 = { |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
44 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
45 cat("\n'log2' transformation\n", sep="") |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
46 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
47 trfMN <- log2(1 + datMN) |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
48 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
49 }, |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
50 log10 = { |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
51 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
52 cat("\n'log10' transformation\n", sep="") |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
53 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
54 trfMN <- log10(1 + datMN) |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
55 |
|
1
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
56 }, |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
57 sqrt = { |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
58 |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
59 cat("\n'Square root' transformation\n", sep="") |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
60 |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
61 trfMN <- sqrt(datMN) |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
62 |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
63 |
|
d9e05021553c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit c4b65942d74d5bdfd46e748c0040a8b5ebe4fd1d
ethevenot
parents:
0
diff
changeset
|
64 }) ## end of method |
|
0
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
65 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
66 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
67 ## returning |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
68 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
69 options(stringsAsFactors=optStrAsFacL) |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
70 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
71 return(trfMN) |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
72 |
|
eacea1349a7c
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
ethevenot
parents:
diff
changeset
|
73 } ## end of transformF |
