\name{dksPerm}
\alias{dksPerm}
\title{ Estimate significance of signature scores. }
\description{
	The distribution of Kolmogorov Rank Sum scores generated by 
	this package depends on a variety of factors including the size
    of the signature and the total number of genes measured in each 
	sample.  For a given classifier, this function bootstraps an 
	approximate distribution for the scores and then identifies 
	optimum parameters for the gamma distribution that best fits the 
	bootstrap distribution.  The corresponding gamma probability 
	function is then returned, allowing p-values for one or more 
	scores to be readily computed.
}
\usage{
dksPerm(eset, class, n=100, samples=100, type="up", rescale=FALSE, 
		verbose=FALSE, method="kort")
}
\arguments{
  \item{eset}{An \code{ExpressionSet} or \code{matrix} containing the gene 
		expression data to be used for bootstrapping.}
  \item{class}{A factor with two or more levels indicating which 
				class each sample in the expression set belongs OR 
				an integer indicating which column of pData(eset) 
				contains this information.}
  \item{n}{The number of genes per class to use in the bootstrap 
			signature.}
  \item{samples}{The number of bootstrap samples to generate.  A 
		value of at least 1000 give good results, but may take a 
		a while.}
  \item{type}{One of "up", "down", or "both".  
				See \code{\link{dksTrain}}.}
  \item{rescale}{Logical indicating whether scores should be rescaled 
				to range c(0,1).}
  \item{verbose}{Set to TRUE if you want more evidence of progress
				while data is being processed.  Set to FALSE if you 
				want your CPU cycles to be used on analysis and not 
				printing messages.}
  \item{method}{ One of either 'kort' or 'yang'.  Should match that 
					used for \code{\link{dksTrain}}.}

}
\note{ All arguments should match those used by \code{\link{dksClassify}},
		otherwise the estimated p-values will not meaningfully describe 
		the distribution of scores generated by that function. }
\value{
	A function (1-pgamma(x, ...)) with the appropriate parameters 
	preset based on log likelihood maximization relative to the bootstrapped 
	distribution.
}
\author{Eric J. Kort}
\seealso{\code{\link{dksTrain}}, \code{\link{dksSelectGenes}},
	\code{\link{dksClassify}}, \code{\link{DKSGeneScores}}, 
	\code{\link{DKSPredicted}}, 
	\code{\link{DKSClassifier}}}

\examples{

	data("dks")
	p.value <- dksPerm(eset, 1, samples=25)
	# this is not nearly enough samples, but will suffice for 
	# the demonstration.  See the vignette for more informative 
	# example.
	p.value(250)
	p.value(1500)
}

\keyword{classif}