### load data
data(toyspectrum)
data(toyspectrumsolution)
mz <- toyspectrum[,"x"]
intensities <- toyspectrum[,"yyy"]
### select mz range
filter <- mz >= 2800 & mz <= 3200
### Extract peak patterns with model = "Gaussian"
sigmafun <- function (mz) -8.5e-07 * mz + 6.09e-10 * mz^2 + 0.00076
gausslist <- getPeaklist(mz = mz[filter], intensities = intensities[filter],
model = "Gaussian",
model.parameters = list(sigma = sigmafun,
alpha = function(mz){},
mu = function(mz){}),
control.localnoise = list(quantile = 0.5, factor.place = 3))
show(gausslist)
### threshold list at signal-to-noise ratio = 2
peaklist <- threshold(gausslist, threshold = 2)
### Extract peak patterns with model = "EMG" and loss = "L1"
alpha0 <- function(mz) 0.00001875 * 0.5 * 4/3 * mz
sigma0 <- function(mz) 0.00001875 * 0.5 * mz
mu0 <- function(mz) return(rep(-0.06162891, length(mz)))
EMGlist <- getPeaklist(mz = mz[filter], intensities = intensities[filter],
model = "EMG", loss = "L1",
model.parameters = list(sigma = sigma0,
alpha = alpha0,
mu = mu0),
control.localnoise = list(quantile = 0.5, factor.place = 3))
show(EMGlist)
peaklist2 <- threshold(EMGlist, threshold = 2)
### plot results of the 1st list and compare vs. 'truth'
### 'ground truth'
solution <- toyspectrumsolution[toyspectrumsolution[,1] >= 2800 & toyspectrumsolution[,1] <= 3200,]
visualize(gausslist, mz[filter], intensities[filter], lower = 3150, upper = 3170,
truth = TRUE,
signal = TRUE,
fitted = TRUE,
postprocessed = TRUE,
booktrue = as.matrix(toyspectrumsolution),
cutoff.eps = 0.2)
Run the code above in your browser using DataLab