\HeaderA{plotBins}{Plots the probability bins overlaid with flowFrame data}{plotBins}
\keyword{misc}{plotBins}
\begin{Description}\relax
This function is useful in visualizing the differences between the binned control
and sample datasets. The bins generated from the control dataset are 
overlaid with the sample dataset. An optional argument residuals can be used to 
shade each bin based on a calculated statistical measure of difference between 
the number of events in each bin.
\end{Description}
\begin{Usage}
\begin{verbatim}
plotBins(binRes,data,channels,title,residuals,shadeFactor)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{binRes}] The result generated by calling the \code{probBin}
function on a control dataset.
\item[\code{data}] An object of class \code{\LinkA{flowFrame}{flowFrame}}
sample(dataset)
\item[\code{channels}] The flow parameters to be plotted.In cases where more
than two parameters are binned from the control set, the
\code{plotBins} function plots the projections of the hyperplanes in
2 dimensions)
\item[\code{title}] Optional title for the plot generated
\item[\code{residuals}] A vector of length equal to the number of bins
generated that can be used to shade each bin. The residuals from the
\code{calcPearsonChi} function or the \code{calcPBChiSquare}
function can be used to highlight the bins that are different
between control and sample datasets
\item[\code{shadeFactor}] Optional argument between 0 and 1 that controls
the intensity of the shading of bins
\end{ldescription}
\end{Arguments}
\begin{Author}\relax
Nishant Gopalakrishnan
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{proBin}{proBin}}, \code{\LinkA{calcPearsonChi}{calcPearsonChi}},
\code{\LinkA{calcPBChiSquare}{calcPBChiSquare}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

data(GvHD)
# flow frame 1 is treated as  control dataset and used to generate bins
resCtrl<-proBin(GvHD[[1]][,c("FSC-H","SSC-H","Time")],200)  
plotBins(resCtrl,GvHD[[1]],channels=c("FSC-H","SSC-H"),title="Binned control data")
# Same bins are applied to flowFrame 16
resSample<-binByRef(resCtrl,GvHD[[16]][,c("FSC-H","SSC-H","Time")])
stat<-calcPearsonChi(resCtrl,resSample)
dev.new()
plotBins(resCtrl,data=GvHD[[16]],channels=c("FSC-H","SSC-H","Time"),title="Comparision 1 & 16",
residuals=stat$residuals[2,],shadeFactor=0.7)

\end{ExampleCode}
\end{Examples}

