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