annotate lib.r @ 23:abf1775ac14d draft

"planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
author workflow4metabolomics
date Thu, 22 Apr 2021 10:27:38 +0000
parents b979ba5888f7
children 4b9ab71be05e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
1 # lib.r
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
2
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
3 #@author G. Le Corguille
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
4 # solve an issue with batch if arguments are logical TRUE/FALSE
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
5 parseCommandArgs <- function(...) {
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
6 args <- batch::parseCommandArgs(...)
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
7 for (key in names(args)) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
8 if (args[key] %in% c("TRUE", "FALSE"))
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
9 args[key] <- as.logical(args[key])
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
10 }
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
11 return(args)
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
12 }
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
13
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
14 #@author G. Le Corguille
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
15 # This function will
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
16 # - load the packages
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
17 # - display the sessionInfo
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
18 loadAndDisplayPackages <- function(pkgs) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
19 for (pkg in pkgs) suppressPackageStartupMessages(stopifnot(library(pkg, quietly = TRUE, logical.return = TRUE, character.only = TRUE)))
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
20
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
21 sessioninfo <- sessionInfo()
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
22 cat(sessioninfo$R.version$version.string, "\n")
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
23 cat("Main packages:\n")
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
24 for (pkg in names(sessioninfo$otherPkgs)) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
25 cat(paste(pkg, packageVersion(pkg)), "\t")
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
26 }
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
27 cat("\n")
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
28 cat("Other loaded packages:\n")
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
29 for (pkg in names(sessioninfo$loadedOnly)) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
30 cat(paste(pkg, packageVersion(pkg)), "\t")
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
31 }
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
32 cat("\n")
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
33 }
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
34
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
35 # This function retrieve a xset like object
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
36 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
37 getxcmsSetObject <- function(xobject) {
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
38 # XCMS 1.x
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
39 if (class(xobject) == "xcmsSet")
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
40 return(xobject)
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
41 # XCMS 3.x
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
42 if (class(xobject) == "XCMSnExp") {
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
43 # Get the legacy xcmsSet object
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
44 suppressWarnings(xset <- as(xobject, "xcmsSet"))
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
45 if (is.null(xset@phenoData$sample_group))
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
46 sampclass(xset) <- "."
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
47 else
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
48 sampclass(xset) <- xset@phenoData$sample_group
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
49 if (!is.null(xset@phenoData$sample_name))
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
50 rownames(xset@phenoData) <- xset@phenoData$sample_name
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
51 return(xset)
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
52 }
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
53 }
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
54
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
55 #@author G. Le Corguille
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
56 #The function create a pdf from the different png generated by diffreport
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
57 diffreport_png2pdf <- function(filebase) {
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
58 dir.create("pdf")
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
59
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
60 pdfEicOutput <- paste0("pdf/", filebase, "-eic_pdf.pdf")
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
61 pdfBoxOutput <- paste0("pdf/", filebase, "-box_pdf.pdf")
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
62
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
63 system(paste0("gm convert ", filebase, "_eic/*.png ", pdfEicOutput))
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
64 system(paste0("gm convert ", filebase, "_box/*.png ", pdfBoxOutput))
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
65
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
66 }
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
67
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
68 #@author G. Le Corguille
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
69 #The function create a zip archive from the different png generated by diffreport
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
70 diffreport_png2zip <- function() {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
71 zip("eic.zip", dir(pattern = "_eic"), zip = Sys.which("zip"))
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
72 zip("box.zip", dir(pattern = "_box"), zip = Sys.which("zip"))
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
73 }
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
74
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
75 #The function create a zip archive from the different tabular generated by diffreport
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
76 diffreport_tabular2zip <- function() {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
77 zip("tabular.zip", dir(pattern = "tabular/*"), zip = Sys.which("zip"))
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
78 }
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
79
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
80 #@author G. Le Corguille
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
81 #This function convert if it is required the Retention Time in minutes
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
82 RTSecondToMinute <- function(variableMetadata, convertRTMinute) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
83 if (convertRTMinute) {
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
84 #converting the retention times (seconds) into minutes
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
85 print("converting the retention times into minutes in the variableMetadata")
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
86 variableMetadata[, "rt"] <- variableMetadata[, "rt"] / 60
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
87 variableMetadata[, "rtmin"] <- variableMetadata[, "rtmin"] / 60
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
88 variableMetadata[, "rtmax"] <- variableMetadata[, "rtmax"] / 60
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
89 }
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
90 return(variableMetadata)
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
91 }
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
92
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
93 #@author G. Le Corguille
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
94 #This function format ions identifiers
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
95 formatIonIdentifiers <- function(variableMetadata, numDigitsRT = 0, numDigitsMZ = 0) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
96 splitDeco <- strsplit(as.character(variableMetadata$name), "_")
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
97 idsDeco <- sapply(splitDeco, function(x) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
98 deco <- unlist(x)[2]; if (is.na(deco)) return("") else return(paste0("_", deco))
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
99 })
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
100 namecustom <- make.unique(paste0("M", round(variableMetadata[, "mz"], numDigitsMZ), "T", round(variableMetadata[, "rt"], numDigitsRT), idsDeco))
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
101 variableMetadata <- cbind(name = variableMetadata$name, namecustom = namecustom, variableMetadata[, !(colnames(variableMetadata) %in% c("name"))])
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
102 return(variableMetadata)
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
103 }
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
104
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
105 #The function annotateDiffreport without the corr function which bugs
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
106 annotatediff <- function(xset = xset, args = args, variableMetadataOutput = "variableMetadata.tsv") {
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
107 # Resolve the bug with x11, with the function png
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
108 options(bitmapType = "cairo")
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
109
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
110 #Check if the fillpeaks step has been done previously, if it hasn't, there is an error message and the execution is stopped.
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
111 res <- try(is.null(xset@filled))
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
112
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
113 # ------ annot -------
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
114 args$calcCiS <- as.logical(args$calcCiS)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
115 args$calcIso <- as.logical(args$calcIso)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
116 args$calcCaS <- as.logical(args$calcCaS)
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
117
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
118 # common parameters
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
119 args4annotate <- list(object = xset,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
120 nSlaves = args$nSlaves, sigma = args$sigma, perfwhm = args$perfwhm,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
121 maxcharge = args$maxcharge, maxiso = args$maxiso, minfrac = args$minfrac,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
122 ppm = args$ppm, mzabs = args$mzabs, quick = args$quick,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
123 polarity = args$polarity, max_peaks = args$max_peaks, intval = args$intval)
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
124
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
125 if (args$quick == FALSE) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
126 args4annotate <- append(args4annotate,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
127 list(graphMethod = args$graphMethod, cor_eic_th = args$cor_eic_th, pval = args$pval,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
128 calcCiS = args$calcCiS, calcIso = args$calcIso, calcCaS = args$calcCaS))
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
129 # no ruleset
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
130 if (!is.null(args$multiplier)) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
131 args4annotate <- append(args4annotate,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
132 list(multiplier = args$multiplier))
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
133 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
134 # ruleset
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
135 else {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
136 rulset <- read.table(args$rules, h = T, sep = ";")
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
137 if (ncol(rulset) < 4) rulset <- read.table(args$rules, h = T, sep = "\t")
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
138 if (ncol(rulset) < 4) rulset <- read.table(args$rules, h = T, sep = ",")
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
139 if (ncol(rulset) < 4) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
140 error_message <- "Your ruleset file seems not well formatted. The column separators accepted are ; , and tabulation"
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
141 print(error_message)
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
142 stop(error_message)
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
143 }
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
144
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
145 args4annotate <- append(args4annotate,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
146 list(rules = rulset))
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
147 }
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
148 }
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
149
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
150
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
151 # launch annotate
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
152 xa <- do.call("annotate", args4annotate)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
153 peakList <- getPeaklist(xa, intval = args$intval)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
154 peakList <- cbind(groupnames(xa@xcmsSet), peakList); colnames(peakList)[1] <- c("name");
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
155
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
156 # --- Multi condition : diffreport ---
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
157 diffrepOri <- NULL
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
158 if (!is.null(args$runDiffreport) & nlevels(sampclass(xset)) >= 2) {
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
159 #Check if the fillpeaks step has been done previously, if it hasn't, there is an error message and the execution is stopped.
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
160 res <- try(is.null(xset@filled))
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
161 classes <- levels(sampclass(xset))
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
162 x <- 1:(length(classes) - 1)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
163 for (i in seq(along = x)) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
164 y <- 1:(length(classes))
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
165 for (n in seq(along = y)) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
166 if (i + n <= length(classes)) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
167 filebase <- paste(classes[i], class2 = classes[i + n], sep = "-vs-")
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
168
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
169 diffrep <- diffreport(
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
170 object = xset, class1 = classes[i], class2 = classes[i + n],
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
171 filebase = filebase, eicmax = args$eicmax, eicwidth = args$eicwidth,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
172 sortpval = TRUE, value = args$value, h = args$h, w = args$w, mzdec = args$mzdec, missing = 0)
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
173
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
174 diffrepOri <- diffrep
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
175
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
176 # renamming of the column rtmed to rt to fit with camera peaklist function output
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
177 colnames(diffrep)[colnames(diffrep) == "rtmed"] <- "rt"
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
178 colnames(diffrep)[colnames(diffrep) == "mzmed"] <- "mz"
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
179
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
180 # combines results and reorder columns
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
181 diffrep <- merge(peakList, diffrep[, c("name", "fold", "tstat", "pvalue")], by.x = "name", by.y = "name", sort = F)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
182 diffrep <- cbind(diffrep[, !(colnames(diffrep) %in% c(sampnames(xa@xcmsSet)))], diffrep[, (colnames(diffrep) %in% c(sampnames(xa@xcmsSet)))])
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
183
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
184 diffrep <- RTSecondToMinute(diffrep, args$convertRTMinute)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
185 diffrep <- formatIonIdentifiers(diffrep, numDigitsRT = args$numDigitsRT, numDigitsMZ = args$numDigitsMZ)
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
186
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
187 if (args$sortpval) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
188 diffrep <- diffrep[order(diffrep$pvalue), ]
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
189 }
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
190
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
191 dir.create("tabular", showWarnings = FALSE)
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
192 write.table(diffrep, sep = "\t", quote = FALSE, row.names = FALSE, file = paste("tabular/", filebase, "_tsv.tabular", sep = ""))
16
a2c49996603e planemo upload commit e440674afa3e58c46100b0ac7c305a6f46ecbbdc
lecorguille
parents: 13
diff changeset
193
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
194 if (args$eicmax != 0) {
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
195 if (args$png2 == "pdf")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
196 diffreport_png2pdf(filebase)
20
b979ba5888f7 "planemo upload commit 0b77855ab98a4940d58727271c28990969367f4d"
workflow4metabolomics
parents: 19
diff changeset
197 if (args$png2 == "zip")
b979ba5888f7 "planemo upload commit 0b77855ab98a4940d58727271c28990969367f4d"
workflow4metabolomics
parents: 19
diff changeset
198 diffreport_png2zip()
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
199 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
200 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
201 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
202 }
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
203 if (args$tabular2 == "zip")
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
204 diffreport_tabular2zip()
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
205 }
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
206
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
207 # --- variableMetadata ---
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
208 variableMetadata <- peakList[, !(make.names(colnames(peakList)) %in% c(make.names(sampnames(xa@xcmsSet))))]
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
209 variableMetadata <- RTSecondToMinute(variableMetadata, args$convertRTMinute)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
210 variableMetadata <- formatIonIdentifiers(variableMetadata, numDigitsRT = args$numDigitsRT, numDigitsMZ = args$numDigitsMZ)
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
211 # if we have 2 conditions, we keep stat of diffrep
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
212 if (!is.null(args$runDiffreport) & nlevels(sampclass(xset)) == 2) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
213 variableMetadata <- merge(variableMetadata, diffrep[, c("name", "fold", "tstat", "pvalue")], by.x = "name", by.y = "name", sort = F)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
214 if (exists("args[[\"sortpval\"]]")) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
215 variableMetadata <- variableMetadata[order(variableMetadata$pvalue), ]
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
216 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
217 }
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
218
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
219 variableMetadataOri <- variableMetadata
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
220 write.table(variableMetadata, sep = "\t", quote = FALSE, row.names = FALSE, file = variableMetadataOutput)
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
221
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
222 return(list("xa" = xa, "diffrep" = diffrepOri, "variableMetadata" = variableMetadataOri));
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
223
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
224 }
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
225
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
226
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
227 combinexsAnnos_function <- function(xaP, xaN, diffrepP = NULL, diffrepN = NULL,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
228 pos = TRUE, tol = 2, ruleset = NULL, keep_meta = TRUE, convertRTMinute = F, numDigitsMZ = 0,
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
229 numDigitsRT = 0, variableMetadataOutput = "variableMetadata.tsv") {
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
230
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
231 #Load the two Rdata to extract the xset objects from positive and negative mode
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
232 cat("\tObject xset from positive mode\n")
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
233 print(xaP)
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
234 cat("\n")
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
235
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
236 cat("\tObject xset from negative mode\n")
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
237 print(xaN)
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
238 cat("\n")
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
239
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
240 cat("\n")
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
241 cat("\tCombining...\n")
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
242 #Convert the string to numeric for creating matrix
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
243 row <- as.numeric(strsplit(ruleset, ",")[[1]][1])
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
244 column <- as.numeric(strsplit(ruleset, ",")[[1]][2])
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
245 ruleset <- cbind(row, column)
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
246 #Test if the file comes from an older version tool
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
247 if ((!is.null(xaP)) & (!is.null(xaN))) {
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
248 #Launch the combinexsannos function from CAMERA
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
249 cAnnot <- combinexsAnnos(xaP, xaN, pos = pos, tol = tol, ruleset = ruleset)
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
250 } else {
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
251 stop("You must relauch the CAMERA.annotate step with the lastest version.")
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
252 }
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
253
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
254 if (pos) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
255 xa <- xaP
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
256 mode <- "neg. Mode"
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
257 } else {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
258 xa <- xaN
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
259 mode <- "pos. Mode"
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
260 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
261
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
262 peakList <- getPeaklist(xa)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
263 peakList <- cbind(groupnames(xa@xcmsSet), peakList); colnames(peakList)[1] <- c("name");
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
264 variableMetadata <- cbind(peakList, cAnnot[, c("isotopes", "adduct", "pcgroup", mode)]);
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
265 variableMetadata <- variableMetadata[, !(colnames(variableMetadata) %in% c(sampnames(xa@xcmsSet)))]
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
266
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
267 #Test if there are more than two classes (conditions)
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
268 if (nlevels(sampclass(xaP@xcmsSet)) == 2 & (!is.null(diffrepN)) & (!is.null(diffrepP))) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
269 diffrepP <- diffrepP[, c("name", "fold", "tstat", "pvalue")]; colnames(diffrepP) <- paste("P.", colnames(diffrepP), sep = "")
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
270 diffrepN <- diffrepN[, c("name", "fold", "tstat", "pvalue")]; colnames(diffrepN) <- paste("N.", colnames(diffrepN), sep = "")
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
271
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
272 variableMetadata <- merge(variableMetadata, diffrepP, by.x = "name", by.y = "P.name")
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
273 variableMetadata <- merge(variableMetadata, diffrepN, by.x = "name", by.y = "N.name")
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
274 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
275
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
276 rownames(variableMetadata) <- NULL
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
277 #TODO: checker colnames(variableMetadata)[1:2] = c("name", "mz/rt");
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
278
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
279 variableMetadata <- RTSecondToMinute(variableMetadata, convertRTMinute)
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
280 variableMetadata <- formatIonIdentifiers(variableMetadata, numDigitsRT = numDigitsRT, numDigitsMZ = numDigitsMZ)
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
281
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
282 #If the user want to keep only the metabolites which match a difference
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
283 if (keep_meta) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
284 variableMetadata <- variableMetadata[variableMetadata[, c(mode)] != "", ]
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
285 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
286
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
287 #Write the output into a tsv file
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
288 write.table(variableMetadata, sep = "\t", quote = FALSE, row.names = FALSE, file = variableMetadataOutput)
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
289 return(variableMetadata);
9
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
290
7da9252dd983 planemo upload commit 9d47e3b467dbbe0af0d90a937c5e9f2c4b958c4b
lecorguille
parents:
diff changeset
291 }
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
292
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
293 # This function get the raw file path from the arguments
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
294 getRawfilePathFromArguments <- function(singlefile, zipfile, args) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
295 if (!is.null(args$zipfile)) zipfile <- args$zipfile
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
296 if (!is.null(args$zipfilePositive)) zipfile <- args$zipfilePositive
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
297 if (!is.null(args$zipfileNegative)) zipfile <- args$zipfileNegative
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
298
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
299 if (!is.null(args$singlefile_galaxyPath)) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
300 singlefile_galaxyPaths <- args$singlefile_galaxyPath;
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
301 singlefile_sampleNames <- args$singlefile_sampleName
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
302 }
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
303 if (!is.null(args$singlefile_galaxyPathPositive)) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
304 singlefile_galaxyPaths <- args$singlefile_galaxyPathPositive;
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
305 singlefile_sampleNames <- args$singlefile_sampleNamePositive
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
306 }
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
307 if (!is.null(args$singlefile_galaxyPathNegative)) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
308 singlefile_galaxyPaths <- args$singlefile_galaxyPathNegative;
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
309 singlefile_sampleNames <- args$singlefile_sampleNameNegative
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
310 }
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
311 if (exists("singlefile_galaxyPaths")) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
312 singlefile_galaxyPaths <- unlist(strsplit(singlefile_galaxyPaths, ","))
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
313 singlefile_sampleNames <- unlist(strsplit(singlefile_sampleNames, ","))
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
314
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
315 singlefile <- NULL
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
316 for (singlefile_galaxyPath_i in seq_len(length(singlefile_galaxyPaths))) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
317 singlefile_galaxyPath <- singlefile_galaxyPaths[singlefile_galaxyPath_i]
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
318 singlefile_sampleName <- singlefile_sampleNames[singlefile_galaxyPath_i]
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
319 singlefile[[singlefile_sampleName]] <- singlefile_galaxyPath
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
320 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
321 }
18
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
322 for (argument in c("zipfile", "zipfilePositive", "zipfileNegative",
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
323 "singlefile_galaxyPath", "singlefile_sampleName",
cb923396e70f planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
lecorguille
parents: 17
diff changeset
324 "singlefile_galaxyPathPositive", "singlefile_sampleNamePositive",
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
325 "singlefile_galaxyPathNegative", "singlefile_sampleNameNegative")) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
326 args[[argument]] <- NULL
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
327 }
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
328 return(list(zipfile = zipfile, singlefile = singlefile, args = args))
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
329 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
330
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
331
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
332 # This function retrieve the raw file in the working directory
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
333 # - if zipfile: unzip the file with its directory tree
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
334 # - if singlefiles: set symlink with the good filename
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
335 retrieveRawfileInTheWorkingDir <- function(singlefile, zipfile) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
336 if (!is.null(singlefile) && (length("singlefile") > 0)) {
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
337 for (singlefile_sampleName in names(singlefile)) {
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
338 singlefile_galaxyPath <- singlefile[[singlefile_sampleName]]
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
339 if (!file.exists(singlefile_galaxyPath)) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
340 error_message <- paste("Cannot access the sample:", singlefile_sampleName, "located:", singlefile_galaxyPath, ". Please, contact your administrator ... if you have one!")
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
341 print(error_message); stop(error_message)
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
342 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
343
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
344 file.symlink(singlefile_galaxyPath, singlefile_sampleName)
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
345 }
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
346 directory <- "."
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
347
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
348 }
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
349 if (!is.null(zipfile) && (zipfile != "")) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
350 if (!file.exists(zipfile)) {
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
351 error_message <- paste("Cannot access the Zip file:", zipfile, ". Please, contact your administrator ... if you have one!")
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
352 print(error_message)
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
353 stop(error_message)
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
354 }
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
355
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
356 #unzip
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
357 suppressWarnings(unzip(zipfile, unzip = "unzip"))
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
358
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
359 #get the directory name
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
360 filesInZip <- unzip(zipfile, list = T);
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
361 directories <- unique(unlist(lapply(strsplit(filesInZip$Name, "/"), function(x) x[1])));
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
362 directories <- directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
363 directory <- "."
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
364 if (length(directories) == 1) directory <- directories
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
365
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
366 cat("files_root_directory\t", directory, "\n")
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
367
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
368 }
23
abf1775ac14d "planemo upload commit c1e276cf53b3c54d4702ab26d4f40a525a720998"
workflow4metabolomics
parents: 20
diff changeset
369 return(directory)
13
1c30ff90f3ae planemo upload commit 301d42e88026afdac618f4ec56fc6cbe19e3e419
lecorguille
parents: 9
diff changeset
370 }