-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreprocess.r
46 lines (39 loc) · 1.57 KB
/
preprocess.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
###############################################################################
##
## MALDI-TOF Translator from Bruker to mzML
##
## Alejandro Guerrero-López
##
###############################################################################
args <- commandArgs(trailingOnly = TRUE)
###############################################################################
## Load libraries
## MALDIquant()
## MALDIquantForeign()
##
#install.packages(c("MALDIquant","MALDIquantForeign"))
###############################################################################
library("MALDIquant")
library("MALDIquantForeign")
###############################################################################
## Load data
###############################################################################
path <- "data/maldi_pure"
spectra1 <- importBrukerFlex(path)
##### PREPROCESS FOLLOWING PAPER INSTRUCTIONS:
spectra <- smoothIntensity(spectra, method="SavitzkyGolay", halfWindowSize=5)
spectra <- removeBaseline(spectra, method="TopHat")
spectra <- calibrateIntensity(spectra, method="TIC")
peaks <- detectPeaks(spectra, method="MAD", halfWindowSize=20, SNR=2)
peaks <- binPeaks(peaks, tolerance=0.004)
peaks <- filterPeaks(peaks, minFrequency=0.9)
###############################################################################
## Save data
###############################################################################
path_save <- paste0(path, '/mzml/')
# path_save <- paste0(path, args[2])
## Save Rdata object
save(spectra1, file='mzml')
# save(spectra1, file=args[2])
## Export
exportMzMl(spectra1, path=path_save)