KS.flowcytest {rflowcyt}R Documentation

Kolmogorov Smirnoff Test 2-sample

Description

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 stats. A density plot made by the function 'bkde' in KernSmooth package is also shown.

Usage

  KS.flowcytest(controldata, stimuldata,
                title="", varname = "", yupper = 0.01,
                xlimit = c(0, 1025), alternative="two.sided",
                KS.plotted=TRUE,
                MY.DEBUG=TRUE,...)

Arguments

controldata a vector of numeric values of the control data
stimuldata a vector of numeric values of the stimulated/case data
title character string of the plot title
varname character string of the name of the variable
yupper the upper limit of the densities calculated
xlimit a vector indicating the range of the controldata and the stimuldata
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
KS.plotted boolean to display the corresponding plot; default is TRUE and the plot will be displayed
MY.DEBUG boolean; if TRUE, the test is printed out with comments; if FALSE then these comments are surpressed
... parameters for the stimuldata distribution specified in ks.test

Details

In general, the control and the stimulated data come from the Interferon Gamma Data Variable of a FCS R object.

Value

pval.2sid.KS p value of the two sided Kolmogorov Smirnoff test
Alt.Hypoth.KS The Alternative Hypthesis as a string
method.KS the method used
dataname.KS the name of the data

A superimposed plot of the densities of the control and the stimulated dataset is also displayed.

WARNING

Usually the FCS object is gated and subset prior to this testing and analysis.

Note

Other flowcytests are available such as pkci2.flowcytest, ProbBin.flowcytest, 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.

Author(s)

A.J. Rossini and J.Y. Wan

References

See ks.test

See Also

pkci2.flowcytest, ProbBin.flowcytest, runflowcytests, ks.test, bkde

Examples

 
    ## 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.
  }
  

[Package rflowcyt version 1.14.0 Index]