annotate frag4feature.R @ 12:cb8dce9812ff draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
author tomnl
date Thu, 14 Jun 2018 09:19:47 -0400
parents
children ac2e4562b70a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
1 library(optparse)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
2 library(msPurity)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
3 library(xcms)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
4 print(sessionInfo())
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
5
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
6 xset_pa_filename_fix <- function(opt, pa, xset){
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
7
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
8
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
9 if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)){
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
10 # NOTE: Relies on the pa@fileList having the names of files given as 'names' of the variables
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
11 # needs to be done due to Galaxy moving the files around and screwing up any links to files
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
12
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
13 filepaths <- trimws(strsplit(opt$mzML_files, ',')[[1]])
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
14 filepaths <- filepaths[filepaths != ""]
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
15 new_names <- basename(filepaths)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
16
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
17 galaxy_names <- trimws(strsplit(opt$galaxy_names, ',')[[1]])
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
18 galaxy_names <- galaxy_names[galaxy_names != ""]
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
19
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
20 nsave <- names(pa@fileList)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
21 old_filenames <- basename(pa@fileList)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
22
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
23 pa@fileList <- filepaths[match(names(pa@fileList), galaxy_names)]
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
24 names(pa@fileList) <- nsave
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
25
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
26 pa@puritydf$filename <- basename(pa@fileList[match(pa@puritydf$filename, old_filenames)])
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
27 pa@grped_df$filename <- basename(pa@fileList[match(pa@grped_df$filename, old_filenames)])
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
28 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
29 print(pa@fileList)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
30 print(xset@filepaths)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
31
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
32 if(!all(basename(pa@fileList)==basename(xset@filepaths))){
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
33 if(!all(names(pa@fileList)==basename(xset@filepaths))){
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
34 print('FILELISTS DO NOT MATCH')
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
35 message('FILELISTS DO NOT MATCH')
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
36 quit(status = 1)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
37 }else{
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
38 xset@filepaths <- unname(pa@fileList)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
39 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
40 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
41
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
42
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
43 return(list(pa, xset))
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
44 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
45
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
46
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
47 option_list <- list(
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
48 make_option(c("-o", "--out_dir"), type="character"),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
49 make_option("--pa", type="character"),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
50 make_option("--xset", type="character"),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
51 make_option("--ppm", default=10),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
52 make_option("--plim", default=0.0),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
53 make_option("--convert2RawRT", action="store_true"),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
54 make_option("--mostIntense", action="store_true"),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
55 make_option("--createDB", action="store_true"),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
56 make_option("--cores", default=4),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
57 make_option("--mzML_files", type="character"),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
58 make_option("--galaxy_names", type="character"),
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
59 make_option("--grp_peaklist", type="character")
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
60 )
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
61
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
62 # store options
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
63 opt<- parse_args(OptionParser(option_list=option_list))
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
64
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
65 loadRData <- function(rdata_path, name){
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
66 #loads an RData file, and returns the named xset object if it is there
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
67 load(rdata_path)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
68 return(get(ls()[ls() %in% name]))
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
69 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
70
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
71 # This function retrieve a xset like object
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
72 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
73 getxcmsSetObject <- function(xobject) {
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
74 # XCMS 1.x
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
75 if (class(xobject) == "xcmsSet")
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
76 return (xobject)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
77 # XCMS 3.x
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
78 if (class(xobject) == "XCMSnExp") {
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
79 # Get the legacy xcmsSet object
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
80 suppressWarnings(xset <- as(xobject, 'xcmsSet'))
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
81 sampclass(xset) <- xset@phenoData$sample_group
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
82 return (xset)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
83 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
84 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
85
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
86 # Requires
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
87 pa <- loadRData(opt$pa, 'pa')
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
88 xset <- loadRData(opt$xset, c('xset','xdata'))
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
89 xset <- getxcmsSetObject(xset)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
90
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
91 pa@cores <- opt$cores
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
92
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
93 print(pa@fileList)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
94 print(xset@filepaths)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
95
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
96 if(is.null(opt$mostIntense)){
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
97 mostIntense = FALSE
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
98 }else{
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
99 mostIntense = TRUE
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
100 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
101
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
102 if(is.null(opt$convert2RawRT)){
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
103 convert2RawRT = FALSE
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
104 }else{
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
105 convert2RawRT= TRUE
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
106 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
107
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
108 if(is.null(opt$createDB)){
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
109 createDB = FALSE
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
110 }else{
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
111 createDB = TRUE
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
112 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
113
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
114
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
115 fix <- xset_pa_filename_fix(opt, pa, xset)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
116 pa <- fix[[1]]
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
117 xset <- fix[[2]]
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
118
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
119 if(is.null(opt$grp_peaklist)){
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
120 grp_peaklist = NA
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
121 }else{
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
122 grp_peaklist = opt$grp_peaklist
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
123 }
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
124
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
125 print(pa@fileList)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
126 print(names(pa@fileList))
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
127 print(xset@filepaths)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
128 saveRDS(pa, 'test_pa.rds')
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
129
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
130 pa <- msPurity::frag4feature(pa=pa, xset=xset, ppm=opt$ppm, plim=opt$plim,
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
131 intense=opt$mostIntense, convert2RawRT=convert2RawRT,
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
132 db_name='alldata.sqlite', out_dir=opt$out_dir, grp_peaklist=grp_peaklist,
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
133 create_db=createDB)
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
134
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
135 save(pa, file=file.path(opt$out_dir, 'frag4feature.RData'))
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
136
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
137 print(head(pa@grped_df))
cb8dce9812ff planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f79fa34772bbab836d89cf8bad52d49285409a98
tomnl
parents:
diff changeset
138 write.table(pa@grped_df, file.path(opt$out_dir, 'frag4feature.tsv'), row.names=FALSE, sep='\t')