Mercurial > repos > tomnl > deconrank
comparison lcms-interval-scheduling.R @ 1:defa57c7775e draft
planemo upload for repository https://github.com/computational-metabolomics/dma-tools-galaxy commit 6c48bd51987a28401de6cf5e49b1b30e5e73fe16-dirty
author | tomnl |
---|---|
date | Tue, 27 Mar 2018 07:18:42 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:d2940fcb7104 | 1:defa57c7775e |
---|---|
1 library(XCMSwrapper) | |
2 library(optparse) | |
3 | |
4 option_list <- list( | |
5 | |
6 make_option(c("-s", "--sample_peaklist"), type="character"), | |
7 make_option(c("-b", "--blank_peaklist"), type="character"), | |
8 make_option(c("-t", "--topn"), type="character"), | |
9 make_option(c("-o", "--out_dir"), type="character", default=getwd(), | |
10 help="Output folder for resulting files [default = %default]" | |
11 ), | |
12 make_option("--method", type="character"), | |
13 make_option("--maxms2", type="numeric"), | |
14 make_option("--widthFactor", type="numeric"), | |
15 make_option("--minWidth", type="numeric"), | |
16 make_option("--ilimit", type="numeric"), | |
17 make_option("--shift", type="numeric"), | |
18 make_option("--samplelistNm", type="numeric"), | |
19 make_option("--overlappingP", type="numeric"), | |
20 make_option("--fullpw", action="store_true"), | |
21 make_option("--b_widthFactor", type="numeric"), | |
22 make_option("--b_shift", type="numeric"), | |
23 make_option("--b_exclu_limit", type="numeric"), | |
24 make_option("--b_minWidth", type="numeric"), | |
25 make_option("--polarity", type="character"), | |
26 make_option("--fillgaps", type="character"), | |
27 make_option("--dmaNearline", action="store_true"), | |
28 make_option("--blankClass", type="character"), | |
29 make_option("--intensityCN", type="character"), | |
30 make_option("--sortCN", type="character"), | |
31 make_option("--filterS", type="character") | |
32 ) | |
33 | |
34 # store options | |
35 opt<- parse_args(OptionParser(option_list=option_list)) | |
36 | |
37 print(sessionInfo()) | |
38 print(opt) | |
39 | |
40 if(is.null(opt$fullpw)){ | |
41 fullpw = FALSE | |
42 }else{ | |
43 fullpw = TRUE | |
44 } | |
45 | |
46 if(is.null(opt$fillgaps)){ | |
47 fillgaps = FALSE | |
48 }else{ | |
49 fillgaps = TRUE | |
50 } | |
51 | |
52 | |
53 # Nearline processing | |
54 # nearline parameters (sample and blank) | |
55 params <- list( | |
56 nl.method = opt$method, | |
57 nl.maxms2 = opt$maxms2, # only used for simple nearline | |
58 nl.widthFactor = opt$widthFactor, | |
59 nl.minWidth = opt$minWidth, # 5 seconds | |
60 nl.ilimit = opt$ilimit, # only used for simple nearline | |
61 nl.shift = opt$shift, | |
62 nl.samplelist_nm = opt$samplelistNm, | |
63 nl.overlappingP = opt$overlappingP, | |
64 nl.fullpw = fullpw, | |
65 nl.fillgaps = fillgaps, # only used for metshot nearline | |
66 #nearline blank parameters | |
67 nl.b_widthFactor = opt$b_widthFactor, # increase the width | |
68 nl.b_minWidth = opt$b_minWidth, | |
69 nl.b.shift = opt$b_shift, | |
70 nl.exclu_limit = opt$b_exclu_limit, | |
71 temp_dir='.', | |
72 intensityCN=opt$intensityCN, | |
73 sortCN=opt$sortCN # column of the sample peaklist to use for | |
74 | |
75 ) | |
76 | |
77 | |
78 | |
79 # ################################## | |
80 # # Perform Nearline optimisation | |
81 # ################################## | |
82 s_peaklist <- read.table(opt$sample_peaklist, header = TRUE, sep='\t', stringsAsFactors = FALSE) | |
83 b_peaklist <- read.table(opt$blank_peaklist, header = TRUE, sep='\t', stringsAsFactors = FALSE) | |
84 | |
85 if(!is.null(opt$dmaNearline)){ | |
86 # have to do some additional filtering if part of the dma nearline workflow | |
87 blank_class_name <- gsub('-', '.', opt$blankClass) | |
88 b_peaklist = b_peaklist[which(b_peaklist[,paste(blank_class_name, '_valid', sep='')]==1),] | |
89 s_peaklist = s_peaklist[s_peaklist[,opt$filterS]==0,] | |
90 } | |
91 | |
92 | |
93 | |
94 topn <- read.table(opt$topn, header = TRUE, sep='\t', stringsAsFactors = FALSE, check.names=FALSE) | |
95 topn[is.na(topn)] <- "" | |
96 # colnames(topn) <- c('Mass [m/z]', 'Formula [M]', 'Formula type', 'Species', 'CS [z]', 'Polarity', 'Start [min]', 'End [min]','Comment') | |
97 # colnames(topn) <- gsub('\\.', ' ', colnames(topn)) | |
98 print(head(topn)) | |
99 | |
100 # #Generate inclusions lists for DDA-MS/MS and store in list | |
101 incl.lists = nearline_main(pm = params, peaklist_xcms=s_peaklist, pol=opt$polarity, merge_peaklists=FALSE, peaklist_post=NA) | |
102 | |
103 # #Generate exclusion lists for each class being analysed | |
104 nearline_main_blank(pm = params, | |
105 plist = b_peaklist, | |
106 incl_list_pos = incl.lists, | |
107 pol = opt$polarity, | |
108 topn = topn) | |
109 # |