annotate frag4feature.R @ 6:52d48bcd3608 draft

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