annotate dimsPredictPuritySingle.R @ 0:ca0ac330f1a4 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
author tomnl
date Fri, 24 May 2019 09:13:42 -0400
parents
children b71677d4f958
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
1 library(msPurity)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
2 library(optparse)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
3 print(sessionInfo())
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
4
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
5 option_list <- list(
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
6 make_option(c("--mzML_file"), type="character"),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
7 make_option(c("--peaks_file"), type="character"),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
8 make_option(c("-o", "--out_dir"), type="character"),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
9 make_option("--minOffset", default=0.5),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
10 make_option("--maxOffset", default=0.5),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
11 make_option("--ilim", default=0.05),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
12 make_option("--ppm", default=4),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
13 make_option("--dimspy", action="store_true"),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
14 make_option("--sim", action="store_true"),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
15 make_option("--remove_nas", action="store_true"),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
16 make_option("--iwNorm", default="none", type="character"),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
17 make_option("--file_num_dimspy", default=1),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
18 make_option("--exclude_isotopes", action="store_true"),
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
19 make_option("--isotope_matrix", type="character")
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
20 )
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
21
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
22 # store options
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
23 opt<- parse_args(OptionParser(option_list=option_list))
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
24
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
25 print(sessionInfo())
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
26 print(opt)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
27
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
28 if (is.null(opt$dimspy)){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
29
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
30 df <- read.table(opt$peaks_file, header = TRUE, sep='\t')
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
31 filename = NA
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
32 mzml_file <- opt$mzML_file
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
33 }else{
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
34 indf <- read.table(opt$peaks_file,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
35 header = TRUE, sep='\t', stringsAsFactors = FALSE)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
36
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
37
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
38 if (file.exists(opt$mzML_file)){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
39 mzml_file <- opt$mzML_file
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
40 }else{
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
41
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
42 filename = colnames(indf)[8:ncol(indf)][opt$file_num_dimspy]
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
43 print(filename)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
44 # check if the data file is mzML or RAW (can only use mzML currently) so
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
45 # we expect an mzML file of the same name in the same folder
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
46 indf$i <- indf[,colnames(indf)==filename]
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
47 indf[,colnames(indf)==filename] <- as.numeric(indf[,colnames(indf)==filename])
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
48
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
49 filename = sub("raw", "mzML", filename, ignore.case = TRUE)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
50 print(filename)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
51
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
52 mzml_file <- file.path(opt$mzML_file, filename)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
53
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
54 }
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
55
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
56 df <- indf[4:nrow(indf),]
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
57 if ('blank_flag' %in% colnames(df)){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
58 df <- df[df$blank_flag==1,]
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
59 }
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
60 colnames(df)[colnames(df)=='m.z'] <- 'mz'
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
61
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
62 if ('nan' %in% df$mz){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
63 df[df$mz=='nan',]$mz <- NA
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
64 }
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
65 df$mz <- as.numeric(df$mz)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
66
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
67
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
68
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
69
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
70 }
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
71
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
72 if (!is.null(opt$remove_nas)){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
73 df <- df[!is.na(df$mz),]
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
74 }
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
75
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
76 if (is.null(opt$isotope_matrix)){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
77 im <- NULL
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
78 }else{
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
79 im <- read.table(opt$isotope_matrix,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
80 header = TRUE, sep='\t', stringsAsFactors = FALSE)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
81 }
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
82
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
83 if (is.null(opt$exclude_isotopes)){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
84 isotopes <- FALSE
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
85 }else{
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
86 isotopes <- TRUE
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
87 }
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
88
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
89
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
90
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
91 if (is.null(opt$sim)){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
92 sim=FALSE
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
93 }else{
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
94 sim=TRUE
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
95 }
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
96
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
97 minOffset = as.numeric(opt$minOffset)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
98 maxOffset = as.numeric(opt$maxOffset)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
99
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
100
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
101
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
102 if (opt$iwNorm=='none'){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
103 iwNorm = FALSE
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
104 iwNormFun = NULL
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
105 }else if (opt$iwNorm=='gauss'){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
106 iwNorm = TRUE
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
107 iwNormFun = msPurity::iwNormGauss(minOff=-minOffset, maxOff=maxOffset)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
108 }else if (opt$iwNorm=='rcosine'){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
109 iwNorm = TRUE
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
110 iwNormFun = msPurity::iwNormRcosine(minOff=-minOffset, maxOff=maxOffset)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
111 }else if (opt$iwNorm=='QE5'){
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
112 iwNorm = TRUE
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
113 iwNormFun = msPurity::iwNormQE.5()
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
114 }
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
115
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
116 print('FIRST ROWS OF PEAK FILE')
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
117 print(head(df))
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
118 print(mzml_file)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
119 predicted <- msPurity::dimsPredictPuritySingle(df$mz,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
120 filepth=mzml_file,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
121 minOffset=minOffset,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
122 maxOffset=maxOffset,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
123 ppm=opt$ppm,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
124 mzML=TRUE,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
125 sim = sim,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
126 ilim = opt$ilim,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
127 isotopes = isotopes,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
128 im = im,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
129 iwNorm = iwNorm,
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
130 iwNormFun = iwNormFun
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
131 )
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
132 predicted <- cbind(df, predicted)
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
133
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
134 print(head(predicted))
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
135 print(file.path(opt$out_dir, 'dimsPredictPuritySingle_output.tsv'))
ca0ac330f1a4 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
tomnl
parents:
diff changeset
136 write.table(predicted, file.path(opt$out_dir, 'dimsPredictPuritySingle_output.tsv'), row.names=FALSE, sep='\t')