Mercurial > repos > ethevenot > checkformat
annotate checkformat_script.R @ 5:e7c5811ec12f draft default tip
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 6b7aa0db6cebdb8acfac0a07291647947260a310
author | ethevenot |
---|---|
date | Thu, 01 Mar 2018 05:07:38 -0500 |
parents | 9590fac86f63 |
children |
rev | line source |
---|---|
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
1 ## Etienne Thevenot |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
2 ## CEA, MetaboHUB Paris |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
3 ## etienne.thevenot@cea.fr |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
4 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
5 |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
6 |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
7 ## Reads the dataMatrix, sampleMetadata, and variableMetadata .tsv files |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
8 ## and checks the formats |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
9 readAndCheckF <- function(datFilC="dataMatrix.tsv", |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
10 samFilC="sampleMetadata.tsv", |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
11 varFilC="variableMetadata.tsv", |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
12 makNamL) { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
13 |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
14 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
15 ## options |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
16 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
17 optStrAsFacL <- options()[["stringsAsFactors"]] |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
18 options(stringsAsFactors = FALSE) |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
19 |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
20 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
21 ## checking that the tables have no duplicated row or column names |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
22 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
23 for(tabC in c("dat", "sam", "var")) { |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
24 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
25 tabNamC <- switch(tabC, dat="dataMatrix", sam="sampleMetadata", var="variableMetadata") |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
26 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
27 rowVc <- read.table(eval(parse(text=paste0(tabC, "FilC"))), |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
28 check.names = FALSE, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
29 header = TRUE, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
30 sep = "\t")[, 1] |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
31 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
32 colVc <- unlist(read.table(eval(parse(text=paste0(tabC, "FilC"))), |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
33 check.names = FALSE, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
34 nrow=1, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
35 sep = "\t"))[-1] |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
36 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
37 if(any(duplicated(rowVc))) |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
38 stop("The following row name(s) is/are duplicated in the ", |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
39 tabNamC, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
40 " table: '", |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
41 paste(rowVc[duplicated(rowVc)], collapse="', '"), "'", |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
42 call.=FALSE) |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
43 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
44 if(any(duplicated(colVc))) |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
45 stop("The following column name(s) is/are duplicated in the ", |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
46 tabNamC, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
47 " table: '", |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
48 paste(colVc[duplicated(colVc)], collapse="', '"), "'", |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
49 call.=FALSE) |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
50 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
51 } |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
52 |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
53 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
54 ## reading tables |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
55 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
56 datMN <- t(as.matrix(read.table(datFilC, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
57 check.names = FALSE, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
58 header = TRUE, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
59 row.names = 1, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
60 sep = "\t"))) |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
61 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
62 samDF <- read.table(samFilC, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
63 check.names = FALSE, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
64 header = TRUE, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
65 row.names = 1, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
66 sep = "\t") |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
67 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
68 varDF <- read.table(varFilC, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
69 check.names = FALSE, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
70 header = TRUE, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
71 row.names = 1, |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
72 sep = "\t") |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
73 |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
74 |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
75 ## checking that dataMatrix is numeric and that the sample and variable numbers are coherent |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
76 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
77 if(mode(datMN) != "numeric") { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
78 stop("The dataMatrix is not of the 'numeric' type", |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
79 call. = FALSE) |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
80 } |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
81 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
82 if(nrow(datMN) != nrow(samDF)) { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
83 if(nrow(datMN) > nrow(samDF)) { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
84 print(setdiff(rownames(datMN), rownames(samDF))) |
4
9590fac86f63
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 46e92656192f2714265cc525b283c7cbb87b9093
ethevenot
parents:
3
diff
changeset
|
85 stop("The sample names above from dataMatrix were not found in sampleMetadata", |
9590fac86f63
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 46e92656192f2714265cc525b283c7cbb87b9093
ethevenot
parents:
3
diff
changeset
|
86 call. = FALSE) |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
87 } else { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
88 print(setdiff(rownames(samDF), rownames(datMN))) |
4
9590fac86f63
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 46e92656192f2714265cc525b283c7cbb87b9093
ethevenot
parents:
3
diff
changeset
|
89 stop("The sample names above from sampleMetadata were not found in dataMatrix", |
9590fac86f63
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 46e92656192f2714265cc525b283c7cbb87b9093
ethevenot
parents:
3
diff
changeset
|
90 call. = FALSE) |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
91 } |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
92 } |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
93 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
94 if(ncol(datMN) != nrow(varDF)) { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
95 if(ncol(datMN) > nrow(varDF)) { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
96 print(setdiff(colnames(datMN), rownames(varDF))) |
4
9590fac86f63
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 46e92656192f2714265cc525b283c7cbb87b9093
ethevenot
parents:
3
diff
changeset
|
97 stop("The variable names above from dataMatrix were not found in variableMetadata", |
9590fac86f63
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 46e92656192f2714265cc525b283c7cbb87b9093
ethevenot
parents:
3
diff
changeset
|
98 call. = FALSE) |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
99 } else { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
100 print(setdiff(rownames(varDF), colnames(datMN))) |
4
9590fac86f63
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 46e92656192f2714265cc525b283c7cbb87b9093
ethevenot
parents:
3
diff
changeset
|
101 stop("The variable names above from variableMetadata were not found in dataMatrix", |
9590fac86f63
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 46e92656192f2714265cc525b283c7cbb87b9093
ethevenot
parents:
3
diff
changeset
|
102 call. = FALSE) |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
103 } |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
104 } |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
105 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
106 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
107 ## making sample and variable names (optional) |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
108 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
109 newL <- FALSE |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
110 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
111 if(makNamL) { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
112 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
113 cat("\n\nMessage: Converting sample and variable names to the standard R format\n") |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
114 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
115 rownames(datMN) <- make.names(rownames(datMN), unique = TRUE) |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
116 colnames(datMN) <- make.names(colnames(datMN), unique = TRUE) |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
117 rownames(samDF) <- make.names(rownames(samDF), unique = TRUE) |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
118 rownames(varDF) <- make.names(rownames(varDF), unique = TRUE) |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
119 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
120 newL <- TRUE |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
121 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
122 } |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
123 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
124 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
125 ## checking sample and variable names |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
126 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
127 chkL <- TRUE |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
128 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
129 if(!identical(rownames(datMN), rownames(samDF))) { |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
130 |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
131 if(identical(sort(rownames(datMN)), sort(rownames(samDF)))) { |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
132 |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
133 cat("\n\nMessage: Re-ordering dataMatrix sample names to match sampleMetadata\n") |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
134 datMN <- datMN[rownames(samDF), , drop = FALSE] |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
135 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
136 stopifnot(identical(sort(rownames(datMN)), sort(rownames(samDF)))) |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
137 |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
138 newL <- TRUE |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
139 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
140 } else { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
141 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
142 cat("\n\nStop: The sample names of dataMatrix and sampleMetadata do not match:\n") |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
143 print(cbind.data.frame(indice = 1:nrow(datMN), |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
144 dataMatrix=rownames(datMN), |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
145 sampleMetadata=rownames(samDF))[rownames(datMN) != rownames(samDF), , drop = FALSE]) |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
146 chkL <- FALSE |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
147 |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
148 } |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
149 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
150 } |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
151 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
152 if(!identical(colnames(datMN), rownames(varDF))) { |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
153 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
154 if(identical(sort(colnames(datMN)), sort(rownames(varDF)))) { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
155 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
156 cat("\n\nMessage: Re-ordering dataMatrix variable names to match variableMetadata\n") |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
157 datMN <- datMN[, rownames(varDF), drop = FALSE] |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
158 |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
159 stopifnot(identical(sort(colnames(datMN)), sort(rownames(varDF)))) |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
160 |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
161 newL <- TRUE |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
162 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
163 } else { |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
164 |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
165 cat("\n\nStop: The variable names of dataMatrix and variableMetadata do not match:\n") |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
166 print(cbind.data.frame(indice = 1:ncol(datMN), |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
167 dataMatrix=colnames(datMN), |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
168 variableMetadata=rownames(varDF))[colnames(datMN) != rownames(varDF), , drop = FALSE]) |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
169 chkL <- FALSE |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
170 |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
171 } |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
172 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
173 } |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
174 |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
175 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
176 options(stringsAsFactors=optStrAsFacL) |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
177 |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
178 resLs <- list(chkL=chkL, |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
179 newL = newL, |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
180 datMN = datMN, |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
181 samDF = samDF, |
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
182 varDF = varDF) |
1
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
183 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
184 return(resLs) |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
185 |
e194eec8e70c
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 8ebfbfa8d9449c9bbfbf569851a30b1e33df0b3f
ethevenot
parents:
diff
changeset
|
186 } ## end of checkAndReadF |
3
80a38d36f946
planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
ethevenot
parents:
1
diff
changeset
|
187 |