Closed WallFacerLR closed 1 month ago
Good point @WallFacerLR . What I would suggest instead (of changing the combinePeaksData()
function) is to run reduceSpectra()
before aggregating the spectra with combineSpectra()
(which will then use the combinePeaksData()
function). The reduceSpectra()
function will do exactly what you suggest: it will group peaks within each spectrum and then report only the mass peak with the highest intensity for each group. You could then either extract the list of peaks data using peaksData()
from the Spectra
object and run the combinePeaksData()
manually, or simply call combineSpectra()
on the Spectra
object. So, summarizing, the workflow you suggest could be:
sps |>
reduceSpectra(tolerance = 0, ppm = 10) |>
combineSpectra(tolerance = 0, ppm = 10)
you would obviously need to check that the default for parameter f
in combineSpectra()
is the same as the sets of spectra you would like to combine - or otherwise provide the sets of spectra you want to combine with parameter f
.
Thanks for reminding me this function. It's actually a complete job.
Maybe this should be noticed in doc of combineSpectra
or combinePeaksData
, causing it's necessary for aggregating multiple spectra. And as user, when I read the documentation of these function and vignette of section 3.6 Aggregating spectra data
, I‘m not aware of this problem and above solution.
Yes, good point! I will update the documentation accordingly!
Updated the documentation of the current (release) version. Closing issue now - feel free to re-open if needed.
In the description of
combinePeaksData
: combinePeaksData aggregates provided peak matrices into a single peak matrix. Peaks are grouped by their m/z values with the group() function from the MsCoreUtils package. In brief, all peaks in all provided spectra are first ordered by their m/z and consecutively grouped into one group if the (pairwise) difference between them is smaller than specified with parameter tolerance and ppm.In many cases, there are lower magnitude noise around a signal peak within the allowable ppm range. Aggregation functions
intensityFun
take noise and signal from different spectra equally. But actually we hope just signal from different spectra be aggregated.There is one case of intermediate data of one mz-group in
combinePeaksData
, ppm = 10.In this case, we want select the maximum peak for each spectra and then apply
intensityFun
. lower magnitude noise will reduce the aggregated intensity to a great extent. Simply stat, this problem exist in 7/52 mz-groups of this case (lengths(mzs) > length(sp), this mean noise are involved)This problem may be improved by more suitable
ppm
, but maybe a aggregation procedure inside one spectra before aggregation between spectra is more useful in some situation.