\HeaderA{ALICOR}{aligned and interpolated correlation for local
maximum traces for two scatterplots}{ALICOR}
\aliasA{alicor}{ALICOR}{alicor}
\aliasA{demoPGM1ssr}{ALICOR}{demoPGM1ssr}
\aliasA{locmax}{ALICOR}{locmax}
\aliasA{WRC}{ALICOR}{WRC}
\aliasA{wrc}{ALICOR}{wrc}
\keyword{models}{ALICOR}
\begin{Description}\relax
aligned and interpolated correlation for local maximum traces from two
scatterplots
\end{Description}
\begin{Usage}
\begin{verbatim}
alicor(x1, y1, x2, y2, bin = 50000)
ALICOR(ssr, dns = rawCD4, bin = 50000)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x1}] domain points for first scatterplot
\item[\code{y1}] range points for first scatterplot
\item[\code{x2}] domain points for second scatterplot
\item[\code{y2}] range points for second scatterplot
\item[\code{ssr}] an instance of class \code{snpScreenResult} 
\item[\code{dns}] an instance of class \code{\LinkA{hg18track}{hg18track.Rdash.class}} 
\item[\code{bin}] bin size, units are base pairs 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
We define a scatterplot to be a pair of vectors (x, y).
We are interested in measuring the distance between two scatterplots,
focusing on the locations of local peaks and valleys.  Two scatterplots
are close if their peaks and valleys in y are nearby in x.

We have no restrictions on commonalities between the scatterplots,
but this only makes sense if there is reasonable overlap between
their x ranges.

The algorithm, implemented in low-level function
\code{alicor}, is as follows.  Use parameter \code{bin} to 
define a grid in x for each scatterplot, and compute the maximum
y value in each x-grid interval.  Compute a common domain
for the two scatterplots based solely on \code{x1}.
Linearly interpolate the maximal series for
each scatterplot on the common domain.  Compute the correlation coefficient
for the resulting interpolated series.

The higher-level function \code{ALICOR} adapts this to \code{snpScreenResult}
\code{plot\_mlp} display data and to hg18 annotation track data.
\end{Details}
\begin{Value}
scalar correlation coefficient
\end{Value}
\begin{Note}\relax
Many variations on this algorithm are possible, but the code is not
very flexible at this time.
\end{Note}
\begin{Author}\relax
VJ Carey \textless{}stvjc@channing.harvard.edu\textgreater{}
\end{Author}
\begin{Examples}
\begin{ExampleCode}
data(sOSR2)
data(c19g)
juxtaPlot(c19g, sOSR2)
ALICOR(sOSR2,  c19g)
\end{ExampleCode}
\end{Examples}

