annotate frag4feature.R @ 8:e98ae5c1f4e7 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
author computational-metabolomics
date Wed, 12 Jun 2024 16:01:28 +0000
parents 52d48bcd3608
children ac284b969836
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
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
6 xset_pa_filename_fix <- function(opt, pa, xset = NULL) {
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
7 if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)) {
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
8 # NOTE: Relies on the pa@fileList having the names of files given as 'names' of the variables
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
9 # needs to be done due to Galaxy moving the files around and screwing up any links to files
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
10
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
11 filepaths <- trimws(strsplit(opt$mzML_files, ",")[[1]]) # nolint
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
12
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
13 filepaths <- filepaths[filepaths != ""]
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
14
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
15 galaxy_names <- trimws(strsplit(opt$galaxy_names, ",")[[1]])
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
16 galaxy_names <- galaxy_names[galaxy_names != ""]
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
17
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
18 nsave <- names(pa@fileList)
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
19 old_filenames <- basename(pa@fileList)
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
20
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
21 pa@fileList <- filepaths[match(names(pa@fileList), galaxy_names)]
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
22 names(pa@fileList) <- nsave
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
23
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
24 pa@puritydf$filename <- basename(pa@fileList[match(pa@puritydf$filename, old_filenames)])
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
25 pa@grped_df$filename <- basename(pa@fileList[match(pa@grped_df$filename, old_filenames)])
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
26 }
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
27 print(pa@fileList)
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
28
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
29 if (!is.null(xset)) {
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
30 print(xset@filepaths)
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
31
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
32 if (!all(basename(pa@fileList) == basename(xset@filepaths))) {
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
33 if (!all(names(pa@fileList) == basename(xset@filepaths))) {
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
34 print("FILELISTS DO NOT MATCH")
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
35 message("FILELISTS DO NOT MATCH")
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
36 quit(status = 1)
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
37 } else {
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
38 xset@filepaths <- unname(pa@fileList)
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
39 }
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
40 }
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
41 }
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
42
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
43 return(list(pa, xset))
0
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
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
47 option_list <- list(
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
48 make_option(c("-o", "--out_dir"), type = "character"),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
49 make_option("--pa", type = "character"),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
50 make_option("--xset", type = "character"),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
51 make_option("--ppm", default = 10),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
52 make_option("--plim", default = 0.0),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
53 make_option("--convert2RawRT", action = "store_true"),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
54 make_option("--intense", action = "store_true"),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
55 make_option("--createDB", action = "store_true"),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
56 make_option("--cores", default = 4),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
57 make_option("--mzML_files", type = "character"),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
58 make_option("--galaxy_names", type = "character"),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
59 make_option("--grp_peaklist", type = "character"),
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
60 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
61 )
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
62
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
63 # store options
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
64 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
65 print(opt)
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
66
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
67 loadRData <- function(rdata_path, name) {
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
68 # loads an RData file, and returns the named xset object if it is there
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
69 load(rdata_path)
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
70 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
71 }
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
72
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
73 # This function retrieve a xset like object
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
74 # @author Gildas Le Corguille lecorguille@sb-roscoff.fr
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
75 getxcmsSetObject <- function(xobject) {
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
76 # XCMS 1.x
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
77 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
78 return(xobject)
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
79 }
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
80 # XCMS 3.x
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
81 if (class(xobject) == "XCMSnExp") {
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
82 # 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
83 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
84 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
85 return(xset)
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
86 }
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
87 }
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 # Requires
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
90 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
91 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
92 xset <- getxcmsSetObject(xset)
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
93
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
94 pa@cores <- opt$cores
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 print(pa@fileList)
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
97 print(xset@filepaths)
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
98
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
99 if (is.null(opt$intense)) {
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
100 intense <- FALSE
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
101 } else {
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
102 intense <- TRUE
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
103 }
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
104
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
105 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
106 convert2RawRT <- FALSE
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
107 } else {
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
108 convert2RawRT <- TRUE
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
109 }
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
110
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
111 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
112 createDB <- FALSE
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
113 } else {
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
114 createDB <- TRUE
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
115 }
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
116
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
117 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
118 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
119 pa <- fix[[1]]
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
120 xset <- fix[[2]]
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
121 useGroup <- FALSE
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
122 } else {
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
123 # 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
124 print("useGroup")
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
125 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
126 pa <- fix[[1]]
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
127 useGroup <- TRUE
0
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
128 }
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
129
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
130
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
131 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
132 grp_peaklist <- NA
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
133 } else {
6
52d48bcd3608 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
computational-metabolomics
parents: 0
diff changeset
134 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
135 }
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
136 print(useGroup)
50eedf5ad217 "planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit cb903cd93f9378cfb5eeb68512a54178dcea7bbc-dirty"
computational-metabolomics
parents:
diff changeset
137
8
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
138 pa <- msPurity::frag4feature(
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
139 pa = pa,
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
140 xset = xset,
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
141 ppm = opt$ppm,
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
142 plim = opt$plim,
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
143 intense = intense,
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
144 convert2RawRT = convert2RawRT,
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
145 db_name = "alldata.sqlite",
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
146 out_dir = opt$out_dir,
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
147 grp_peaklist = grp_peaklist,
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
148 create_db = createDB,
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
149 use_group = useGroup
e98ae5c1f4e7 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
computational-metabolomics
parents: 6
diff changeset
150 )
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")