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