Mercurial > repos > computational-metabolomics > mspurity_createdatabase
annotate createDatabase.R @ 11:fa84bfaab681 draft default tip
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 94f746247c464fb270358421399810d8a9fb9e8a
author | computational-metabolomics |
---|---|
date | Fri, 13 Sep 2024 13:39:28 +0000 |
parents | efd14b326007 |
children |
rev | line source |
---|---|
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
1 library(msPurity) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
2 library(optparse) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
3 library(xcms) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
4 library(CAMERA) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
5 print(sessionInfo()) |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
6 print("CREATING DATABASE") |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
7 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
8 xset_pa_filename_fix <- function(opt, pa, xset) { |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
9 if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)) { |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
10 # NOTE: Relies on the pa@fileList having the names of files given as 'names' of the variables |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
11 # needs to be done due to Galaxy moving the files around and screwing up any links to files |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
12 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
13 filepaths <- trimws(strsplit(opt$mzML_files, ",")[[1]]) |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
14 filepaths <- filepaths[filepaths != ""] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
15 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
16 galaxy_names <- trimws(strsplit(opt$galaxy_names, ",")[[1]]) |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
17 galaxy_names <- galaxy_names[galaxy_names != ""] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
18 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
19 nsave <- names(pa@fileList) |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
20 old_filenames <- basename(pa@fileList) |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
21 pa@fileList <- filepaths[match(names(pa@fileList), galaxy_names)] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
22 names(pa@fileList) <- nsave |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
23 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
24 pa@puritydf$filename <- basename(pa@fileList[match(pa@puritydf$filename, old_filenames)]) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
25 pa@grped_df$filename <- basename(pa@fileList[match(pa@grped_df$filename, old_filenames)]) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
26 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
27 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
28 |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
29 if (!all(basename(pa@fileList) == basename(xset@filepaths))) { |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
30 if (!all(names(pa@fileList) == basename(xset@filepaths))) { |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
31 print("FILELISTS DO NOT MATCH") |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
32 message("FILELISTS DO NOT MATCH") |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
33 quit(status = 1) |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
34 } else { |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
35 xset@filepaths <- unname(pa@fileList) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
36 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
37 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
38 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
39 print(xset@phenoData) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
40 print(xset@filepaths) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
41 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
42 return(list(pa, xset)) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
43 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
44 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
45 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
46 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
47 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
48 option_list <- list( |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
49 make_option(c("-o", "--outDir"), type = "character"), |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
50 make_option("--pa", type = "character"), |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
51 make_option("--xset_xa", type = "character"), |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
52 make_option("--xcms_camera_option", type = "character"), |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
53 make_option("--eic", action = "store_true"), |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
54 make_option("--cores", default = 4), |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
55 make_option("--mzML_files", type = "character"), |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
56 make_option("--galaxy_names", type = "character"), |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
57 make_option("--grpPeaklist", type = "character") |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
58 ) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
59 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
60 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
61 # store options |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
62 opt <- parse_args(OptionParser(option_list = option_list)) |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
63 print(opt) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
64 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
65 loadRData <- function(rdata_path, name) { |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
66 # loads an RData file, and returns the named xset object if it is there |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
67 load(rdata_path) |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
68 return(get(ls()[ls() %in% name])) |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
69 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
70 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
71 getxcmsSetObject <- function(xobject) { |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
72 # XCMS 1.x |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
73 if (class(xobject) == "xcmsSet") { |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
74 return(xobject) |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
75 } |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
76 # XCMS 3.x |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
77 if (class(xobject) == "XCMSnExp") { |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
78 # Get the legacy xcmsSet object |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
79 suppressWarnings(xset <- as(xobject, "xcmsSet")) |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
80 xcms::sampclass(xset) <- xset@phenoData$sample_group |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
81 return(xset) |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
82 } |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
83 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
84 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
85 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
86 print(paste("pa", opt$pa)) |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
87 print(opt$xset) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
88 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
89 print(opt$xcms_camera_option) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
90 # Requires |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
91 pa <- loadRData(opt$pa, "pa") |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
92 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
93 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
94 print(pa@fileList) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
95 |
4
3d36a391612c
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cbbd708ea1e93b1b1643f6bf6da72af65ffd9950"
computational-metabolomics
parents:
2
diff
changeset
|
96 # Missing list element causes failures (should be updated |
3d36a391612c
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cbbd708ea1e93b1b1643f6bf6da72af65ffd9950"
computational-metabolomics
parents:
2
diff
changeset
|
97 # in msPurity R package for future releases) |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
98 if (!exists("allfrag", where = pa@filter_frag_params)) { |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
99 pa@filter_frag_params$allfrag <- FALSE |
4
3d36a391612c
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cbbd708ea1e93b1b1643f6bf6da72af65ffd9950"
computational-metabolomics
parents:
2
diff
changeset
|
100 } |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
101 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
102 if (opt$xcms_camera_option == "xcms") { |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
103 xset <- loadRData(opt$xset, c("xset", "xdata")) |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
104 xset <- getxcmsSetObject(xset) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
105 fix <- xset_pa_filename_fix(opt, pa, xset) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
106 pa <- fix[[1]] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
107 xset <- fix[[2]] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
108 xa <- NULL |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
109 } else { |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
110 xa <- loadRData(opt$xset, "xa") |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
111 fix <- xset_pa_filename_fix(opt, pa, xa@xcmsSet) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
112 pa <- fix[[1]] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
113 xa@xcmsSet <- fix[[2]] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
114 xset <- NULL |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
115 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
116 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
117 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
118 if (is.null(opt$grpPeaklist)) { |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
119 grpPeaklist <- NA |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
120 } else { |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
121 grpPeaklist <- opt$grpPeaklist |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
122 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
123 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
124 dbPth <- msPurity::createDatabase(pa, |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
125 xset = xset, |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
126 xsa = xa, |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
127 outDir = opt$outDir, |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
128 grpPeaklist = grpPeaklist, |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
129 dbName = "createDatabase_output.sqlite" |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
130 ) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
131 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
132 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
133 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
134 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
135 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
136 if (!is.null(opt$eic)) { |
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
137 if (is.null(xset)) { |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
138 xset <- xa@xcmsSet |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
139 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
140 # previous check should have matched filelists together |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
141 xset@filepaths <- unname(pa@fileList) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
142 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
143 convert2Raw <- function(x, xset) { |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
144 sid <- unique(x$sample) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
145 # for each file get list of peaks |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
146 x$rt_raw <- xset@rt$raw[[sid]][match(x$rt, xset@rt$corrected[[sid]])] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
147 x$rtmin_raw <- xset@rt$raw[[sid]][match(x$rtmin, xset@rt$corrected[[sid]])] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
148 x$rtmax_raw <- xset@rt$raw[[sid]][match(x$rtmax, xset@rt$corrected[[sid]])] |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
149 return(x) |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
150 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
151 |
6
2f71b3495221
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents:
4
diff
changeset
|
152 xset@peaks <- as.matrix( |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
153 plyr::ddply(data.frame(xset@peaks), ~sample, convert2Raw, xset = xset) |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
154 ) |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
155 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
156 # Saves the EICS into the previously created database |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
157 px <- msPurity::purityX(xset, |
8
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
158 saveEIC = TRUE, |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
159 cores = 1, |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
160 sqlitePth = dbPth, |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
161 rtrawColumns = TRUE |
efd14b326007
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents:
6
diff
changeset
|
162 ) |
0
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
163 } |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
164 |
f52287a06c02
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff
changeset
|
165 closeAllConnections() |