comparison checkformat_script.R @ 4:9590fac86f63 draft

planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 46e92656192f2714265cc525b283c7cbb87b9093
author ethevenot
date Wed, 28 Feb 2018 05:47:44 -0500
parents 80a38d36f946
children
comparison
equal deleted inserted replaced
3:80a38d36f946 4:9590fac86f63
80 } 80 }
81 81
82 if(nrow(datMN) != nrow(samDF)) { 82 if(nrow(datMN) != nrow(samDF)) {
83 if(nrow(datMN) > nrow(samDF)) { 83 if(nrow(datMN) > nrow(samDF)) {
84 print(setdiff(rownames(datMN), rownames(samDF))) 84 print(setdiff(rownames(datMN), rownames(samDF)))
85 stop("The sample names above from dataMatrix were not found in sampleMetadata") 85 stop("The sample names above from dataMatrix were not found in sampleMetadata",
86 call. = FALSE)
86 } else { 87 } else {
87 print(setdiff(rownames(samDF), rownames(datMN))) 88 print(setdiff(rownames(samDF), rownames(datMN)))
88 stop("The sample names above from sampleMetadata were not found in dataMatrix") 89 stop("The sample names above from sampleMetadata were not found in dataMatrix",
90 call. = FALSE)
89 } 91 }
90 } 92 }
91 93
92 if(ncol(datMN) != nrow(varDF)) { 94 if(ncol(datMN) != nrow(varDF)) {
93 if(ncol(datMN) > nrow(varDF)) { 95 if(ncol(datMN) > nrow(varDF)) {
94 print(setdiff(colnames(datMN), rownames(varDF))) 96 print(setdiff(colnames(datMN), rownames(varDF)))
95 stop("The variable names above from dataMatrix were not found in variableMetadata") 97 stop("The variable names above from dataMatrix were not found in variableMetadata",
98 call. = FALSE)
96 } else { 99 } else {
97 print(setdiff(rownames(varDF), colnames(datMN))) 100 print(setdiff(rownames(varDF), colnames(datMN)))
98 stop("The variable names above from variableMetadata were not found in dataMatrix") 101 stop("The variable names above from variableMetadata were not found in dataMatrix",
102 call. = FALSE)
99 } 103 }
100 } 104 }
101 105
102 106
103 ## making sample and variable names (optional) 107 ## making sample and variable names (optional)
179 183
180 return(resLs) 184 return(resLs)
181 185
182 } ## end of checkAndReadF 186 } ## end of checkAndReadF
183 187
184
185
186
187 ## if(!identical(rownames(datMN), rownames(samDF))) {
188 ## ## checking sample names
189
190 ## chkL <- FALSE
191
192 ## datSamDifVc <- setdiff(rownames(datMN), rownames(samDF))
193
194 ## if(length(datSamDifVc)) {
195 ## cat("\nThe following samples were found in the dataMatrix column names but not in the sampleMetadata row names:\n", sep="")
196 ## print(cbind.data.frame(col = as.numeric(sapply(datSamDifVc, function(samC) which(rownames(datMN) == samC))),
197 ## name = datSamDifVc))
198 ## }
199
200 ## samDatDifVc <- setdiff(rownames(samDF), rownames(datMN))
201
202 ## if(length(samDatDifVc)) {
203 ## cat("\n\nThe following samples were found in the sampleMetadata row names but not in the dataMatrix column names:\n", sep="")
204 ## print(cbind.data.frame(row = as.numeric(sapply(samDatDifVc, function(samC) which(rownames(samDF) == samC))),
205 ## name = samDatDifVc))
206 ## }
207
208 ## if(nrow(datMN) != nrow(samDF)) {
209 ## cat("\n\nThe dataMatrix has ", nrow(datMN), " columns (ie samples) whereas the sampleMetadata has ", nrow(samDF), " rows\n", sep="")
210 ## } else if(identical(gsub("^X", "", rownames(datMN)), rownames(samDF))) {
211 ## cat("\n\nThe dataMatrix column names start with an 'X' but not the sampleMetadata row names\n", sep="")
212 ## } else if(identical(gsub("^X", "", rownames(samDF)), rownames(datMN))) {
213 ## cat("\n\nThe sampleMetadata row names start with an 'X' but not the dataMatrix column names\n", sep="")
214 ## } else if(identical(sort(rownames(datMN)), sort(rownames(samDF)))) {
215 ## cat("\n\nThe dataMatrix column names and the sampleMetadata row names are not in the same order:\n", sep="")
216 ## print(cbind.data.frame(indice = 1:nrow(datMN),
217 ## dataMatrix_columnnames=rownames(datMN),
218 ## sampleMetadata_rownames=rownames(samDF))[rownames(datMN) != rownames(samDF), , drop = FALSE])
219 ## } else {
220 ## cat("\n\nThe dataMatrix column names and the sampleMetadata row names are not identical:\n", sep="")
221 ## print(cbind.data.frame(indice = 1:nrow(datMN),
222 ## dataMatrix_columnnames=rownames(datMN),
223 ## sampleMetadata_rownames=rownames(samDF))[rownames(datMN) != rownames(samDF), , drop = FALSE])
224 ## }
225
226 ## }
227 ## datRowVc <- rownames(datMN)
228 ## datRowMakVc <- make.names(datRowVc, unique = TRUE)
229 ## if(datRowMakVc != datRowVc) {
230 ## rownames(datMN) <- datRowMakVc
231 ## cat("\n\nMessage: The sample names of the dataMatrix have been converted to the standard R format\n")
232 ## }
233
234 ## datColVc <- colnames(datMN)
235 ## datColMakVc <- make.names(datColVc, unique = TRUE)
236 ## if(datColMakVc != datColVc) {
237 ## colnames(datMN) <- datColMakVc
238 ## cat("\n\nMessage: The variable names of the dataMatrix have been converted to the standard R format\n")
239 ## }
240
241 ## samRowVc <- rownames(datMN)
242 ## samRowMakVc <- make.names(samRowVc, unique = TRUE)
243 ## if(samRowMakVc != samRowVc) {
244 ## rownames(datMN) <- samRowMakVc
245 ## cat("\n\nMessage: The sample names of the sampleMetadata have been converted to the standard R format\n")
246 ## }
247
248 ## datRowVc <- rownames(datMN)
249 ## datRowMakVc <- make.names(datRowVc, unique = TRUE)
250 ## if(datRowMakVc != datRowVc) {
251 ## rownames(datMN) <- datRowMakVc
252 ## cat("\n\nMessage: The sample names of the dataMatrix have been converted to the standard R format\n")
253 ## }
254
255 ## }
256
257 ## checking names (optional)
258
259
260
261
262 ## datRowMakVc <- make.names(datRowVc, unique = TRUE)
263 ## if(datRowMakVc != datRowVc) {
264 ## if(makNamL) {
265 ## rownames(datMN) <- datRowMakVc
266 ## cat("\n\nMessage: The sample names of the dataMatrix have been converted to the standard R format; select the make names argument to convert them\n")
267 ## } else {
268 ## cat("\n\nWarning: Some of the sample names of the dataMatrix are not in the standard R format; select the make names argument to convert them\n")
269 ## }
270
271 ## if(makNamL) {
272
273 ## rownames(datMN) <- make.names(rownames(datMN), unique = TRUE)
274 ## colnames(datMN) <- make.names(colnames(datMN), unique = TRUE)
275 ## rownames(samDF) <- make.names(rownames(samDF), unique = TRUE)
276 ## rownames(varDF) <- make.names(rownames(varDF), unique = TRUE)
277
278 ## }
279 ## checking sample names
280
281 ## if(nrow(datMN) == nrow(samDF)) {
282
283
284
285 ## }
286
287 ## chkL <- FALSE
288
289 ## datSamDifVc <- setdiff(rownames(datMN), rownames(samDF))
290
291 ## if(length(datSamDifVc)) {
292 ## cat("\nThe following samples were found in the dataMatrix column names but not in the sampleMetadata row names:\n", sep="")
293 ## print(cbind.data.frame(col = as.numeric(sapply(datSamDifVc, function(samC) which(rownames(datMN) == samC))),
294 ## name = datSamDifVc))
295 ## }
296
297 ## samDatDifVc <- setdiff(rownames(samDF), rownames(datMN))
298
299 ## if(length(samDatDifVc)) {
300 ## cat("\n\nThe following samples were found in the sampleMetadata row names but not in the dataMatrix column names:\n", sep="")
301 ## print(cbind.data.frame(row = as.numeric(sapply(samDatDifVc, function(samC) which(rownames(samDF) == samC))),
302 ## name = samDatDifVc))
303 ## }
304
305 ## if(nrow(datMN) != nrow(samDF)) {
306 ## cat("\n\nThe dataMatrix has ", nrow(datMN), " columns (ie samples) whereas the sampleMetadata has ", nrow(samDF), " rows\n", sep="")
307 ## } else if(identical(gsub("^X", "", rownames(datMN)), rownames(samDF))) {
308 ## cat("\n\nThe dataMatrix column names start with an 'X' but not the sampleMetadata row names\n", sep="")
309 ## } else if(identical(gsub("^X", "", rownames(samDF)), rownames(datMN))) {
310 ## cat("\n\nThe sampleMetadata row names start with an 'X' but not the dataMatrix column names\n", sep="")
311 ## } else if(identical(sort(rownames(datMN)), sort(rownames(samDF)))) {
312 ## cat("\n\nThe dataMatrix column names and the sampleMetadata row names are not in the same order:\n", sep="")
313 ## print(cbind.data.frame(indice = 1:nrow(datMN),
314 ## dataMatrix_columnnames=rownames(datMN),
315 ## sampleMetadata_rownames=rownames(samDF))[rownames(datMN) != rownames(samDF), , drop = FALSE])
316 ## } else {
317 ## cat("\n\nThe dataMatrix column names and the sampleMetadata row names are not identical:\n", sep="")
318 ## print(cbind.data.frame(indice = 1:nrow(datMN),
319 ## dataMatrix_columnnames=rownames(datMN),
320 ## sampleMetadata_rownames=rownames(samDF))[rownames(datMN) != rownames(samDF), , drop = FALSE])
321 ## }
322
323 ## }
324
325
326 ## if(!identical(colnames(datMN), rownames(varDF))) {
327 ## ## checking variable names
328
329 ## chkL <- FALSE
330
331 ## datVarDifVc <- setdiff(colnames(datMN), rownames(varDF))
332
333 ## if(length(datVarDifVc)) {
334 ## cat("\nThe following variables were found in the dataMatrix row names but not in the variableMetadata row names:\n", sep="")
335 ## print(cbind.data.frame(row = as.numeric(sapply(datVarDifVc, function(varC) which(colnames(datMN) == varC))),
336 ## name = datVarDifVc))
337
338 ## }
339
340 ## varDatDifVc <- setdiff(rownames(varDF), colnames(datMN))
341
342 ## if(length(varDatDifVc)) {
343 ## cat("\n\nThe following variables were found in the variableMetadata row names but not in the dataMatrix row names:\n", sep="")
344 ## print(cbind.data.frame(row = as.numeric(sapply(varDatDifVc, function(varC) which(rownames(varDF) == varC))),
345 ## name = varDatDifVc))
346 ## }
347
348 ## if(ncol(datMN) != nrow(varDF)) {
349 ## cat("\n\nThe dataMatrix has ", nrow(datMN), " rows (ie variables) whereas the variableMetadata has ", nrow(varDF), " rows\n", sep="")
350 ## } else if(identical(sort(colnames(datMN)), sort(rownames(varDF)))) {
351 ## cat("\n\nThe dataMatrix row names and the variableMetadata row names are not in the same order:\n", sep="")
352 ## print(cbind.data.frame(row = 1:ncol(datMN),
353 ## dataMatrix_rownames=colnames(datMN),
354 ## variableMetadata_rownames=rownames(varDF))[colnames(datMN) != rownames(varDF), , drop = FALSE])
355 ## } else {
356 ## cat("\n\nThe dataMatrix row names and the variableMetadata row names are not identical:\n", sep="")
357 ## print(cbind.data.frame(row = 1:ncol(datMN),
358 ## dataMatrix_rownames=colnames(datMN),
359 ## variableMetadata_rownames=rownames(varDF))[colnames(datMN) != rownames(varDF), , drop = FALSE])
360 ## }
361 ## }
362 ## checkF <- function(datInpMN,
363 ## samInpDF,
364 ## varInpDF) {
365
366 ## mode(datInpMN) == "numeric" &&
367 ## identical(rownames(datInpMN), rownames(samInpDF)) &&
368 ## identical(colnames(datInpMN), rownames(varInpDF))
369
370
371 ## }