annotate createDatabase.R @ 10:eeae5175cfed draft

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