\name{summary.ProbBin.FCS}
\alias{summary.ProbBin.FCS}
\title{Chi-Squared/Standard Normal Approximation Summary Statistics for
  a ProbBin.FCS object} 
\description{
  This function provides summary statistics for the test of distribution
  difference of two samples that have been probability-binned or in
  histogram form.

  Given two probability-binned samples, of which one will be called the
  stimulated sample and the other the unstimulated/control sample, the
  null hypothesis is that both the unstimulated/Control Data
  Histogram/Bins are the statistically the same as the Stimulated
  Data Histogram/Bins.  Thus, the two samples have the same distribution
  in the null hypothesis.

  The alternative hypothesis is that the Unstimulated/Control Data
  Histogram/Bins are significantly different from the Stimulated Data
  Histogram/Bins.  Thus, the two distributions have a different distribution.


}
\usage{
  summary.ProbBin.FCS(object, verbose=FALSE,...)
}
\arguments{
  \item{object}{ProbBin.FCS object}
  \item{verbose}{Boolean whether to output all the counts in each bin}
  \item{...}{not used}
}
\details{
  
  There are four main test statistics involved which are the following:
  
  1.  Test1: T.chi.unadj=max(0,(PBmetric-mean(PBmetric)) / SD(PBmetric))
  is approximately standard normal (by the Central Limit Theorem
  (CLT)).  Thus, the test of significance used the standard normal
  test as proposed by Mario Roederer.
  
  2.  Test2: Adjusted PB metric statistic is distributed as a
  chi-squared statistics.  Thus, the test of significance uses
  the chi-squared test as proposed by Keith A. Baggerly.
  
  3.  Test3: Adjusted T.chi.unadj statistic is approximately 
  the standard normal (by CLT).  Thus the test of significance uses the
  standard normal test as proposed by Keith A. Baggerly.
  
  4.  Test4: Pearson's statistic using the Chi-Squared Test.
  There has been a suggestion of using a different number of degrees of
  freedom
  
  
  Please note that all four tests use different statistics to test the
  same null hypothesis against the same alternative hypothesis. 

  Test 2 and 3 are ajusted forms of the statistics mentioned in Test 1.
  
  Different p-values both one and two-sided are given for those
  applicable statistics.
}
\value{
  A list consisting of:
  \item{PBinType}{Type of Probability Binning:
   \describe{
    \item{"by.control"}{uses the control dataset to obtain the
    breaks/cutoffs to bin the stimulated dataset given a certain
    number of observations in each bin of the control dataset}
    \item{"combined"}{uses the combined dataset (both control and stimulated
    datasets) to obtain the breaks/cutoffs for the bins given a
    certain number in each bin}
   }
  }
  \item{control.bins}{single column matrix of the counts in each bin of
    the control dataset} 
  \item{stim.bins}{single column matrix of the counts in each bin of the
    stimulated dataset}
  \item{total.control}{numeric; total number in the control dataset}
  \item{total.stim}{numeric; total number in the stimulated dataset}
  \item{T.chi.unadj}{Roederer's unadjusted normalized PB metric statistic which
    is normalized by subtracting off the
    mean and then dividing by the standard deviation.  This statistic is
    approximately standard normal.}
  \item{p.val.2tail.z.unadj}{Two-tailed standard normal p-value corresponding to the
    Roederer's unadjusted normalized PB metric statistic which is approximated as
    a standard normal}
  \item{p.val.1tail.z.unadj}{Upper standard normal one-tailed p-value corresponding to the
    Roederer's unadjusted PB metric statistic which is approximated as
    a standard normal}
  \item{PBmetric.unadj}{Roederer's unadjusted PB metric which is
    ((n.c + n.s)/(2*nc.*n.s))*Chi-squared or an unadjusted
  chi-squared statistic, where n.c is the number of control observations
  (unbinned) and n.s is the number of stimulated observations (unbinned)}
  \item{PBmetric.adj}{Baggerly's adjusted PB metric statistic which is a
    Chi-squared statistic}
  \item{PB.df}{The degrees of freedom of the PB metric (adjusted and
    unadjusted) which is B-1, where B is the number of bins in the
    eitherthe control or the stimulated binned data}
  \item{p.val.1tail.chi.adj}{Upper one-tailed chi-squared p-value
    corresponding to Baggerly's adjusted PB metric}
  \item{T.chi.adj}{Baggerly's PB metric which is normalized
    by subtracting off the mean and dividing by the standard deviation;
    This normalized statistic is approximately standard normal.}
  \item{p.val.1tail.z.adj}{Upper one-tailed standard normal p-value corresponding to the
    Baggerly's adjusted normalized PB metric statistic which is approximated as
    a standard normal}
  \item{p.val.2tail.z.adj}{Standard normal two-tailed p-value corresponding to the
    Baggerly's adjusted PB metric statistic which is approximated as
    a standard normal}
  \item{pearson.stat}{Pearson's Chi-Squared Statistic with degrees
  of freedom 2B-1, where B is the number of bins in either the control or
  the stimulated binned data}
  \item{pearson.df}{the degrees of freedom for the chi-squared statistic}
  \item{pearson.p.value}{The p-value corresponding to the chi-squared distribution}
  \item{pearson.method}{string of the indicating the type of test and
    options performed}
  \item{pearson.dataname}{string of the name(s) of the data}
  \item{pearson.observed}{a vector of the observed counts}
  \item{pearson.expected}{a vector of the expected counts under the null
  hypothesis}
  \item{pearson.p.val.PB.df}{Fisher's Chi-squared statistic with degrees
  of freedom B-1, where B is the number of bins in either the control or
  the stimulated binned data}

}
\references{

  Keith A. Baggerly "Probability Binning and Test Agreement
  between Multivariate Immunofluorescence Histograms: Extending the
  Chi-Squared test" Cytometry 45: 141:150 (2001).

  Mario Roederer, et al. "Probability Binning Comparison: A
  Metric for Quantitating Univariate Distribution Differences" Cytometry
  45:37-46 (2001).
  
  Documentation for \code{\link{chisq.test}}.}
\author{A.J. Rossini and J.Y. Wan}

\seealso{ \code{\link{ProbBin.FCS}}, \code{\link{ProbBin.flowcytest}},
  \code{\link{chisq.test}}}
\examples{

if (require(rfcdmin)){
  ## obtaining the FCS objects from VRC data
if ( !(is.element("unst.1829", objects()) & is.element("st.1829", objects())) ){
data(VRCmin)
}
IFN.gamma.1<-unst.1829@data[1:2000,4]
IFN.gamma.2<-st.1829@data[1:2000,4]

#Probability binning using the control dataset to determine the breaks
PB1<-ProbBin.FCS(IFN.gamma.1, IFN.gamma.2, 200,
varname=colnames(unst.1829@data)[4], PBspec="by.control",MY.DEBUG=FALSE)

sum.PB1.1<-summary(PB1)
sum.PB1.2<-summary.ProbBin.FCS(PB1)


}
}
\keyword{univar}
\keyword{dplot}