-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscr_metabolic_data_processing.R
65 lines (48 loc) · 1.7 KB
/
scr_metabolic_data_processing.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# The script shows the metabolomic data processing for "red ripe" samples in a negative ionization mode.
# Repeat the processing for the positive ionization mode accordingly
# 0. Install packages ----
library(xcms)
library(CAMERA)
library(BiocParallel)
bpparam <- MulticoreParam(4)
# 1. Perform peak picking in batches ----
ionization = "negative" #
PL_PATH = "."
cdfFiles = list.files("netCDF_red_stage",full.names=T,pattern="*0[1|2].CDF")
strata = findInterval(1:length(cdfFiles), seq(1,length(cdfFiles), by = 100))
stop()
for (i in 1:max(strata)) {
cdfFiles.i = cdfFiles[strata==i]
xs.i = xcmsSet(cdfFiles.i,snthresh=5,fwhm=10,mzdiff=0.05,max=200,BPPARAM=bpparam)
save(xs.i,file=file.path(PL_PATH,paste("xs",i,sep="")))
}
load(file.path(PL_PATH,paste("xs",1,sep="")))
xs = xs.i
rm(xs.i)
for(i in unique(strata)){
if(i != 1){
print(i)
load(file.path(PL_PATH,paste("xs",i,sep="")))
xs = c(xs, xs.i)
rm(xs.i)
}
}
# 2. Group peaks ----
xsg = group(xs, bw=25, mzwid = 0.05, minsamp = 4, max = 200)
# 3. Perform retention time correction ----
xs_corr = retcor(xsg,smooth="loess",plottype="mdevden",span=0.75,missing=120,extra=20)
# 4. Group corrected peaks ----
xs_corrg = group(xs_corr, bw=20, mzwid = 0.05, minsamp= 4, max = 200)
# 5. Fill peaks ----
p <- SerialParam()
xs_corrg_fill = fillPeaks(xs_corrg,BPPARAM=p)
# 6. Annotate peaks with CAMERA ----
xan = annotate(xs_corrg_fill, polarity=ionization,ppm=20,multiplier=2,quick=TRUE)
PL = getPeaklist(xan)
time.RetGroup <- system.time({ # measuring time
resultRetcorGroup <-
optimizeRetGroup(xset = xs,
params = retcorGroupParameters,
nSlaves = 8,
subdir = "retCorGrpOpt")
})