For Matlab:
mslowess
Smooth mass spectrum using nonparametric method
Syntax
Yout = mslowess(MZ, Y, 'PropertyName', PropertyValue...)
mslowess(..., 'Order', OrderValue)
mslowess(..., 'Span', SpanValue)
mslowess(..., 'Kernel', KernelValue)
mslowess(..., 'RobustIterations', RobustIterationsValue)
mslowess(..., 'ShowPlot', ShowPlotValue)
Arguments
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.
Description
Yout = mslowess(MZ, Y, 'PropertyName', PropertyValue...) smoothes a mass spectrum (Y) using a locally weighted linear regression (lowess) method with a default span of 10 samples.
Note 1) mslowess assumes that a mass/charge vector (MZ) might not be uniformly spaced. Therefore, the sliding window for smoothing is centered using the closest samples in terms of the MZ value and not in terms of the MZ indices.
2) When the vector MZ does not have repeated values or NaNs, the algorithm is approximately twice as fast.
mslowess(..., 'Order', OrderValue) specifies the order (OrderValue) of the Lowess smoother. Enter 1 (linear polynomial fit or Lowess), 2 (quadratic polynomial fit or Loess), or 0 (equivalent to a weighted local mean estimator and presumably faster because only a mean computation is performed instead of a least squares regression). The default value is 1.
Note The MATLAB Curve Fitting Toolbox also refers to Lowess smoothing of order 2 as Loess smoothing.
mslowess(..., 'Span', SpanValue) specifies the window size for the smoothing kernel. If SpanValue is greater than 1, the window is equal to SpanValue number of samples independent of the mass/charge vector (MZ). The default value is 10 samples. Higher values will smooth the signal more at the expense of computation time. If SpanValue is less than 1, the window size is taken to be a fraction of the number of points in the data. For example, when SpanValue is 0.005, the window size is equal to 0.50% of the number of points in MZ.
mslowess(..., 'Kernel', KernelValue) selects the function (KernelValue) for weighting the observed ion intensities. Samples close to the MZ location being smoothed have the most weight in determining the estimate. Enter
'tricubic' (default) (1 - (dist/dmax).^3).^3
'gaussian' exp(-(2*dist/dmax).^2)
'linear' 1-dist/dmaxmslowess(..., 'RobustIterations', RobustIterationsValue) specifies the number of iterations (RobustValue) for a robust fit. If RobustIterationsValue is 0 (default), no robust fit is performed. For robust smoothing, small residual values at every span are outweighed to improve the new estimate. 1 or 2 robust iterations are usually adequate while, larger values might be computationally expensive.
Note For a uniformly spaced MZ vector, a nonrobust smoothing with Order equal to 0 is equivalent to filtering the signal with the kernel vector.
mslowess(..., 'ShowPlot', ShowPlotValue)plots the smoothed spectrum over the original spectrum. When mslowess 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.
Example
Load sample data.
load sample_lo_resSmooth spectrum and draw figure with unsmoothed and smoothed spectra.
YS = mslowess(MZ_lo_res,Y_lo_res(:,1),'Showplot',true);
[此贴子已经被作者于2006-4-22 1:25:49编辑过]