annotate frag4feature.R @ 19:78885fff83a3 draft default tip

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