Closed wkumler closed 2 years ago
sorry - pushed enter too early - this is the edited/completed example:
Unfortunately there is no such functionality yet in Spectra
. We've started working on the Chromatograms package, but unfortunately we didn't find the time recently to work on it (but it's high on the TODO list...).
Maybe a slightly improved version over your code above:
## need to aggregate intensities of all peaks in a spectrum
## Simple function that takes a peaks matrix as input `x` and aggregates
## (sums) the intensities and returns a single row peaks matrix. For spectra
## with no peaks available, NA will be returned as intensity
.sum_intensities <- function(x, ...) {
if (nrow(x)) {
cbind(mz = NA_real_, intensity = sum(x[, "intensity"], na.rm = TRUE))
} else cbind(mz = NA_real_, intensity = NA_real_)
}
sfs_agg <- addProcessing(sfs_filtered, .sum_intensities)
eic <- cbind(rtime(sfs_agg), unlist(intensity(sfs_agg), use.names = FALSE))
That version will do automatically per-file parallel processing and loading data chunk-wise into memory hence keeping a low memory footprint.
I see, thank you! The new version you suggest is indeed more effective. Looking forward to the eventual release of Chromatograms!
Hi all, neat work on this package so far and congrats on the publication in Metabolites! I have a dumb question about the package - is it possible to plot an EIC for a given mass range? It seems like many of the use cases in the tutorial are MSMS focused and I'm hoping to see how the new backends compare with existing packages. I'm basically trying to replicate the code below but with
Spectra
instead ofRaMS
orMSnbase
:So far I've tried a couple different methods but none seem to extract an EIC as I'm expecting:
I'm able to hack together a chromatogram with the below code but this doesn't feel like it obeys the spirit of
Spectra
at all:Is there a better way to assemble a chromatogram for a given mass?