annotate lib-xcms3.x.x.r @ 36:eddc995c6df1 draft

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