\HeaderA{KS.flowcytest}{Kolmogorov Smirnoff Test 2-sample}{KS.flowcytest}
\aliasA{KS}{KS.flowcytest}{KS}
\keyword{dplot}{KS.flowcytest}
\keyword{distribution}{KS.flowcytest}
\begin{Description}\relax
Provides a Kolmogorov Smirnoff 2-sample Test to determine if the
distribution of the control data is different from the
distribution of the stimulated data (for which both datasets are of
the same variable).  See also the function 'ks.test' in the \pkg{stats}.  A
density plot made by the function 'bkde' in \pkg{KernSmooth}
package is also
shown.
\end{Description}
\begin{Usage}
\begin{verbatim}
  KS.flowcytest(controldata, stimuldata,
                title="", varname = "", yupper = 0.01,
                xlimit = c(0, 1025), alternative="two.sided",
                KS.plotted=TRUE,
                MY.DEBUG=TRUE,...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{controldata}] a vector of numeric values of the control data
\item[\code{stimuldata}] a vector of numeric values of the stimulated/case data
\item[\code{title}] character string of the plot title
\item[\code{varname}] character string of the name of the variable
\item[\code{yupper}] the upper limit of the densities calculated
\item[\code{xlimit}] a vector indicating the range of the controldata and the
stimuldata
\item[\code{alternative}] character string of the alternative hypothesis:

1.  "two sided" : Two sided alternative hypothesis

2. "less": One sided alternative hypothesis: controldata
distribution is less than the stimuldata distribution

3.  "greater" One sided alternative hypothesis: controldata
distribution is greater than the stimuldata distribution


\item[\code{KS.plotted}] boolean to display the corresponding plot; default
is TRUE and the plot will be displayed
\item[\code{MY.DEBUG}] boolean; if TRUE, the test is printed out with
comments; if FALSE then these comments are surpressed
\item[\code{...}] parameters for the stimuldata distribution specified in
\code{\LinkA{ks.test}{ks.test}}
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
In general, the control and the stimulated data come from the
Interferon Gamma Data Variable of a FCS R object.
\end{Details}
\begin{Value}
\begin{ldescription}
\item[\code{pval.2sid.KS}] p value of the two sided Kolmogorov Smirnoff test
\item[\code{Alt.Hypoth.KS}] The Alternative Hypthesis as a string
\item[\code{method.KS}] the method used
\item[\code{dataname.KS}] the name of the data
\end{ldescription}

A superimposed plot of the densities of the control and the stimulated
dataset is also displayed.
\end{Value}
\begin{Section}{WARNING}
Usually the FCS object is gated and subset prior to
this testing and analysis.
\end{Section}
\begin{Note}\relax
Other flowcytests are available such as \code{pkci2.flowcytest},
\code{ProbBin.flowcytest}, \code{KS.flowcytest}, which test the
equivalence of two sample distributions. Generally, comparing the control and
stimulated samples of the interferon gamma variable is of interest.
\end{Note}
\begin{Author}\relax
A.J. Rossini and J.Y. Wan
\end{Author}
\begin{References}\relax
See \code{\LinkA{ks.test}{ks.test}}
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{pkci2.flowcytest}{pkci2.flowcytest}},
\code{\LinkA{ProbBin.flowcytest}{ProbBin.flowcytest}},
\code{\LinkA{runflowcytests}{runflowcytests}},
\code{\LinkA{ks.test}{ks.test}},
\code{\LinkA{bkde}{bkde}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
 
    ## different distributions
    control<-rnorm(1000, mean=3, sd=.7)
    stimulated<-rnorm(1000, mean=2, sd=.5)

    if (interactive()==TRUE) {
      output.same <- KS.flowcytest(control, stimulated,
                                   title="Different Distributions",
                                   varname="Interferon Gamma",
                                   yupper=1, xlimit=c(-5,8))
    }
    ## same distribution
    stimulated2<-rnorm(1000, mean=3, sd=.7)
    if (interactive()==TRUE) {
      output.diff <- KS.flowcytest(control, stimulated2,
                                   title="Same Distributions",
                                   varname="Interferon Gamma",
                                   yupper=1, xlimit=c(-5,8))
    }

    ## obtaining the FCS objects from VRC data
    if (require(rfcdmin)) {
      data.there<-is.element(c("st.1829", "unst.1829", "st.DRT", "unst.DRT"),objects())
      if ((sum(data.there) != length(data.there))) {
        ## obtaining the FCS objects from VRC data
        data(VRCmin)
      }

      ## This only serves as an example.  Usually the FCS object is
      ## gated and then subset

      ## HIV negative individual 1829
      ## only the first 2000 cells are selected

      IFN.control<-unst.1829@data[1:2000,4]
      IFN.stimul<-st.1829@data[1:2000,4]
     
      if (interactive()==TRUE){
        KS.flowcytest(IFN.control, IFN.stimul,
          title="HIV Negative Individual 1829", varname="Interferon Gamma",
          yupper=.006)
      }
      ## HIV positive individual DRT
      ## only the first 2000 cells are selected

      IFN.control2<-unst.DRT@data[1:2000,4]
      IFN.stimul2<-st.DRT@data[1:2000,4]
      
      if (interactive()){

      KS.flowcytest(IFN.control2, IFN.stimul2,
            title="HIV Positive Individual DRT", varname="Interferon Gamma",
            yupper=.006)
    }
    ## This is an artifical example, but one would expect the
    ## distributions of the stimulated and control samples
    ## to be the same in the HIV negative individual 1829
    ## and to be different in the HIV positive individual DRT
    ## The test in this example is a bit contrived but
    ## the bigger picture is achieved.
  }
  
\end{ExampleCode}
\end{Examples}

