| Bioinformatics Toolbox | ![]() |
Smooth mass spectrum with least-squares polynomial
Yout = mssgolay(MZ,Y, 'PropertyName', PropertyValue...)
mssgolay(..., 'Span', SpanValue)
mssgolay(..., 'Degree', DegreeValue)
mssgolay(..., 'ShowPlot', ShowPlotValue)
MZ | Mass/charge vector with the range of ions in the spectra. |
Y | Ion intensity vector with the same length as the mass/charge vector (MZ). Y can also be a matrix with several spectra that share the same mass/charge (MZ) range. |
Yout = mssgolay(MZ,Y, 'PropertyName', PropertyValue...) smoothes a raw mass spectrum (Y) using a least squares digital polynomial filter (Savitzky and Golay filters). The default span or frame is 15 samples.
mssgolay(..., 'Span', SpanValue) modifies the frame size for the smoothing function. If SpanValue is greater than 1, the window is the size of SpanValue in samples independent of the MZ vector. Higher values will smooth the signal more with an increase in computation time. If SpanValue is less than 1, the window size is a fraction of the number of points in the data (MZ). For example, if SpanValue is 0.05, the window size is equal to 5% of the number of points in MZ.
Note 1) The original algorithm by Savitzky and Golay assumes a uniformly spaced mass/charge vector (MZ), while mssgolay also allows one that is not uniformly spaced. Therefore, the sliding frame for smoothing is centered using the closest samples in terms of the MZ value and not in terms of the MZ index. 2) When the vector MZ does not have repeated values or NaNs, the algorithm is approximately twice as fast. 3) When the vector MZ is evenly spaced, the least-squares fitting is performed once so that the spectrum is filtered with the same coefficients, and the speed of the algorithm increases considerably. 4) If the vector MZ is evenly spaced and SpanValue is even, Span is incremented by 1 to include both edge samples in the frame. |
mssgolay(..., 'Degree', DegreeValue) specifies the degree of the polynomial (DegreeValue) fitted to the points in the moving frame. The default value is 2. DegreeValue must be smaller than SpanValue.
mssgolay(..., 'ShowPlot', ShowPlotValue) plots smoothed spectra over the original. When mssgolay is called without output arguments, the spectra are plotted unless ShowPlotValue is false. When ShowPlotValue is true, only the first spectrum in Y is plotted. ShowPlotValue can also contain an index to one of the spectra in Y.
load sample_lo_res YS = mssgolay(MZ_low_res, Y_low_res(:,1)); plot(MZ,[Y(:,1) YS])
Bioinformatic Toolbox functions msalign, msbackadj, msheatmap, mslowess, msnorm, , msresample, msviewer
| msresample | msviewer | ![]() |
© 1994-2005 The MathWorks, Inc.