annotate flag-remove-peaks.R @ 0:aa55ff1d76d4 draft

planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
author tomnl
date Thu, 10 May 2018 07:20:04 -0400
parents
children 89f33758ad22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
1 library(XCMSwrapper)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
2 library(optparse)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
3
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
4 option_list <- list(
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
5 make_option(c("-o", "--out_dir"), type="character", default=getwd(),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
6 help="Output folder for resulting files [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
7 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
8 make_option(c("-x", "--xset_path"), type="character", default=file.path(getwd(),"xset.rds"),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
9 help="The path to the xcmsSet object [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
10 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
11 make_option("--polarity", default='NA',
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
12 help="polarity (just used for naming purpose for files being saved) [positive, negative, NA] [default %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
13 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
14 make_option("--rsd_i_blank", default=NA,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
15 help="RSD threshold for the blank [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
16 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
17 make_option("--minfrac_blank", default=0.5,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
18 help="minimum fraction of files for features needed for the blank [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
19 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
20 make_option("--rsd_rt_blank", default=NA,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
21 help="RSD threshold for the RT of the blank [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
22 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
23
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
24 make_option("--ithres_blank", default=NA,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
25 help="Intensity threshold for the blank [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
26 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
27 make_option("--s2b", default=10,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
28 help="fold change (sample/blank) needed for sample peak to be allowed. e.g.
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
29 if s2b set to 10 and the recorded sample 'intensity' value was 100 and blank was 10.
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
30 1000/10 = 100, so sample has fold change higher than the threshold and the peak
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
31 is not considered a blank [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
32 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
33 make_option("--blank_class", default='blank', type="character",
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
34 help="A string representing the class that will be used for the blank.[default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
35 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
36 make_option("--egauss_thr", default=NA,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
37 help="Threshold for filtering out non gaussian shaped peaks. Note this only works
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
38 if the 'verbose columns' and 'fit gauss' was used with xcms
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
39 [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
40 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
41 make_option("--rsd_i_sample", default=NA,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
42 help="RSD threshold for the samples [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
43 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
44 make_option("--minfrac_sample", default=0.8,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
45 help="minimum fraction of files for features needed for the samples [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
46 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
47 make_option("--rsd_rt_sample", default=NA,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
48 help="RSD threshold for the RT of the samples [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
49 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
50 make_option("--ithres_sample", default=5000,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
51 help="Intensity threshold for the sample [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
52 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
53 make_option("--grp_rm_ids", default=NA,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
54 help="vector of grouped_xcms peaks to remove (corresponds to the row from xcms::group output)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
55 [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
56 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
57 make_option("--remove_spectra", action="store_true",
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
58 help=" TRUE if flagged spectra is to be removed [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
59 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
60 make_option("--minfrac_xcms", default=0.5,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
61 help="minfrac for xcms grouping [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
62 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
63 make_option("--mzwid", default=0.001,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
64 help="mzwid for xcms grouping [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
65 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
66 make_option("--bw", default=5,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
67 help="bw for xcms grouping [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
68 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
69
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
70 make_option("--temp_save", action="store_true",
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
71 help="Assign True if files for each step saved (for testing purposes) [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
72 ),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
73
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
74 make_option("--samplelist", type="character", help="Sample list to determine the blank class"),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
75
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
76 make_option("--xset_name", default="xset",
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
77 help="Name of the xcmsSet object within the RData file [default = %default]"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
78 )
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
79
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
80
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
81
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
82 )
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
83
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
84 #make_option("--multilist", action="store_true"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
85 # help="NOT CURRENTLY IMPLEMENTED: If paired blank removal is to be performed a - multilist - sample list file has to be provided"
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
86 #),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
87
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
88 # store options
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
89 opt<- parse_args(OptionParser(option_list=option_list))
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
90
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
91 if (is.null(opt$temp_save)){
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
92 temp_save<-FALSE
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
93 }else{
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
94 temp_save<-TRUE
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
95 }
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
96
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
97 if (is.null(opt$remove_spectra)){
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
98 remove_spectra<-FALSE
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
99 }else{
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
100 remove_spectra<-TRUE
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
101 }
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
102
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
103
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
104 print(opt)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
105
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
106 loadRData <- function(rdata_path, xset_name){
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
107 #loads an RData file, and returns the named xset object if it is there
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
108 load(rdata_path)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
109 return(get(ls()[ls() == xset_name]))
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
110 }
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
111
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
112 xset<-loadRData(opt$xset_path, opt$xset_name)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
113 print(xset)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
114 if (is.null(opt$samplelist)){
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
115 blank_class <- opt$blank_class
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
116 }else{
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
117 samplelist <- read.table(opt$samplelist, sep='\t', header=TRUE)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
118 samplelist_blank <- unique(samplelist$sample_class[samplelist$blank=='yes'])
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
119
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
120 chosen_blank <- samplelist_blank[samplelist_blank %in% xset@phenoData$class]
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
121 if (length(chosen_blank)>1){
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
122 print('ERROR: only 1 blank is currently allowed to be used with this tool')
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
123 exit()
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
124 }
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
125 blank_class <- as.character(chosen_blank)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
126 print(blank_class)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
127 }
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
128
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
129
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
130 if (is.null(opt$multilist)){
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
131 ffrm_out <- XCMSwrapper::flag_remove(xset,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
132 pol=opt$polarity,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
133 rsd_i_blank=opt$rsd_i_blank,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
134 minfrac_blank=opt$minfrac_blank,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
135 rsd_rt_blank=opt$rsd_rt_blank,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
136 ithres_blank=opt$ithres_blank,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
137 s2b=opt$s2b,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
138 ref.class=blank_class,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
139 egauss_thr=opt$egauss_thr,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
140 rsd_i_sample=opt$rsd_i_sample,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
141 minfrac_sample=opt$minfrac_sample,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
142 rsd_rt_sample=opt$rsd_rt_sample,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
143 ithres_sample=opt$ithres_sample,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
144 minfrac_xcms=opt$minfrac_xcms,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
145 mzwid=opt$mzwid,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
146 bw=opt$bw,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
147 out_dir=opt$out_dir,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
148 temp_save=temp_save,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
149 remove_spectra=remove_spectra,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
150 grp_rm_ids=unlist(strsplit(as.character(opt$grp_rm_ids), split=", "))[[1]])
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
151
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
152 xset <- ffrm_out[[1]]
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
153 grp_peaklist <- ffrm_out[[2]]
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
154 removed_peaks <- ffrm_out[[3]]
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
155
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
156 save.image(file=file.path(opt$out_dir, 'xset_filtered.RData'))
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
157
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
158 # grpid needed for mspurity ID needed for deconrank... (will clean up at some up)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
159 write.table(data.frame('grpid'=rownames(grp_peaklist), 'ID'=rownames(grp_peaklist), grp_peaklist),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
160 file.path(opt$out_dir, 'peaklist_filtered.txt'), row.names=FALSE, sep='\t')
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
161
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
162 removed_peaks <- data.frame(removed_peaks)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
163 write.table(data.frame('ID'=rownames(removed_peaks),removed_peaks),
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
164 file.path(opt$out_dir, 'removed_peaks.txt'), row.names=FALSE, sep='\t')
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
165
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
166 }else{
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
167
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
168
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
169 # TODO
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
170 #xsets <- split(xset, multilist_df$multlist)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
171 #
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
172 #mult_grps <- unique(multilist_df$multlist)
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
173 #
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
174 #for (mgrp in mult_grps){
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
175 # xset_i <- xsets[mgrp]
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
176 # xcms::group(xset_i,
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
177 #
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
178 # }
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
179
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
180
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
181
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
182 }
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
183
aa55ff1d76d4 planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit dcfc95273101a7ef0405c2efb8d83f5d456ccd15
tomnl
parents:
diff changeset
184