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