lgatto / MSnbase

Base Classes and Functions for Mass Spectrometry and Proteomics
http://lgatto.github.io/MSnbase/
123 stars 50 forks source link

Problem with "too large halfWindowSize" with writeMSdata after centroiding MSe data #587

Closed cwegler closed 1 year ago

cwegler commented 1 year ago

Hi, I have MSe data acquired in profile (continuum) mode with a Waters Xevo G2 XS QToF instrument, converted to mzML with MSConvert from proteowizard, and imported using the readMSData(x, centroided = FALSE) function.

The profile data contains many data points:

image image

I then centroid the data with the pickPeaks function, after smooth and mz-refinement (see code below). My peaks are about 5-10 s wide, and I set the halfWindowSize to 2. When trying to save a mzML file (I need this file for other downstream analyses) with writeMSdata I get the error that the halfWindowSize is too big. image

However, It seems like the peak picking does work with those settings when I look at a XIC:

image image

When plotting, I get the warnings:

image

When I reduce the halfWindowSize to 1, I still get similar results in the XIC:

image

but I get another error when trying to save the file

image

I have also tried to remove the smooth() function, but then I got another error:

image

Does anyone have any ideas of how this can be fixed?

Cheers!

jorainer commented 1 year ago

Hm, maybe @sgibb has an idea?

cwegler commented 1 year ago

It seems like the problem was in that some of the spectra contained only zeros, the problem was resolved by adding the following line before the centroiding with smooth() and pickPeaks()

data_profile@featureData <- featureData(data_profile)[fData(data_profile)$totIonCurrent != 0,]

sgibb commented 1 year ago

The error too large halfWindowSize just happens if the number of data points in a spectrum are less than 2 * halfWindowSize + 1 (5 data points in this case).