annotate ipo4retgroup.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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")
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
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")
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
27
2
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
28 samplebyclass <- 2
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
29 if (!is.null(args$samplebyclass)) {
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
30 samplebyclass <- args$samplebyclass
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
31 args$samplebyclass <- NULL
0
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
32 }
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
33
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
34 cat("\n\n")
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
35
1
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
36 # ----- INFILE PROCESSING -----
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
37 cat("\tINFILE PROCESSING INFO\n")
2
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
38 options(bitmapType = "cairo")
1
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
39
2
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
40 # image is an .RData file necessary to use xset variable given by previous tools
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
41 load(args$image)
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
42 args$image <- NULL
1
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
43
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
44 # Because so far CAMERA isn't compatible with the new XCMSnExp object
2
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
45 if (exists("xdata")) {
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
46 xset <- getxcmsSetObject(xdata)
1
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
47 }
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
48
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
49 if (!exists("xset")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata' which is provided by the tool: MSnbase readMSData")
0
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
50
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
51
1
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
52 # Handle infiles
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
53 if (!exists("singlefile")) singlefile <- NULL
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
54 rawFilePath <- getRawfilePathFromArguments(singlefile, NULL, args)
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
55 singlefile <- rawFilePath$singlefile
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
56 print(singlefile)
2
8e5f667359cb planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 1
diff changeset
57 directory <- retrieveRawfileInWD(singlefile, NULL)
0
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
58
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
59
1
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
60 cat("\n\n")
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
61
0
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
62
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
63 # ----- MAIN PROCESSING INFO -----
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
64 cat("\tMAIN PROCESSING INFO\n")
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
65
1
ae8de756dfcf "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 0
diff changeset
66 ipo4retgroup(xset, directory, "IPO_parameters4xcmsSet.tsv", args, samplebyclass)
0
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
67
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
68 cat("\n\n")
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
69
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
70
ac5f2936575b planemo upload commit 131562ad89c33a2f87754936ce3c8fe6899484c0
lecorguille
parents:
diff changeset
71 cat("\tDONE\n")