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