annotate ipo4retgroup.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")
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
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")
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
27
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
28 samplebyclass <- 2
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
29 if (!is.null(args$samplebyclass)) {
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
30 samplebyclass <- args$samplebyclass
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
31 args$samplebyclass <- NULL
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
32 }
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
33
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
34 cat("\n\n")
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
35
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
36 # ----- INFILE PROCESSING -----
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
37 cat("\tINFILE PROCESSING INFO\n")
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
38 options(bitmapType = "cairo")
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
39
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
40 # image is an .RData file necessary to use xset variable given by previous tools
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
41 load(args$image)
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
42 args$image <- NULL
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
43
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
44 # Because so far CAMERA isn't compatible with the new XCMSnExp object
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
45 if (exists("xdata")) {
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
46 xset <- getxcmsSetObject(xdata)
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
47 }
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
48
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
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")
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
50
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
51
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
52 # Handle infiles
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
53 if (!exists("singlefile")) singlefile <- NULL
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
54 rawFilePath <- getRawfilePathFromArguments(singlefile, NULL, args)
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
55 singlefile <- rawFilePath$singlefile
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
56 print(singlefile)
10
57f180a8eaae planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
workflow4metabolomics
parents: 9
diff changeset
57 directory <- retrieveRawfileInWD(singlefile, NULL)
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
58
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
59
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
60 cat("\n\n")
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
61
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
62
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
63 # ----- MAIN PROCESSING INFO -----
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
64 cat("\tMAIN PROCESSING INFO\n")
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
65
9
364756ea5f42 "planemo upload for repository https://github.com/rietho/IPO commit 5083f3b5800bdd8515519f2f6398046b41e1df97"
workflow4metabolomics
parents: 8
diff changeset
66 ipo4retgroup(xset, directory, "IPO_parameters4xcmsSet.tsv", args, samplebyclass)
6
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
67
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
68 cat("\n\n")
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
69
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
70
03fdfbd914ab planemo upload commit 8dfb0b11442ccce78165b5d8f07555ccbd303cce
lecorguille
parents:
diff changeset
71 cat("\tDONE\n")