-
Notifications
You must be signed in to change notification settings - Fork 6
/
proprecessing_spectra.R
29 lines (26 loc) · 961 Bytes
/
proprecessing_spectra.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
library(MALDIquant)
library(MALDIquantForeign)
#' processSpectra
#'
#' @param input MALDIquant mass spectrum list
#'
#' @return MALDIquant mass spectrum list
#' @export
#'
processSpectra <- function(fileList, wd = 5, snr=3){
# Intensity transformation
spectra <- transformIntensity(input, method = "log")
# Baseline Correction
spectra <- removeBaseline(spectra, method = "SNIP", iterations=100)
# Intensity Calibration / Normalization
spectra <- calibrateIntensity(spectra, method="TIC")
# Spectra alignment
spectra <- alignSpectra(spectra, halfWindowSize = wd, allowNoMatches= TRUE, tolerance = 0.002, warpingMethod="cubic")
# Peaks detection
peaks <- detectPeaks(spectra, method = "MAD", halfWindowSize = wd, SNR = snr)
}
# Create an intensity matrix
intensity_matrix <- intensityMatrix(peaks, spectra)
# write the output file
file_sp <- file(out_filename, open="wt")
write.table(intensity_matrix, file_sp, sep=" ", row.names=FALSE)