The peak detection algorithms in
xcms perform peak detection in retention time domain, i.e. in one dimension of the 2D matrix - with a lot of assumptions on peak shape, scattering of values in one dimension etc.
I would have a look at the
yamss package instead. AFAIK,
yamss uses a two-dimensional kernel to find peaks in 2D space.
So, the author provided an answer when I posed the question on the github site. I think this may be useful to many, so I'll post it here:
It is possible to phrase your question in terms of density estimation though. I've tried to illustrate with the following toy example:
library(yamss) library(data.table) set.seed(4) num_rows <- 1000 # "m/z" num_cols <- 2000 # "scan" mat <- matrix(runif(num_rows*num_cols, 3, 5), nrow = num_rows, ncol = num_cols) # "intensities" dt <- data.table( mz = rep(seq_len(num_rows), num_cols), scan = rep(seq_len(num_cols), each = num_rows), intensity = as.numeric(mat), sample = 1 ) cms_raw <- new("CMSraw") yamss:::.mzParams(cms_raw) <- yamss:::.setMZParams(dt) yamss:::.rawDT(cms_raw) <- dt colData(cms_raw) <- DataFrame(sample = 1) cms_proc <- bakedpi(cms_raw, dbandwidth = c(1e-5, 1), dgridstep = c(1e-5, 1)) cms_slice <- slicepi(cms_proc, cutoff = NULL, verbose = TRUE)"