\HeaderA{getRidge}{Identify ridges based on the local maximum matrix}{getRidge}
\keyword{methods}{getRidge}
\begin{Description}\relax
Identify ridges by connecting the local maximum of 2-D CWT coefficients from the coarse scale to detail scale. The local maximum matrix is returned  from \code{\LinkA{getLocalMaximumCWT}{getLocalMaximumCWT}}
\end{Description}
\begin{Usage}
\begin{verbatim}
getRidge(localMax, iInit = ncol(localMax), step = -1, iFinal = 1, minWinSize= 5, gapTh = 3, skip = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{localMax}] The local maximum matrix is returned  from \code{\LinkA{getLocalMaximumCWT}{getLocalMaximumCWT}} with 1 represents maximum, others are 0. 
\item[\code{iInit}] The start column to search ridge. By default, it starts from the coarsest scale level.
\item[\code{step}] Search step. -1 by default, which means searching from coarse scale to detail scale column by column. 
\item[\code{iFinal}] The final column index of search ridge. 
\item[\code{minWinSize}] The minimum slide window size used. 
\item[\code{gapTh}] The gap allowed during searching for ridge. 3 by default. 
\item[\code{skip}] The column to be skipped during search. 
\end{ldescription}
\end{Arguments}
\begin{Value}
Return a list of ridge. As some ridges may end at the scale larger than 1, in order to keep the uniqueness of the ridge names, we combined the smallest scale of the ridge and m/z index of the peak at that scale together to name the ridges. For example the ridge name "1\_653" means the peak ridge ends at the CWT scale 1 with m/z index 653 at scale 1.
\end{Value}
\begin{Author}\relax
Pan Du, Simon Lin
\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{getLocalMaximumCWT}{getLocalMaximumCWT}}, \code{\LinkA{identifyMajorPeaks}{identifyMajorPeaks}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
        data(exampleMS)
        scales <- seq(1, 64, 3)
        wCoefs <- cwt(exampleMS[5000:11000], scales=scales, wavelet='mexh')
        
        localMax <- getLocalMaximumCWT(wCoefs)
        ridgeList <- getRidge(localMax)
        plotRidgeList(ridgeList)
\end{ExampleCode}
\end{Examples}

