\HeaderA{tuneInPeakInfo}{Tune in the peak information: peak position and peak scale}{tuneInPeakInfo}
\keyword{methods}{tuneInPeakInfo}
\begin{Description}\relax
Based on the identified peak position, more precise estimation of the peak information, i.e., peak position and peak scale, can be got by this function. The basic idea is to cut the segment of spectrum near the identified peaks, and then do similar procedures as \code{\LinkA{peakDetectionCWT}{peakDetectionCWT}}, but with more detailed scales around the estimated peak scale.
\end{Description}
\begin{Usage}
\begin{verbatim}
tuneInPeakInfo(ms, majorPeakInfo = NULL, peakIndex = NULL, peakScale = NULL, maxScale = 128, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{ms}] the mass spectrometry spectrum 
\item[\code{majorPeakInfo}] return of \code{\LinkA{identifyMajorPeaks}{identifyMajorPeaks}} 
\item[\code{peakIndex}] the m/z index of the identified peaks
\item[\code{peakScale}] the scales of the identified peaks 
\item[\code{maxScale}] the maximum scale allowed for the peak 
\item[\code{...}] other parameters of used by \code{\LinkA{getLocalMaximumCWT}{getLocalMaximumCWT}}, \code{\LinkA{getRidge}{getRidge}}, \code{\LinkA{identifyMajorPeaks}{identifyMajorPeaks}} 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The majorPeakInfo or peakIndex and peakScale must be provided.
\end{Details}
\begin{Value}
\begin{ldescription}
\item[\code{peakCenterIndex}] the updated peak center m/z index
\item[\code{peakScale}] the updated peak scale
\item[\code{peakValue}] the corresponding peak value
\end{ldescription}
\end{Value}
\begin{Author}\relax
Pan Du
\end{Author}
\begin{References}\relax
Du, P., Kibbe, W.A. and Lin, S.M. (2006) Improved peak detection in mass spectrum by incorporating continuous wavelet transform-based pattern matching, Bioinformatics, 22, 2059-2065.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{peakDetectionCWT}{peakDetectionCWT}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

        data(exampleMS)
        SNR.Th <- 3
        peakInfo <- peakDetectionCWT(exampleMS, SNR.Th=SNR.Th)
        majorPeakInfo <- peakInfo$majorPeakInfo
        betterPeakInfo <- tuneInPeakInfo(exampleMS, majorPeakInfo)
        plot(500:length(exampleMS), exampleMS[500:length(exampleMS)], type='l', log='x')
        abline(v=betterPeakInfo$peakCenterIndex, col='red')

\end{ExampleCode}
\end{Examples}

