annotate checkFormat_script.R @ 0:0d8099822c49 draft

planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
author ethevenot
date Sat, 30 Jul 2016 12:06:35 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
1 ## Etienne Thevenot
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
2 ## CEA, MetaboHUB Paris
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
3 ## etienne.thevenot@cea.fr
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
4
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
5
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
6 ## Reads the dataMatrix, sampleMetadata, and variableMetadata .tsv files
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
7 ## and checks the formats
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
8 readAndCheckF <- function(datFilC="dataMatrix.tsv",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
9 samFilC="sampleMetadata.tsv",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
10 varFilC="variableMetadata.tsv") {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
11
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
12 ## options
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
13
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
14 optStrAsFacL <- options()[["stringsAsFactors"]]
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
15 options(stringsAsFactors = FALSE)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
16
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
17 ## checking that the tables have no duplicated row or column names
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
18
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
19 for(tabC in c("dat", "sam", "var")) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
20
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
21 tabNamC <- switch(tabC, dat="dataMatrix", sam="sampleMetadata", var="variableMetadata")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
22
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
23 rowVc <- read.table(eval(parse(text=paste0(tabC, "FilC"))),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
24 check.names = FALSE,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
25 header = TRUE,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
26 sep = "\t")[, 1]
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
27
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
28 colVc <- unlist(read.table(eval(parse(text=paste0(tabC, "FilC"))),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
29 check.names = FALSE,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
30 nrow=1,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
31 sep = "\t"))[-1]
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
32
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
33 if(any(duplicated(rowVc)))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
34 stop("The following row name(s) is/are duplicated in the ",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
35 tabNamC,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
36 " table: '",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
37 paste(rowVc[duplicated(rowVc)], collapse="', '"), "'",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
38 call.=FALSE)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
39
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
40 if(any(duplicated(colVc)))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
41 stop("The following column name(s) is/are duplicated in the ",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
42 tabNamC,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
43 " table: '",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
44 paste(colVc[duplicated(colVc)], collapse="', '"), "'",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
45 call.=FALSE)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
46
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
47 rowMakVc <- make.names(rowVc, unique = TRUE)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
48
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
49 rowDifVl <- rowVc != rowMakVc
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
50
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
51 if(any(rowDifVl)) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
52 rowDifDF <- data.frame(row = 1:length(rowVc),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
53 actual = rowVc,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
54 preferred = rowMakVc)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
55 rowDifDF <- rowDifDF[rowDifVl, , drop = FALSE]
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
56 cat("\n\nWarning: The following row names of the ",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
57 tabNamC,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
58 " table are not in the standard R format, which may result in errors when loading the data in some of the W4M modules:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
59 print(rowDifDF)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
60 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
61
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
62 colMakVc <- make.names(colVc, unique = TRUE)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
63
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
64 colDifVl <- colVc != colMakVc
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
65
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
66 if(any(colDifVl)) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
67 colDifDF <- data.frame(col = 1:length(colVc),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
68 actual = colVc,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
69 preferred = colMakVc)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
70 colDifDF <- colDifDF[colDifVl, , drop = FALSE]
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
71 cat("\n\nWarning: The following column names of the ",
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
72 tabNamC,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
73 " table are not in the standard R format, which may result in errors when loading the data in some of the W4M modules:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
74 print(colDifDF)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
75 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
76 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
77
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
78 ## reading tables
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
79
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
80 datMN <- t(as.matrix(read.table(datFilC,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
81 check.names = FALSE,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
82 header = TRUE,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
83 row.names = 1,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
84 sep = "\t")))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
85
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
86 samDF <- read.table(samFilC,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
87 check.names = FALSE,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
88 header = TRUE,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
89 row.names = 1,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
90 sep = "\t")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
91
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
92 varDF <- read.table(varFilC,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
93 check.names = FALSE,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
94 header = TRUE,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
95 row.names = 1,
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
96 sep = "\t")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
97
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
98 ## checking formats
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
99
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
100 chkL <- TRUE
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
101
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
102 if(!identical(rownames(datMN), rownames(samDF))) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
103 ## checking sample names
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
104
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
105 chkL <- FALSE
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
106
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
107 datSamDifVc <- setdiff(rownames(datMN), rownames(samDF))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
108
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
109 if(length(datSamDifVc)) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
110 cat("\nThe following samples were found in the dataMatrix column names but not in the sampleMetadata row names:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
111 print(cbind.data.frame(col = as.numeric(sapply(datSamDifVc, function(samC) which(rownames(datMN) == samC))),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
112 name = datSamDifVc))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
113 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
114
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
115 samDatDifVc <- setdiff(rownames(samDF), rownames(datMN))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
116
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
117 if(length(samDatDifVc)) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
118 cat("\n\nThe following samples were found in the sampleMetadata row names but not in the dataMatrix column names:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
119 print(cbind.data.frame(row = as.numeric(sapply(samDatDifVc, function(samC) which(rownames(samDF) == samC))),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
120 name = samDatDifVc))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
121 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
122
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
123 if(nrow(datMN) != nrow(samDF)) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
124 cat("\n\nThe dataMatrix has ", nrow(datMN), " columns (ie samples) whereas the sampleMetadata has ", nrow(samDF), " rows\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
125 } else if(identical(gsub("^X", "", rownames(datMN)), rownames(samDF))) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
126 cat("\n\nThe dataMatrix column names start with an 'X' but not the sampleMetadata row names\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
127 } else if(identical(gsub("^X", "", rownames(samDF)), rownames(datMN))) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
128 cat("\n\nThe sampleMetadata row names start with an 'X' but not the dataMatrix column names\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
129 } else if(identical(sort(rownames(datMN)), sort(rownames(samDF)))) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
130 cat("\n\nThe dataMatrix column names and the sampleMetadata row names are not in the same order:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
131 print(cbind.data.frame(indice = 1:nrow(datMN),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
132 dataMatrix_columnnames=rownames(datMN),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
133 sampleMetadata_rownames=rownames(samDF))[rownames(datMN) != rownames(samDF), , drop = FALSE])
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
134 } else {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
135 cat("\n\nThe dataMatrix column names and the sampleMetadata row names are not identical:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
136 print(cbind.data.frame(indice = 1:nrow(datMN),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
137 dataMatrix_columnnames=rownames(datMN),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
138 sampleMetadata_rownames=rownames(samDF))[rownames(datMN) != rownames(samDF), , drop = FALSE])
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
139 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
140
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
141 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
142
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
143 if(!identical(colnames(datMN), rownames(varDF))) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
144 ## checking variable names
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
145
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
146 chkL <- FALSE
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
147
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
148 datVarDifVc <- setdiff(colnames(datMN), rownames(varDF))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
149
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
150 if(length(datVarDifVc)) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
151 cat("\nThe following variables were found in the dataMatrix row names but not in the variableMetadata row names:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
152 print(cbind.data.frame(row = as.numeric(sapply(datVarDifVc, function(varC) which(colnames(datMN) == varC))),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
153 name = datVarDifVc))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
154
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
155 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
156
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
157 varDatDifVc <- setdiff(rownames(varDF), colnames(datMN))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
158
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
159 if(length(varDatDifVc)) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
160 cat("\n\nThe following variables were found in the variableMetadata row names but not in the dataMatrix row names:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
161 print(cbind.data.frame(row = as.numeric(sapply(varDatDifVc, function(varC) which(rownames(varDF) == varC))),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
162 name = varDatDifVc))
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
163 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
164
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
165 if(ncol(datMN) != nrow(varDF)) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
166 cat("\n\nThe dataMatrix has ", nrow(datMN), " rows (ie variables) whereas the variableMetadata has ", nrow(varDF), " rows\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
167 } else if(identical(sort(colnames(datMN)), sort(rownames(varDF)))) {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
168 cat("\n\nThe dataMatrix row names and the variableMetadata row names are not in the same order:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
169 print(cbind.data.frame(row = 1:ncol(datMN),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
170 dataMatrix_rownames=colnames(datMN),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
171 variableMetadata_rownames=rownames(varDF))[colnames(datMN) != rownames(varDF), , drop = FALSE])
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
172 } else {
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
173 cat("\n\nThe dataMatrix row names and the variableMetadata row names are not identical:\n", sep="")
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
174 print(cbind.data.frame(row = 1:ncol(datMN),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
175 dataMatrix_rownames=colnames(datMN),
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
176 variableMetadata_rownames=rownames(varDF))[colnames(datMN) != rownames(varDF), , drop = FALSE])
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
177 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
178 }
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
179
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
180 options(stringsAsFactors=optStrAsFacL)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
181
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
182 resLs <- list(chkL=chkL)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
183
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
184 return(resLs)
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
185
0d8099822c49 planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 217d97da5c733c3628997666c73867e81af0a0ee
ethevenot
parents:
diff changeset
186 } ## end of checkAndReadF