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