annotate anticipated_purity_lcms.R @ 22:c8b34df46dae draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
author tomnl
date Fri, 01 Jun 2018 13:41:15 -0400
parents fd6f8eecdec9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
1 library(msPurity)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
2 library(optparse)
2
b83bcc259b76 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents: 0
diff changeset
3 print(sessionInfo())
0
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
4
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
5 option_list <- list(
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
6 make_option(c("--xset_path"), type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
7 make_option(c("-o", "--out_dir"), type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
8 make_option(c("--mzML_path"), type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
9 make_option("--minOffset", default=0.5),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
10 make_option("--maxOffset", default=0.5),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
11 make_option("--ilim", default=0.05),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
12 make_option("--iwNorm", default="none", type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
13 make_option("--exclude_isotopes", action="store_true"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
14 make_option("--isotope_matrix", type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
15 make_option("--purityType", default="purityFWHMmedian"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
16 make_option("--singleFile", default=0),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
17 make_option("--cores", default=4),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
18 make_option("--xgroups", type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
19 make_option("--rdata_name", default='xset'),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
20 make_option("--camera_xcms", default='xset'),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
21 make_option("--files", type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
22 make_option("--galaxy_files", type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
23 make_option("--choose_class", type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
24 make_option("--ignore_files", type="character"),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
25 make_option("--rtraw_columns", action="store_true")
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
26 )
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
27
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
28 # store options
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
29 opt<- parse_args(OptionParser(option_list=option_list))
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
30
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
31 print(sessionInfo())
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
32 print(opt)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
33
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
34 if (!is.null(opt$xgroups)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
35 xgroups = as.numeric(strsplit(opt$xgroups, ',')[[1]])
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
36 }else{
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
37 xgroups = NULL
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
38 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
39
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
40
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
41
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
42 print(xgroups)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
43
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
44 if (!is.null(opt$remove_nas)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
45 df <- df[!is.na(df$mz),]
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
46 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
47
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
48 if (is.null(opt$isotope_matrix)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
49 im <- NULL
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
50 }else{
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
51 im <- read.table(opt$isotope_matrix,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
52 header = TRUE, sep='\t', stringsAsFactors = FALSE)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
53 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
54
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
55 if (is.null(opt$exclude_isotopes)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
56 isotopes <- FALSE
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
57 }else{
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
58 isotopes <- TRUE
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
59 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
60
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
61 if (is.null(opt$rtraw_columns)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
62 rtraw_columns <- FALSE
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
63 }else{
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
64 rtraw_columns <- TRUE
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
65 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
66
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
67 loadRData <- function(rdata_path, xset_name){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
68 #loads an RData file, and returns the named xset object if it is there
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
69 load(rdata_path)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
70 print(ls())
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
71 return(get(ls()[ls() == xset_name]))
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
72 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
73
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
74 target_obj <- loadRData(opt$xset_path, opt$rdata_name)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
75
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
76 if (opt$camera_xcms=='camera'){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
77 xset <- target_obj@xcmsSet
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
78 }else{
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
79 xset <- target_obj
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
80 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
81
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
82 print(xset)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
83
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
84 minOffset = as.numeric(opt$minOffset)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
85 maxOffset = as.numeric(opt$maxOffset)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
86
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
87
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
88 if (opt$iwNorm=='none'){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
89 iwNorm = FALSE
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
90 iwNormFun = NULL
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
91 }else if (opt$iwNorm=='gauss'){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
92 iwNorm = TRUE
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
93 iwNormFun = msPurity::iwNormGauss(minOff=-minOffset, maxOff=maxOffset)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
94 }else if (opt$iwNorm=='rcosine'){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
95 iwNorm = TRUE
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
96 iwNormFun = msPurity::iwNormRcosine(minOff=-minOffset, maxOff=maxOffset)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
97 }else if (opt$iwNorm=='QE5'){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
98 iwNorm = TRUE
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
99 iwNormFun = msPurity::iwNormQE.5()
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
100 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
101
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
102 print(xset@filepaths)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
103
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
104
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
105
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
106 if (!is.null(opt$files)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
107 updated_filepaths <- trimws(strsplit(opt$files, ',')[[1]])
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
108 updated_filepaths <- updated_filepaths[updated_filepaths != ""]
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
109 print(updated_filepaths)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
110 updated_filenames = basename(updated_filepaths)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
111 original_filenames = basename(xset@filepaths)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
112 update_idx = match(updated_filenames, original_filenames)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
113
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
114 if (!is.null(opt$galaxy_files)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
115 galaxy_files <- trimws(strsplit(opt$galaxy_files, ',')[[1]])
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
116 galaxy_files <- galaxy_files[galaxy_files != ""]
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
117 xset@filepaths <- galaxy_files[update_idx]
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
118 }else{
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
119 xset@filepaths <- updated_filepaths[update_idx]
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
120 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
121 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
122
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
123 if (!is.null(opt$choose_class)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
124 classes <- trimws(strsplit(opt$choose_class, ',')[[1]])
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
125
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
126
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
127 ignore_files_class <- which(!as.character(xset@phenoData$class) %in% classes)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
128
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
129 print('choose class')
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
130 print(ignore_files_class)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
131 }else{
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
132 ignore_files_class <- NA
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
133 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
134
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
135 if (!is.null(opt$ignore_files)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
136 ignore_files_string <- trimws(strsplit(opt$ignore_files, ',')[[1]])
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
137 filenames <- rownames(xset@phenoData)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
138 ignore_files <- which(filenames %in% ignore_files_string)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
139
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
140 ignore_files <- unique(c(ignore_files, ignore_files_class))
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
141 ignore_files <- ignore_files[ignore_files != ""]
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
142 }else{
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
143 if (anyNA(ignore_files_class)){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
144 ignore_files <- NULL
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
145 }else{
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
146 ignore_files <- ignore_files_class
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
147 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
148
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
149 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
150
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
151 print('ignore_files')
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
152 print(ignore_files)
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
153
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
154
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
155 ppLCMS <- msPurity::purityX(xset=xset,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
156 offsets=c(minOffset, maxOffset),
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
157 cores=opt$cores,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
158 xgroups=xgroups,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
159 purityType=opt$purityType,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
160 ilim = opt$ilim,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
161 isotopes = isotopes,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
162 im = im,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
163 iwNorm = iwNorm,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
164 iwNormFun = iwNormFun,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
165 singleFile = opt$singleFile,
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
166 fileignore = ignore_files,
5
fd6f8eecdec9 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 9ea2ca0892fa55c21491c93afba790e8d9427e01-dirty
tomnl
parents: 2
diff changeset
167 rtrawColumns=rtraw_columns)
0
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
168
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
169
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
170 dfp <- ppLCMS@predictions
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
171
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
172 # to make compatable with deconrank
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
173 colnames(dfp)[colnames(dfp)=='grpid'] = 'peakID'
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
174 colnames(dfp)[colnames(dfp)=='median'] = 'medianPurity'
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
175 colnames(dfp)[colnames(dfp)=='mean'] = 'meanPurity'
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
176 colnames(dfp)[colnames(dfp)=='sd'] = 'sdPurity'
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
177 colnames(dfp)[colnames(dfp)=='stde'] = 'sdePurity'
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
178 colnames(dfp)[colnames(dfp)=='RSD'] = 'cvPurity'
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
179 colnames(dfp)[colnames(dfp)=='pknm'] = 'pknmPurity'
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
180 if(sum(is.na(dfp$medianPurity))>0){
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
181 dfp[is.na(dfp$medianPurity),]$medianPurity = 0
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
182 }
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
183
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
184 print('saving tsv')
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
185 print(head(dfp))
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
186 write.table(dfp, file.path(opt$out_dir, 'anticipated_purity_lcms.tsv'), row.names=FALSE, sep='\t')
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
187 print('saving RData')
dc00b7222a3c planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f9591483bef88aef71a9f0cc0ffc75cf6eab480c
tomnl
parents:
diff changeset
188 save.image(file.path(opt$out_dir, 'anticipated_purity_lcms.RData'))