annotate createDatabase.R @ 11:4b3b0f5a55d9 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit b6b8da66a6eef180ca8e333f98fc4b7575bac7b3
author tomnl
date Thu, 27 Jun 2019 12:34:09 -0400
parents e6a78f89ee07
children
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 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
9
df2efceff4cd 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)){
4
13985cdcf0ba 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
df2efceff4cd 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
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
13
df2efceff4cd 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]])
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
15 filepaths <- filepaths[filepaths != ""]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
16 new_names <- basename(filepaths)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
17
df2efceff4cd 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]])
df2efceff4cd 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 != ""]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
20
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
21 nsave <- names(pa@fileList)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
22 old_filenames <- basename(pa@fileList)
df2efceff4cd 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)]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
24 names(pa@fileList) <- nsave
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
25
df2efceff4cd 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)])
df2efceff4cd 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)])
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
28 }
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
29
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 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
32 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
33 print('FILELISTS DO NOT MATCH')
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
34 message('FILELISTS DO NOT MATCH')
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
35 quit(status = 1)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
36 }else{
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
37 xset@filepaths <- unname(pa@fileList)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
38 }
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
39 }
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 print(xset@phenoData)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
42 print(xset@filepaths)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
43
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
44 return(list(pa, xset))
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
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 option_list <- list(
df2efceff4cd 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"),
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
52 make_option("--pa", type="character"),
df2efceff4cd 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"),
df2efceff4cd 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"),
df2efceff4cd 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"),
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
56 make_option("--cores", default=4),
df2efceff4cd 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"),
df2efceff4cd 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"),
4
13985cdcf0ba 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
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
60 )
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
61
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 # store options
df2efceff4cd 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))
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
65 print(opt)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
66
df2efceff4cd 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
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
68 #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
69 load(rdata_path)
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
70 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
71 }
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
72
2
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
73 getxcmsSetObject <- function(xobject) {
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
74 # XCMS 1.x
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
75 if (class(xobject) == "xcmsSet")
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
76 return (xobject)
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
77 # XCMS 3.x
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
78 if (class(xobject) == "XCMSnExp") {
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
79 # 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
80 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
81 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
82 return (xset)
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
83 }
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
84 }
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
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
87 print(paste('pa', opt$pa))
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
88 print(opt$xset)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
89
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
90 print(opt$xcms_camera_option)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
91 # Requires
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
92 pa <- loadRData(opt$pa, 'pa')
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
93
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
94
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
95 print(pa@fileList)
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
2
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
98
0
df2efceff4cd 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'){
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
100
2
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
101 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
102 xset <- getxcmsSetObject(xset)
4
13985cdcf0ba 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
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
104 pa <- fix[[1]]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
105 xset <- fix[[2]]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
106 xa <- NULL
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
107 }else{
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
108
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
109 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
110 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
111 pa <- fix[[1]]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
112 xa@xcmsSet <- fix[[2]]
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
113 xset <- NULL
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
114 }
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
115
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 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
119 grpPeaklist = NA
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
120 }else{
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
121 grpPeaklist = opt$grp_peaklist
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
122 }
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
123
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 dbPth <- msPurity::createDatabase(pa,
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
127 xset=xset,
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
128 xsa=xa,
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
129 outDir=opt$outDir,
2
7e7223015600 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit d9efa3f24732a92c2bcef5987289179e86d5c50f-dirty
tomnl
parents: 0
diff changeset
130 grpPeaklist=grpPeaklist,
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
131 dbName='createDatabase_output.sqlite'
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
132 )
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
133
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
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
136
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
137
0
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
138 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
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(xset)){
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
141 xset <- xa@xcmsSet
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
142 }
df2efceff4cd 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
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
144 xset@filepaths <- unname(pa@fileList)
df2efceff4cd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
145
4
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
146 convert2Raw <- function(x, xset){
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
147 sid <- unique(x$sample)
13985cdcf0ba 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
13985cdcf0ba 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]])]
13985cdcf0ba 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]])]
13985cdcf0ba 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]])]
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
152 return(x)
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
153
13985cdcf0ba planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e05cb49ba56d359fec34f132d1c9ace582e5b483-dirty
tomnl
parents: 2
diff changeset
154 }
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 xset@peaks <- as.matrix(plyr::ddply(data.frame(xset@peaks), ~ sample, convert2Raw, xset=xset))
11
4b3b0f5a55d9 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit b6b8da66a6eef180ca8e333f98fc4b7575bac7b3
tomnl
parents: 9
diff changeset
157
0
df2efceff4cd 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
11
4b3b0f5a55d9 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit b6b8da66a6eef180ca8e333f98fc4b7575bac7b3
tomnl
parents: 9
diff changeset
159 px <- msPurity::purityX(xset,
9
e6a78f89ee07 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 74e7bfbb5e70ec6e665114fa9e9863dafd7bced5
tomnl
parents: 6
diff changeset
160 saveEIC = TRUE,
e6a78f89ee07 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 74e7bfbb5e70ec6e665114fa9e9863dafd7bced5
tomnl
parents: 6
diff changeset
161 cores=1,
e6a78f89ee07 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 74e7bfbb5e70ec6e665114fa9e9863dafd7bced5
tomnl
parents: 6
diff changeset
162 sqlitePth=dbPth,
11
4b3b0f5a55d9 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit b6b8da66a6eef180ca8e333f98fc4b7575bac7b3
tomnl
parents: 9
diff changeset
163 rtrawColumns = TRUE)
4
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()