annotate anticipated_purity_dims.R @ 6:e5f627fd21e8 draft

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