annotate checkformat_script.R @ 3:7f093d78a58c draft default tip

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