annotate CAMERA_combinexsAnnos.r @ 7:e461f344226c draft default tip

planemo upload commit 24d44ee26b7c23380c2b42fae2f7f6e58472100d
author workflow4metabolomics
date Sun, 24 Nov 2024 21:28:22 +0000
parents 2443150161b4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
1 #!/usr/bin/env Rscript
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
2
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
3 # ----- PACKAGE -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
4 cat("\tSESSION INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
5
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
6 #Import the different functions
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
7 source_local <- function(fname) {
6
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
8 argv <- commandArgs(trailingOnly = FALSE)
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
9 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
10 source(paste(base_dir, fname, sep = "/"))
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
11 }
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
12 source_local("lib.r")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
13
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
14 pkgs <- c("CAMERA", "multtest", "batch")
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
15 loadAndDisplayPackages(pkgs)
6
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
16 cat("\n\n")
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
17
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
18 # ----- ARGUMENTS -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
19 cat("\tARGUMENTS INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
20
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
21 args <- parseCommandArgs(evaluate = FALSE) #interpretation of arguments given in command line as an R list of objects
6
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
22 write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t")
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
23
6
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
24 cat("\n\n")
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
25
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
26
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
27 # ----- PROCESSING INFILE -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
28 cat("\tINFILE PROCESSING INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
29
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
30 #image is an .RData file necessary to use xset variable given by previous tools
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
31 load(args$image_pos)
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
32 xaP <- xa
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
33
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
34 diffrepP <- NULL
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
35 if (exists("diffrep")) diffrepP <- diffrep
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
36
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
37 load(args$image_neg)
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
38 xaN <- xa
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
39
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
40 diffrepN <- NULL
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
41 if (exists("diffrep")) diffrepN <- diffrep
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
42
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
43
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
44 cat("\n\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
45
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
46
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
47 # ----- ARGUMENTS PROCESSING -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
48 cat("\tARGUMENTS PROCESSING INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
49
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
50 # Save arguments to generate a report
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
51 if (!exists("listOFargs")) listOFargs <- list()
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
52 listOFargs[[format(Sys.time(), "%y%m%d-%H:%M:%S_combinexsAnnos")]] <- args
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
53
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
54 cat("\n\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
55
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
56
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
57 # ----- PROCESSING INFO -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
58 cat("\tMAIN PROCESSING INFO\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
59
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
60 cAnnot <- combinexsAnnos_function(
6
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
61 xaP = xaP, xaN = xaN,
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
62 diffrepP = diffrepP, diffrepN = diffrepN,
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
63 pos = args$pos, tol = args$tol, ruleset = args$ruleset, keep_meta = args$keep_meta,
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
64 convertRTMinute = args$convertRTMinute, numDigitsMZ = args$numDigitsMZ, numDigitsRT = args$numDigitsRT,
2443150161b4 planemo upload commit cfad09eb4dd6b1439b7de6a0852cd8fa22210f58
workflow4metabolomics
parents: 4
diff changeset
65 variableMetadataOutput = "variableMetadata.tsv"
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
66 )
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
67
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
68 # ----- EXPORT -----
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
69
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
70 #saving R data in .Rdata file to save the variables used in the present tool
4
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
71 objects2save <- c("xa", "variableMetadata", "diffrep", "cAnnot", "listOFargs", "zipfile", "singlefile")
4c4945bce185 "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 0
diff changeset
72 save(list = objects2save[objects2save %in% ls()], file = "combinexsAnnos.RData")
0
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
73
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
74 cat("\n\n")
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
75
139ff66b0b5d planemo upload commit f69695e76674862ed9c77c1c127f459b4df42464
workflow4metabolomics
parents:
diff changeset
76 cat("\tDONE\n")