annotate ipo4xcmsSet.r @ 10:57f180a8eaae draft default tip

planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
author workflow4metabolomics
date Mon, 11 Sep 2023 22:36:51 +0000
parents 364756ea5f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
1 #!/usr/bin/env Rscript
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
2 # Authors Gildas Le Corguille and Yann Guitton
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
3
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
4
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
5 # ----- PACKAGE -----
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
6 cat("\tSESSION INFO\n")
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
7
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
8 # Import the different functions
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
9 source_local <- function(fname) {
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
10 argv <- commandArgs(trailingOnly = FALSE)
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
11 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
12 source(paste(base_dir, fname, sep = "/"))
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
13 }
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
14 source_local("lib.r")
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
15
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
16 pkgs <- c("IPO", "batch")
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
17 loadAndDisplayPackages(pkgs)
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
18 cat("\n\n")
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
19 # ----- ARGUMENTS -----
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
20 cat("\tARGUMENTS INFO\n")
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
21 args <- parseCommandArgs(evaluate = FALSE) # interpretation of arguments given in command line as an R list of objects
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
22 write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t")
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
23
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
24 cat("\n\n")
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
25 # ----- PROCESSING INFILE -----
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
26 cat("\tARGUMENTS PROCESSING INFO\n")
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
27 options(bitmapType = "cairo")
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
28
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
29 samplebyclass <- 2
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
30 if (!is.null(args$samplebyclass)) {
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
31 samplebyclass <- args$samplebyclass
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
32 args$samplebyclass <- NULL
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
33 }
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
34
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
35 # ----- INFILE PROCESSING -----
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
36 cat("\tINFILE PROCESSING INFO\n")
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
37
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
38 # Handle infiles
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
39 if (!exists("singlefile")) singlefile <- NULL
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
40 rawFilePath <- getRawfilePathFromArguments(singlefile, NULL, args)
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
41 singlefile <- rawFilePath$singlefile
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
42 directory <- retrieveRawfileInWD(singlefile, NULL)
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
43
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
44 # Check some character issues
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
45 checkXmlStructure(directory)
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
46
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
47 cat("\n\n")
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
48
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
49
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
50
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
51
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
52 # ----- MAIN PROCESSING INFO -----
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
53 cat("\tMAIN PROCESSING INFO\n")
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
54
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
55
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
56 xset <- ipo4xcmsSet(directory, "IPO_parameters4xcmsSet.tsv", args, samplebyclass)
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
57
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
58
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
59
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
60 cat("\n\n")
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
61
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
62
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
63 # ----- EXPORT -----
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
64
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
65 cat("\tXSET OBJECT INFO\n")
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
66 print(xset)
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
67 # delete the parameters to avoid the passage to the next tool in .RData image
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
68
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
69
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
70 # saving R data in .Rdata file to save the variables used in the present tool
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
71 objects2save <- c("xset", "singlefile")
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
72 save(list = objects2save[objects2save %in% ls()], file = "ipo4xcmsSet.RData")
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
73
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
74 cat("\n\n")
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
75
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
76
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
77 cat("\tDONE\n")