annotate createDatabase.R @ 6:2b13f1ae8041 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 14eafbdb65f491713d1314d77c454defd137c392
author tomnl
date Tue, 18 Jun 2019 11:03:56 -0400
parents 3de08f3c4fb6
children e6a78f89ee07
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)){
4
13985cdcf0ba 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
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"),
4
13985cdcf0ba 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
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
62 )
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 # store options
df2efceff4cd 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))
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
67 print(opt)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
68
df2efceff4cd 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
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
70 #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
71 load(rdata_path)
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
72 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
73 }
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
74
2
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
75 getxcmsSetObject <- function(xobject) {
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
76 # XCMS 1.x
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
77 if (class(xobject) == "xcmsSet")
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
78 return (xobject)
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
79 # XCMS 3.x
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
80 if (class(xobject) == "XCMSnExp") {
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
81 # 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
82 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
83 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
84 return (xset)
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
85 }
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
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
89 print(paste('pa', opt$pa))
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
90 print(opt$xset)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
91
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
92 print(opt$xcms_camera_option)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
93 # Requires
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
94 pa <- loadRData(opt$pa, 'pa')
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
95
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 print(pa@fileList)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
98
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
99
2
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
100
0
df2efceff4cd 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'){
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
102
2
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
103 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
104 xset <- getxcmsSetObject(xset)
4
13985cdcf0ba 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
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
106 pa <- fix[[1]]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
107 xset <- fix[[2]]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
108 xa <- NULL
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
109 }else{
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
110
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
111 xa <- loadRData(opt$xset, 'xa')
4
13985cdcf0ba 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
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
113 pa <- fix[[1]]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
114 xa@xcmsSet <- fix[[2]]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
115 xset <- NULL
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
116 }
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 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
121 grpPeaklist = NA
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
122 }else{
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
123 grpPeaklist = opt$grp_peaklist
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
124 }
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 dbPth <- msPurity::createDatabase(pa,
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
129 xset=xset,
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
130 xsa=xa,
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
131 outDir=opt$outDir,
2
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
132 grpPeaklist=grpPeaklist,
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
133 dbName='createDatabase_output.sqlite'
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
134 )
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
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
138
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
139
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
140 if (!is.null(opt$eic)){
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
141
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
142 if (is.null(xset)){
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
143 xset <- xa@xcmsSet
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 # 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
146 xset@filepaths <- unname(pa@fileList)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
147
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
148 convert2Raw <- function(x, xset){
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
149 sid <- unique(x$sample)
13985cdcf0ba 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
13985cdcf0ba 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]])]
13985cdcf0ba 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]])]
13985cdcf0ba 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]])]
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
154 return(x)
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
155
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
156 }
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
157
13985cdcf0ba 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))
6
2b13f1ae8041 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 14eafbdb65f491713d1314d77c454defd137c392
tomnl
parents: 5
diff changeset
159 closeAllConnections()
0
df2efceff4cd 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
df2efceff4cd 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,
6
2b13f1ae8041 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 14eafbdb65f491713d1314d77c454defd137c392
tomnl
parents: 5
diff changeset
162 cores=1, sqlitePth=dbPth,
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
163 rtrawColumns = TRUE)
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
164
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
165 }
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
166
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
167 closeAllConnections()