annotate lib-xcms3.x.x.r @ 1:98aff9eca8b7 draft

planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
author lecorguille
date Wed, 19 Sep 2018 02:51:20 -0400
parents 728ebc7ae7dd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
1
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
2
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
3 #@TODO: remove this function as soon as we can use xcms 3.x.x from Bioconductor 3.7
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
4 # https://github.com/sneumann/xcms/issues/250
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
5 groupnamesW4M <- function(xdata, mzdec = 0, rtdec = 0) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
6 mzfmt <- paste("%.", mzdec, "f", sep = "")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
7 rtfmt <- paste("%.", rtdec, "f", sep = "")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
8
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
9 gnames <- paste("M", sprintf(mzfmt, featureDefinitions(xdata)[,"mzmed"]), "T",
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
10 sprintf(rtfmt, featureDefinitions(xdata)[,"rtmed"]), sep = "")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
11
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
12 if (any(dup <- duplicated(gnames)))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
13 for (dupname in unique(gnames[dup])) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
14 dupidx <- which(gnames == dupname)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
15 gnames[dupidx] <- paste(gnames[dupidx], seq(along = dupidx), sep = "_")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
16 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
17
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
18 return (gnames)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
19 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
20
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
21 #@TODO: remove this function as soon as we can use xcms 3.x.x from Bioconductor 3.7
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
22 # https://github.com/sneumann/xcms/issues/247
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
23 .concatenate_XCMSnExp <- function(...) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
24 x <- list(...)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
25 if (length(x) == 0)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
26 return(NULL)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
27 if (length(x) == 1)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
28 return(x[[1]])
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
29 ## Check that all are XCMSnExp objects.
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
30 if (!all(unlist(lapply(x, function(z) is(z, "XCMSnExp")))))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
31 stop("All passed objects should be 'XCMSnExp' objects")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
32 new_x <- as(.concatenate_OnDiskMSnExp(...), "XCMSnExp")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
33 ## If any of the XCMSnExp has alignment results or detected features drop
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
34 ## them!
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
35 x <- lapply(x, function(z) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
36 if (hasAdjustedRtime(z)) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
37 z <- dropAdjustedRtime(z)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
38 warning("Adjusted retention times found, had to drop them.")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
39 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
40 if (hasFeatures(z)) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
41 z <- dropFeatureDefinitions(z)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
42 warning("Feature definitions found, had to drop them.")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
43 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
44 z
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
45 })
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
46 ## Combine peaks
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
47 fls <- lapply(x, fileNames)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
48 startidx <- cumsum(lengths(fls))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
49 pks <- lapply(x, chromPeaks)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
50 procH <- lapply(x, processHistory)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
51 for (i in 2:length(fls)) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
52 pks[[i]][, "sample"] <- pks[[i]][, "sample"] + startidx[i - 1]
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
53 procH[[i]] <- lapply(procH[[i]], function(z) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
54 z@fileIndex <- as.integer(z@fileIndex + startidx[i - 1])
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
55 z
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
56 })
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
57 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
58 pks <- do.call(rbind, pks)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
59 new_x@.processHistory <- unlist(procH)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
60 chromPeaks(new_x) <- pks
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
61 if (validObject(new_x))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
62 new_x
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
63 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
64
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
65 #@TODO: remove this function as soon as we can use xcms 3.x.x from Bioconductor 3.7
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
66 # https://github.com/sneumann/xcms/issues/247
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
67 .concatenate_OnDiskMSnExp <- function(...) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
68 x <- list(...)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
69 if (length(x) == 0)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
70 return(NULL)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
71 if (length(x) == 1)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
72 return(x[[1]])
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
73 ## Check that all are XCMSnExp objects.
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
74 if (!all(unlist(lapply(x, function(z) is(z, "OnDiskMSnExp")))))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
75 stop("All passed objects should be 'OnDiskMSnExp' objects")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
76 ## Check processingQueue
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
77 procQ <- lapply(x, function(z) z@spectraProcessingQueue)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
78 new_procQ <- procQ[[1]]
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
79 is_ok <- unlist(lapply(procQ, function(z)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
80 !is.character(all.equal(new_procQ, z))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
81 ))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
82 if (any(!is_ok)) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
83 warning("Processing queues from the submitted objects differ! ",
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
84 "Dropping the processing queue.")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
85 new_procQ <- list()
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
86 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
87 ## processingData
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
88 fls <- lapply(x, function(z) z@processingData@files)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
89 startidx <- cumsum(lengths(fls))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
90 ## featureData
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
91 featd <- lapply(x, fData)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
92 ## Have to update the file index and the spectrum names.
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
93 for (i in 2:length(featd)) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
94 featd[[i]]$fileIdx <- featd[[i]]$fileIdx + startidx[i - 1]
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
95 rownames(featd[[i]]) <- MSnbase:::formatFileSpectrumNames(
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
96 fileIds = featd[[i]]$fileIdx,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
97 spectrumIds = featd[[i]]$spIdx,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
98 nSpectra = nrow(featd[[i]]),
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
99 nFiles = length(unlist(fls))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
100 )
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
101 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
102 featd <- do.call(rbind, featd)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
103 featd$spectrum <- 1:nrow(featd)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
104 ## experimentData
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
105 expdata <- lapply(x, function(z) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
106 ed <- z@experimentData
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
107 data.frame(instrumentManufacturer = ed@instrumentManufacturer,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
108 instrumentModel = ed@instrumentModel,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
109 ionSource = ed@ionSource,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
110 analyser = ed@analyser,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
111 detectorType = ed@detectorType,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
112 stringsAsFactors = FALSE)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
113 })
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
114 expdata <- do.call(rbind, expdata)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
115 expdata <- new("MIAPE",
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
116 instrumentManufacturer = expdata$instrumentManufacturer,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
117 instrumentModel = expdata$instrumentModel,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
118 ionSource = expdata$ionSource,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
119 analyser = expdata$analyser,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
120 detectorType = expdata$detectorType)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
121
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
122 ## protocolData
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
123 protodata <- lapply(x, function(z) z@protocolData)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
124 if (any(unlist(lapply(protodata, nrow)) > 0))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
125 warning("Found non-empty protocol data, but merging protocol data is",
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
126 " currently not supported. Skipped.")
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
127 ## phenoData
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
128 pdata <- do.call(rbind, lapply(x, pData))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
129 res <- new(
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
130 "OnDiskMSnExp",
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
131 phenoData = new("NAnnotatedDataFrame", data = pdata),
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
132 featureData = new("AnnotatedDataFrame", featd),
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
133 processingData = new("MSnProcess",
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
134 processing = paste0("Concatenated [", date(), "]"),
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
135 files = unlist(fls), smoothed = NA),
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
136 experimentData = expdata,
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
137 spectraProcessingQueue = new_procQ)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
138 if (validObject(res))
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
139 res
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
140 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
141
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
142 #@TODO: remove this function as soon as we can use xcms 3.x.x from Bioconductor 3.7
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
143 # https://github.com/sneumann/xcms/issues/247
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
144 c.XCMSnExp <- function(...) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
145 .concatenate_XCMSnExp(...)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
146 }
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
147
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
148 #@TODO: remove this function as soon as we can use xcms 3.x.x from Bioconductor 3.7
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
149 # https://github.com/sneumann/xcms/issues/247
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
150 c.MSnbase <- function(...) {
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
151 .concatenate_OnDiskMSnExp(...)
728ebc7ae7dd planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 9f72e947d9c241d11221cad561f3525d27231857
lecorguille
parents:
diff changeset
152 }