annotate createDatabase.R @ 4:e96c518a3f06 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 75d13d0237560528a1c6596a3ea5e327bed3e3a0
author tomnl
date Tue, 18 Jun 2019 10:50:01 -0400
parents 0a3e6c28f1ab
children f12213ae74c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
1 library(msPurity)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
2 library(optparse)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
3 library(xcms)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
4 library(CAMERA)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
5 print(sessionInfo())
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
6 print('CREATING DATABASE')
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
7
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
8
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
9
fc9bb7e49a3a 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){
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
11
fc9bb7e49a3a 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)){
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
13 # NOTE: Relies on the pa@fileList having the names of files given as 'names' of the variables
0
fc9bb7e49a3a 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
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
15
fc9bb7e49a3a 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]])
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
17 filepaths <- filepaths[filepaths != ""]
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
18 new_names <- basename(filepaths)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
19
fc9bb7e49a3a 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]])
fc9bb7e49a3a 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 != ""]
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
22
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
23 nsave <- names(pa@fileList)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
24 old_filenames <- basename(pa@fileList)
fc9bb7e49a3a 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)]
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
26 names(pa@fileList) <- nsave
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
27
fc9bb7e49a3a 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)])
fc9bb7e49a3a 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)])
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
30 }
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
31
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
32
fc9bb7e49a3a 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))){
fc9bb7e49a3a 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))){
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
35 print('FILELISTS DO NOT MATCH')
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
36 message('FILELISTS DO NOT MATCH')
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
37 quit(status = 1)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
38 }else{
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
39 xset@filepaths <- unname(pa@fileList)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
40 }
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
41 }
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
42
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
43 print(xset@phenoData)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
44 print(xset@filepaths)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
45
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
46 return(list(pa, xset))
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
47 }
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
48
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
49
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
50
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
51
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
52 option_list <- list(
fc9bb7e49a3a 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"),
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
54 make_option("--pa", type="character"),
fc9bb7e49a3a 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"),
fc9bb7e49a3a 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"),
fc9bb7e49a3a 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"),
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
58 make_option("--cores", default=4),
fc9bb7e49a3a 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"),
fc9bb7e49a3a 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"),
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
61 make_option("--grpPeaklist", type="character")
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
62 )
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
63
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
64
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
65 # store options
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
66 opt<- parse_args(OptionParser(option_list=option_list))
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
67 print(opt)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
68
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
69 loadRData <- function(rdata_path, name){
2
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
70 #loads an RData file, and returns the named xset object if it is there
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
71 load(rdata_path)
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
72 return(get(ls()[ls() %in% name]))
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
73 }
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
74
2
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
75 getxcmsSetObject <- function(xobject) {
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
76 # XCMS 1.x
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
77 if (class(xobject) == "xcmsSet")
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
78 return (xobject)
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
79 # XCMS 3.x
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
80 if (class(xobject) == "XCMSnExp") {
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
81 # Get the legacy xcmsSet object
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
82 suppressWarnings(xset <- as(xobject, 'xcmsSet'))
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
83 sampclass(xset) <- xset@phenoData$sample_group
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
84 return (xset)
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
85 }
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
86 }
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
87
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
88
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
89 print(paste('pa', opt$pa))
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
90 print(opt$xset)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
91
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
92 print(opt$xcms_camera_option)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
93 # Requires
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
94 pa <- loadRData(opt$pa, 'pa')
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
95
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
96
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
97 print(pa@fileList)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
98
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
99
2
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
100
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
101 if (opt$xcms_camera_option=='xcms'){
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
102
2
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
103 xset <- loadRData(opt$xset, c('xset','xdata'))
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
104 xset <- getxcmsSetObject(xset)
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
105 fix <- xset_pa_filename_fix(opt, pa, xset)
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
106 pa <- fix[[1]]
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
107 xset <- fix[[2]]
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
108 xa <- NULL
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
109 }else{
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
110
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
111 xa <- loadRData(opt$xset, 'xa')
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
112 fix <- xset_pa_filename_fix(opt, pa, xa@xcmsSet)
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
113 pa <- fix[[1]]
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
114 xa@xcmsSet <- fix[[2]]
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
115 xset <- NULL
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
116 }
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
117
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
118
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
119
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
120 if(is.null(opt$grp_peaklist)){
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
121 grpPeaklist = NA
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
122 }else{
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
123 grpPeaklist = opt$grp_peaklist
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
124 }
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
125
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
126
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
127
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
128 dbPth <- msPurity::createDatabase(pa,
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
129 xset=xset,
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
130 xsa=xa,
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
131 outDir=opt$outDir,
2
b1d4689e8a26 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
tomnl
parents: 0
diff changeset
132 grpPeaklist=grpPeaklist,
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
133 dbName='createDatabase_output.sqlite'
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
134 )
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
135
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
136
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
137
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
138
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
139
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
140 if (!is.null(opt$eic)){
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
141
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
142 if (is.null(xset)){
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
143 xset <- xa@xcmsSet
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
144 }
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
145 # previous check should have matched filelists together
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
146 xset@filepaths <- unname(pa@fileList)
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
147
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
148 convert2Raw <- function(x, xset){
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
149 sid <- unique(x$sample)
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
150 # for each file get list of peaks
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
151 x$rt_raw <- xset@rt$raw[[sid]][match(x$rt, xset@rt$corrected[[sid]])]
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
152 x$rtmin_raw <- xset@rt$raw[[sid]][match(x$rtmin, xset@rt$corrected[[sid]])]
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
153 x$rtmax_raw <- xset@rt$raw[[sid]][match(x$rtmax, xset@rt$corrected[[sid]])]
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
154 return(x)
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
155
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
156 }
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
157
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
158 xset@peaks <- as.matrix(plyr::ddply(data.frame(xset@peaks), ~ sample, convert2Raw, xset=xset))
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
159
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
160 # Saves the EICS into the previously created database
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
161 px <- msPurity::purityX(xset, saveEIC = TRUE,
4
e96c518a3f06 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 75d13d0237560528a1c6596a3ea5e327bed3e3a0
tomnl
parents: 3
diff changeset
162 cores=2, sqlitePth=dbPth,
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
163 rtrawColumns = TRUE)
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
164
0
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
165 }
fc9bb7e49a3a planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
166
3
0a3e6c28f1ab planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
167 closeAllConnections()