annotate lib.r @ 17:ae28a753a6f8 draft default tip

planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
author workflow4metabolomics
date Mon, 03 Feb 2025 14:45:41 +0000
parents 58b5a4b6e1da
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
1 # @authors ABiMS TEAM, Y. Guitton
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
2 # lib.r for Galaxy Workflow4Metabolomics xcms tools
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
3
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
4 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
5 # solve an issue with batch if arguments are logical TRUE/FALSE
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
6 parseCommandArgs <- function(...) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
7 args <- batch::parseCommandArgs(...)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
8 for (key in names(args)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
9 if (args[key] %in% c("TRUE", "FALSE")) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
10 args[key] <- as.logical(args[key])
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
11 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
12 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
13 return(args)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
14 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
15
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
16 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
17 # This function will
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
18 # - load the packages
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
19 # - display the sessionInfo
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
20 loadAndDisplayPackages <- function(pkgs) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
21 for (pkg in pkgs) suppressPackageStartupMessages(stopifnot(library(pkg, quietly = TRUE, logical.return = TRUE, character.only = TRUE)))
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
22
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
23 sessioninfo <- sessionInfo()
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
24 cat(sessioninfo$R.version$version.string, "\n")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
25 cat("Main packages:\n")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
26 for (pkg in names(sessioninfo$otherPkgs)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
27 cat(paste(pkg, packageVersion(pkg)), "\t")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
28 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
29 cat("\n")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
30 cat("Other loaded packages:\n")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
31 for (pkg in names(sessioninfo$loadedOnly)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
32 cat(paste(pkg, packageVersion(pkg)), "\t")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
33 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
34 cat("\n")
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
35 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
36
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
37 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
38 # This function merge several chromBPI or chromTIC into one.
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
39 mergeChrom <- function(chrom_merged, chrom) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
40 if (is.null(chrom_merged)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
41 return(NULL)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
42 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
43 chrom_merged@.Data <- cbind(chrom_merged@.Data, chrom@.Data)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
44 return(chrom_merged)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
45 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
46
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
47 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
48 # This function merge several xdata into one.
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
49 mergeXData <- function(args) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
50 chromTIC <- NULL
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
51 chromBPI <- NULL
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
52 chromTIC_adjusted <- NULL
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
53 chromBPI_adjusted <- NULL
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
54 md5sumList <- NULL
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
55 for (image in args$images) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
56 load(image)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
57 # Handle infiles
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
58 if (!exists("singlefile")) singlefile <- NULL
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
59 if (!exists("zipfile")) zipfile <- NULL
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
60 rawFilePath <- retrieveRawfileInTheWorkingDir(singlefile, zipfile, args)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
61 zipfile <- rawFilePath$zipfile
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
62 singlefile <- rawFilePath$singlefile
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
63
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
64 if (exists("raw_data")) xdata <- raw_data
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
65 if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*")
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
66
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
67 cat(sampleNamesList$sampleNamesOrigin, "\n")
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
68
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
69 if (!exists("xdata_merged")) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
70 xdata_merged <- xdata
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
71 singlefile_merged <- singlefile
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
72 md5sumList_merged <- md5sumList
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
73 sampleNamesList_merged <- sampleNamesList
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
74 chromTIC_merged <- chromTIC
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
75 chromBPI_merged <- chromBPI
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
76 chromTIC_adjusted_merged <- chromTIC_adjusted
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
77 chromBPI_adjusted_merged <- chromBPI_adjusted
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
78 } else {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
79 if (is(xdata, "XCMSnExp")) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
80 xdata_merged <- c(xdata_merged, xdata)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
81 } else if (is(xdata, "OnDiskMSnExp")) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
82 xdata_merged <- xcms:::.concatenate_OnDiskMSnExp(xdata_merged, xdata)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
83 } else {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
84 stop("\n\nERROR: The RData either a OnDiskMSnExp object called raw_data or a XCMSnExp object called xdata")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
85 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
86
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
87 singlefile_merged <- c(singlefile_merged, singlefile)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
88 md5sumList_merged$origin <- rbind(md5sumList_merged$origin, md5sumList$origin)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
89 sampleNamesList_merged$sampleNamesOrigin <- c(sampleNamesList_merged$sampleNamesOrigin, sampleNamesList$sampleNamesOrigin)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
90 sampleNamesList_merged$sampleNamesMakeNames <- c(sampleNamesList_merged$sampleNamesMakeNames, sampleNamesList$sampleNamesMakeNames)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
91 chromTIC_merged <- mergeChrom(chromTIC_merged, chromTIC)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
92 chromBPI_merged <- mergeChrom(chromBPI_merged, chromBPI)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
93 chromTIC_adjusted_merged <- mergeChrom(chromTIC_adjusted_merged, chromTIC_adjusted)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
94 chromBPI_adjusted_merged <- mergeChrom(chromBPI_adjusted_merged, chromBPI_adjusted)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
95 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
96 }
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
97 rm(image)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
98 xdata <- xdata_merged
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
99 rm(xdata_merged)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
100 singlefile <- singlefile_merged
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
101 rm(singlefile_merged)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
102 md5sumList <- md5sumList_merged
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
103 rm(md5sumList_merged)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
104 sampleNamesList <- sampleNamesList_merged
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
105 rm(sampleNamesList_merged)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
106
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
107 if (!is.null(args$sampleMetadata)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
108 cat("\tXSET PHENODATA SETTING...\n")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
109 sampleMetadataFile <- args$sampleMetadata
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
110 sampleMetadata <- getDataFrameFromFile(sampleMetadataFile, header = FALSE)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
111 xdata@phenoData@data$sample_group <- sampleMetadata$V2[match(xdata@phenoData@data$sample_name, sampleMetadata$V1)]
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
112
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
113 if (any(is.na(pData(xdata)$sample_group))) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
114 sample_missing <- pData(xdata)$sample_name[is.na(pData(xdata)$sample_group)]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
115 error_message <- paste("Those samples are missing in your sampleMetadata:", paste(sample_missing, collapse = " "))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
116 print(error_message)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
117 stop(error_message)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
118 }
14
5bd125a3f3b0 "planemo upload for repository https://github.com/workflow4metabolomics/xcms commit dcc90f9cf76e6980c0a7d9698c89fab826e7adae"
workflow4metabolomics
parents: 13
diff changeset
119 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
120
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
121 if (!is.null(chromTIC_merged)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
122 chromTIC <- chromTIC_merged
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
123 chromTIC@phenoData <- xdata@phenoData
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
124 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
125 if (!is.null(chromBPI_merged)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
126 chromBPI <- chromBPI_merged
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
127 chromBPI@phenoData <- xdata@phenoData
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
128 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
129 if (!is.null(chromTIC_adjusted_merged)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
130 chromTIC_adjusted <- chromTIC_adjusted_merged
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
131 chromTIC_adjusted@phenoData <- xdata@phenoData
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
132 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
133 if (!is.null(chromBPI_adjusted_merged)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
134 chromBPI_adjusted <- chromBPI_adjusted_merged
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
135 chromBPI_adjusted@phenoData <- xdata@phenoData
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
136 }
15
58b5a4b6e1da planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 2cb157bd9a8701a3d6874e084032cbd050b8953e
workflow4metabolomics
parents: 14
diff changeset
137
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
138 return(list("xdata" = xdata, "singlefile" = singlefile, "md5sumList" = md5sumList, "sampleNamesList" = sampleNamesList, "chromTIC" = chromTIC, "chromBPI" = chromBPI, "chromTIC_adjusted" = chromTIC_adjusted, "chromBPI_adjusted" = chromBPI_adjusted))
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
139 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
140
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
141 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
142 # This function convert if it is required the Retention Time in minutes
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
143 RTSecondToMinute <- function(variableMetadata, convertRTMinute) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
144 if (convertRTMinute) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
145 # converting the retention times (seconds) into minutes
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
146 print("converting the retention times into minutes in the variableMetadata")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
147 variableMetadata[, "rt"] <- variableMetadata[, "rt"] / 60
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
148 variableMetadata[, "rtmin"] <- variableMetadata[, "rtmin"] / 60
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
149 variableMetadata[, "rtmax"] <- variableMetadata[, "rtmax"] / 60
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
150 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
151 return(variableMetadata)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
152 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
153
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
154 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
155 # This function format ions identifiers
14
5bd125a3f3b0 "planemo upload for repository https://github.com/workflow4metabolomics/xcms commit dcc90f9cf76e6980c0a7d9698c89fab826e7adae"
workflow4metabolomics
parents: 13
diff changeset
156 formatIonIdentifiers <- function(variableMetadata, numDigitsRT = 0, numDigitsMZ = 0) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
157 splitDeco <- strsplit(as.character(variableMetadata$name), "_")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
158 idsDeco <- sapply(
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
159 splitDeco,
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
160 function(x) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
161 deco <- unlist(x)[2]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
162 if (is.na(deco)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
163 return("")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
164 } else {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
165 return(paste0("_", deco))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
166 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
167 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
168 )
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
169 namecustom <- make.unique(paste0("M", round(variableMetadata[, "mz"], numDigitsMZ), "T", round(variableMetadata[, "rt"], numDigitsRT), idsDeco))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
170 variableMetadata <- cbind(name = variableMetadata$name, namecustom = namecustom, variableMetadata[, !(colnames(variableMetadata) %in% c("name"))])
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
171 return(variableMetadata)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
172 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
173
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
174 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
175 # This function convert the remain NA to 0 in the dataMatrix
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
176 naTOzeroDataMatrix <- function(dataMatrix, naTOzero) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
177 if (naTOzero) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
178 dataMatrix[is.na(dataMatrix)] <- 0
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
179 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
180 return(dataMatrix)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
181 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
182
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
183 # @author G. Le Corguille
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
184 # Draw the plotChromPeakDensity 3 per page in a pdf file
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
185 getPlotChromPeakDensity <- function(xdata, param = NULL, mzdigit = 4) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
186 pdf(file = "plotChromPeakDensity.pdf", width = 16, height = 12)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
187
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
188 par(mfrow = c(3, 1), mar = c(4, 4, 1, 0.5))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
189
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
190 if (length(unique(xdata$sample_group)) < 10) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
191 group_colors <- brewer.pal(length(unique(xdata$sample_group)), "Set1")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
192 } else {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
193 group_colors <- hcl.colors(length(unique(xdata$sample_group)), palette = "Dark 3")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
194 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
195 names(group_colors) <- unique(xdata$sample_group)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
196 col_per_samp <- as.character(xdata$sample_group)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
197 for (i in seq_len(length(group_colors))) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
198 col_per_samp[col_per_samp == (names(group_colors)[i])] <- group_colors[i]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
199 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
200
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
201 xlim <- c(min(featureDefinitions(xdata)$rtmin), max(featureDefinitions(xdata)$rtmax))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
202 for (i in seq_len(nrow(featureDefinitions(xdata)))) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
203 mzmin <- featureDefinitions(xdata)[i, ]$mzmin
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
204 mzmax <- featureDefinitions(xdata)[i, ]$mzmax
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
205 plotChromPeakDensity(xdata, param = param, mz = c(mzmin, mzmax), col = col_per_samp, pch = 16, xlim = xlim, main = paste(round(mzmin, mzdigit), round(mzmax, mzdigit)))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
206 legend("topright", legend = names(group_colors), col = group_colors, cex = 0.8, lty = 1)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
207 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
208
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
209 dev.off()
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
210 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
211
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
212 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
213 # Draw the plotChromPeakDensity 3 per page in a pdf file
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
214 getPlotAdjustedRtime <- function(xdata) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
215 pdf(file = "raw_vs_adjusted_rt.pdf", width = 16, height = 12)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
216
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
217 # Color by group
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
218 if (length(unique(xdata$sample_group)) < 10) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
219 group_colors <- brewer.pal(length(unique(xdata$sample_group)), "Set1")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
220 } else {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
221 group_colors <- hcl.colors(length(unique(xdata$sample_group)), palette = "Dark 3")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
222 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
223 if (length(group_colors) > 1) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
224 names(group_colors) <- unique(xdata$sample_group)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
225 plotAdjustedRtime(xdata, col = group_colors[xdata$sample_group])
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
226 legend("topright", legend = names(group_colors), col = group_colors, cex = 0.8, lty = 1)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
227 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
228
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
229 # Color by sample
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
230 plotAdjustedRtime(xdata, col = rainbow(length(xdata@phenoData@data$sample_name)))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
231 legend("topright", legend = xdata@phenoData@data$sample_name, col = rainbow(length(xdata@phenoData@data$sample_name)), cex = 0.8, lty = 1)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
232
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
233 dev.off()
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
234 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
235
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
236 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
237 # value: intensity values to be used into, maxo or intb
15
58b5a4b6e1da planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 2cb157bd9a8701a3d6874e084032cbd050b8953e
workflow4metabolomics
parents: 14
diff changeset
238 getPeaklistW4M <- function(xdata, intval = "into", convertRTMinute = FALSE, numDigitsMZ = 4, numDigitsRT = 0, naTOzero = TRUE, variableMetadataOutput, dataMatrixOutput, sampleNamesList) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
239 dataMatrix <- featureValues(xdata, method = "medret", value = intval)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
240 colnames(dataMatrix) <- make.names(tools::file_path_sans_ext(colnames(dataMatrix)))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
241 dataMatrix <- cbind(name = groupnames(xdata), dataMatrix)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
242 variableMetadata <- featureDefinitions(xdata)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
243 colnames(variableMetadata)[1] <- "mz"
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
244 colnames(variableMetadata)[4] <- "rt"
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
245 variableMetadata <- data.frame(name = groupnames(xdata), variableMetadata)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
246
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
247 variableMetadata <- RTSecondToMinute(variableMetadata, convertRTMinute)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
248 variableMetadata <- formatIonIdentifiers(variableMetadata, numDigitsRT = numDigitsRT, numDigitsMZ = numDigitsMZ)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
249 dataMatrix <- naTOzeroDataMatrix(dataMatrix, naTOzero)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
250
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
251 # FIX: issue when the vector at peakidx is too long and is written in a new line during the export
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
252 variableMetadata[, "peakidx"] <- vapply(variableMetadata[, "peakidx"], FUN = paste, FUN.VALUE = character(1), collapse = ",")
7
a9d451591d7b planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 37b0a6a7686f701e4bf00db97ae2c1b82cd6e989
lecorguille
parents: 5
diff changeset
253
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
254 write.table(variableMetadata, file = variableMetadataOutput, sep = "\t", quote = FALSE, row.names = FALSE)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
255 write.table(dataMatrix, file = dataMatrixOutput, sep = "\t", quote = FALSE, row.names = FALSE)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
256 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
257
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
258 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
259 # It allow different of field separators
15
58b5a4b6e1da planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 2cb157bd9a8701a3d6874e084032cbd050b8953e
workflow4metabolomics
parents: 14
diff changeset
260 getDataFrameFromFile <- function(filename, header = TRUE) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
261 myDataFrame <- read.table(filename, header = header, sep = ";", stringsAsFactors = FALSE)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
262 if (ncol(myDataFrame) < 2) myDataFrame <- read.table(filename, header = header, sep = "\t", stringsAsFactors = FALSE)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
263 if (ncol(myDataFrame) < 2) myDataFrame <- read.table(filename, header = header, sep = ",", stringsAsFactors = FALSE)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
264 if (ncol(myDataFrame) < 2) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
265 error_message <- "Your tabular file seems not well formatted. The column separators accepted are ; , and tabulation"
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
266 print(error_message)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
267 stop(error_message)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
268 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
269 return(myDataFrame)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
270 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
271
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
272 # @author G. Le Corguille
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
273 # Draw the BPI and TIC graphics
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
274 # colored by sample names or class names
14
5bd125a3f3b0 "planemo upload for repository https://github.com/workflow4metabolomics/xcms commit dcc90f9cf76e6980c0a7d9698c89fab826e7adae"
workflow4metabolomics
parents: 13
diff changeset
275 getPlotChromatogram <- function(chrom, xdata, pdfname = "Chromatogram.pdf", aggregationFun = "max") {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
276 if (aggregationFun == "sum") {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
277 type <- "Total Ion Chromatograms"
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
278 } else {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
279 type <- "Base Peak Intensity Chromatograms"
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
280 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
281
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
282 adjusted <- "Raw"
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
283 if (hasAdjustedRtime(xdata)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
284 adjusted <- "Adjusted"
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
285 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
286
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
287 main <- paste(type, ":", adjusted, "data")
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
288
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
289 pdf(pdfname, width = 16, height = 10)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
290
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
291 # Color by group
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
292 if (length(unique(xdata$sample_group)) < 10) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
293 group_colors <- brewer.pal(length(unique(xdata$sample_group)), "Set1")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
294 } else {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
295 group_colors <- hcl.colors(length(unique(xdata$sample_group)), palette = "Dark 3")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
296 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
297 if (length(group_colors) > 1) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
298 names(group_colors) <- unique(xdata$sample_group)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
299 plot(chrom, col = group_colors[chrom$sample_group], main = main, peakType = "none")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
300 legend("topright", legend = names(group_colors), col = group_colors, cex = 0.8, lty = 1)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
301 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
302
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
303 # Color by sample
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
304 plot(chrom, col = rainbow(length(xdata@phenoData@data$sample_name)), main = main, peakType = "none")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
305 legend("topright", legend = xdata@phenoData@data$sample_name, col = rainbow(length(xdata@phenoData@data$sample_name)), cex = 0.8, lty = 1)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
306
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
307 dev.off()
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
308 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
309
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
310
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
311 # Get the polarities from all the samples of a condition
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
312 # @author Misharl Monsoor misharl.monsoor@sb-roscoff.fr ABiMS TEAM
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
313 # @author Gildas Le Corguille lecorguille@sb-roscoff.fr ABiMS TEAM
14
5bd125a3f3b0 "planemo upload for repository https://github.com/workflow4metabolomics/xcms commit dcc90f9cf76e6980c0a7d9698c89fab826e7adae"
workflow4metabolomics
parents: 13
diff changeset
314 getSampleMetadata <- function(xdata = NULL, sampleMetadataOutput = "sampleMetadata.tsv") {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
315 cat("Creating the sampleMetadata file...\n")
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
316
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
317 # Create the sampleMetada dataframe
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
318 sampleMetadata <- xdata@phenoData@data
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
319 rownames(sampleMetadata) <- NULL
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
320 colnames(sampleMetadata) <- c("sample_name", "class")
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
321
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
322 sampleNamesOrigin <- sampleMetadata$sample_name
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
323 sampleNamesMakeNames <- make.names(sampleNamesOrigin)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
324
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
325 if (any(duplicated(sampleNamesMakeNames))) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
326 write("\n\nERROR: Usually, R has trouble to deal with special characters in its column names, so it rename them using make.names().\nIn your case, at least two columns after the renaming obtain the same name, thus XCMS will collapse those columns per name.", stderr())
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
327 for (sampleName in sampleNamesOrigin) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
328 write(paste(sampleName, "\t->\t", make.names(sampleName)), stderr())
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
329 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
330 stop("\n\nERROR: One or more of your files will not be import by xcmsSet. It may due to bad characters in their filenames.")
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
331 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
332
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
333 if (!all(sampleNamesOrigin == sampleNamesMakeNames)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
334 cat("\n\nWARNING: Usually, R has trouble to deal with special characters in its column names, so it rename them using make.names()\nIn your case, one or more sample names will be renamed in the sampleMetadata and dataMatrix files:\n")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
335 for (sampleName in sampleNamesOrigin) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
336 cat(paste(sampleName, "\t->\t", make.names(sampleName), "\n"))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
337 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
338 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
339
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
340 sampleMetadata$sample_name <- sampleNamesMakeNames
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
341
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
342
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
343 # For each sample file, the following actions are done
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
344 for (fileIdx in seq_len(length(fileNames(xdata)))) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
345 # Check if the file is in the CDF format
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
346 if (!mzR:::netCDFIsFile(fileNames(xdata))) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
347 # If the column isn't exist, with add one filled with NA
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
348 if (is.null(sampleMetadata$polarity)) sampleMetadata$polarity <- NA
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
349
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
350 # Extract the polarity (a list of polarities)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
351 polarity <- fData(xdata)[fData(xdata)$fileIdx == fileIdx, "polarity"]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
352 # Verify if all the scans have the same polarity
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
353 uniq_list <- unique(polarity)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
354 if (length(uniq_list) > 1) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
355 polarity <- "mixed"
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
356 } else {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
357 polarity <- as.character(uniq_list)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
358 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
359
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
360 # Set the polarity attribute
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
361 sampleMetadata$polarity[fileIdx] <- polarity
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
362 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
363 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
364
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
365 write.table(sampleMetadata, sep = "\t", quote = FALSE, row.names = FALSE, file = sampleMetadataOutput)
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
366
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
367 return(list("sampleNamesOrigin" = sampleNamesOrigin, "sampleNamesMakeNames" = sampleNamesMakeNames))
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
368 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
369
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
370
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
371 # This function will compute MD5 checksum to check the data integrity
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
372 # @author Gildas Le Corguille lecorguille@sb-roscoff.fr
14
5bd125a3f3b0 "planemo upload for repository https://github.com/workflow4metabolomics/xcms commit dcc90f9cf76e6980c0a7d9698c89fab826e7adae"
workflow4metabolomics
parents: 13
diff changeset
373 getMd5sum <- function(files) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
374 cat("Compute md5 checksum...\n")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
375 library(tools)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
376 return(as.matrix(md5sum(files)))
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
377 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
378
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
379 # This function retrieve the raw file in the working directory
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
380 # - if zipfile: unzip the file with its directory tree
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
381 # - if singlefiles: set symlink with the good filename
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
382 # @author Gildas Le Corguille lecorguille@sb-roscoff.fr
14
5bd125a3f3b0 "planemo upload for repository https://github.com/workflow4metabolomics/xcms commit dcc90f9cf76e6980c0a7d9698c89fab826e7adae"
workflow4metabolomics
parents: 13
diff changeset
383 retrieveRawfileInTheWorkingDir <- function(singlefile, zipfile, args, prefix = "") {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
384 if (!(prefix %in% c("", "Positive", "Negative", "MS1", "MS2"))) stop("prefix must be either '', 'Positive', 'Negative', 'MS1' or 'MS2'")
13
39797c768bba "planemo upload for repository https://github.com/workflow4metabolomics/xcms commit f1caf2a3bf23cf319a75dd12c86402555dd02617"
workflow4metabolomics
parents: 12
diff changeset
385
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
386 # single - if the file are passed in the command arguments -> refresh singlefile
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
387 if (!is.null(args[[paste0("singlefile_galaxyPath", prefix)]])) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
388 singlefile_galaxyPaths <- unlist(strsplit(args[[paste0("singlefile_galaxyPath", prefix)]], "\\|"))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
389 singlefile_sampleNames <- unlist(strsplit(args[[paste0("singlefile_sampleName", prefix)]], "\\|"))
13
39797c768bba "planemo upload for repository https://github.com/workflow4metabolomics/xcms commit f1caf2a3bf23cf319a75dd12c86402555dd02617"
workflow4metabolomics
parents: 12
diff changeset
390
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
391 singlefile <- NULL
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
392 for (singlefile_galaxyPath_i in seq_len(length(singlefile_galaxyPaths))) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
393 singlefile_galaxyPath <- singlefile_galaxyPaths[singlefile_galaxyPath_i]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
394 singlefile_sampleName <- singlefile_sampleNames[singlefile_galaxyPath_i]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
395 # In case, an url is used to import data within Galaxy
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
396 singlefile_sampleName <- tail(unlist(strsplit(singlefile_sampleName, "/")), n = 1)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
397 singlefile[[singlefile_sampleName]] <- singlefile_galaxyPath
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
398 }
15
58b5a4b6e1da planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 2cb157bd9a8701a3d6874e084032cbd050b8953e
workflow4metabolomics
parents: 14
diff changeset
399 }
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
400 # zipfile - if the file are passed in the command arguments -> refresh zipfile
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
401 if (!is.null(args[[paste0("zipfile", prefix)]])) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
402 zipfile <- args[[paste0("zipfile", prefix)]]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
403 }
15
58b5a4b6e1da planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 2cb157bd9a8701a3d6874e084032cbd050b8953e
workflow4metabolomics
parents: 14
diff changeset
404
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
405 # single
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
406 if (!is.null(singlefile) && (length("singlefile") > 0)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
407 files <- vector()
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
408 for (singlefile_sampleName in names(singlefile)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
409 singlefile_galaxyPath <- singlefile[[singlefile_sampleName]]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
410 if (!file.exists(singlefile_galaxyPath)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
411 error_message <- paste("Cannot access the sample:", singlefile_sampleName, "located:", singlefile_galaxyPath, ". Please, contact your administrator ... if you have one!")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
412 print(error_message)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
413 stop(error_message)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
414 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
415
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
416 if (!suppressWarnings(try(file.link(singlefile_galaxyPath, singlefile_sampleName), silent = TRUE))) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
417 file.copy(singlefile_galaxyPath, singlefile_sampleName)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
418 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
419 files <- c(files, singlefile_sampleName)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
420 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
421 }
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
422 # zipfile
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
423 if (!is.null(zipfile) && (zipfile != "")) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
424 if (!file.exists(zipfile)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
425 error_message <- paste("Cannot access the Zip file:", zipfile, ". Please, contact your administrator ... if you have one!")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
426 print(error_message)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
427 stop(error_message)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
428 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
429 suppressWarnings(unzip(zipfile, unzip = "unzip"))
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
430
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
431 # get the directory name
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
432 suppressWarnings(filesInZip <- unzip(zipfile, list = TRUE))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
433 directories <- unique(unlist(lapply(strsplit(filesInZip$Name, "/"), function(x) x[1])))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
434 directories <- directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
435 directory <- "."
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
436 if (length(directories) == 1) directory <- directories
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
437
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
438 cat("files_root_directory\t", directory, "\n")
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
439
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
440 filepattern <- c("[Cc][Dd][Ff]", "[Nn][Cc]", "([Mm][Zz])?[Xx][Mm][Ll]", "[Mm][Zz][Dd][Aa][Tt][Aa]", "[Mm][Zz][Mm][Ll]")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
441 filepattern <- paste(paste("\\.", filepattern, "$", sep = ""), collapse = "|")
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
442 info <- file.info(directory)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
443 listed <- list.files(directory[info$isdir], pattern = filepattern, recursive = TRUE, full.names = TRUE)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
444 files <- c(directory[!info$isdir], listed)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
445 exists <- file.exists(files)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
446 files <- files[exists]
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
447 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
448 return(list(zipfile = zipfile, singlefile = singlefile, files = files))
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
449 }
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
450
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
451
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
452 # This function retrieve a xset like object
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
453 # @author Gildas Le Corguille lecorguille@sb-roscoff.fr
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
454 getxcmsSetObject <- function(xobject) {
17
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
455 # XCMS 1.x
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
456 if (class(xobject) == "xcmsSet") {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
457 return(xobject)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
458 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
459 # XCMS 3.x
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
460 if (class(xobject) == "XCMSnExp") {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
461 # Get the legacy xcmsSet object
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
462 suppressWarnings(xset <- as(xobject, "xcmsSet"))
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
463 if (!is.null(xset@phenoData$sample_group)) {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
464 sampclass(xset) <- xset@phenoData$sample_group
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
465 } else {
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
466 sampclass(xset) <- "."
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
467 }
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
468 return(xset)
ae28a753a6f8 planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
workflow4metabolomics
parents: 15
diff changeset
469 }
3
f439ed7a8f03 planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
470 }