### Name: xval-methods
### Title: support for cross-validatory machine learning with
###   ExpressionSets
### Aliases: xval-methods xval xvalML
###   xval,ExpressionSet,character,nonstandardGeneric,character,missing-met
###   hod
###   xval,ExpressionSet,character,nonstandardGeneric,character,integer-met
###   hod balKfold
###   xval,ExpressionSet,character,genericFunction,character,integer-method
###   xval,ExpressionSet,character,genericFunction,character,missing-method
###   xvalML,formula,ExpressionSet,character,character,numeric-method
###   xvalML,formula,ExpressionSet,character,character,missing-method
###   xvalML,formula,ExpressionSet,character,character,numeric,ANY,ANY,ANY,
###   ANY,ANY-method
###   xvalML,formula,ExpressionSet,character,character,numeric,ANY,ANY,ANY,
###   ANY,ANY,ANY-method
###   xvalML,formula,ExpressionSet,character,character,missing,missing,miss
###   ing,missing,missing,missing-method
###   xvalML,formula,ExpressionSet,character,character,missing,missing,miss
###   ing,missing,missing,missing,missing-method
###   xvalML,formula,ExpressionSet,character,character,missing,missing,miss
###   ing,function,missing,missing,missing-method
###   xvalML,formula,ExpressionSet,character,character,missing,missing,miss
###   ing,function,numeric,missing,missing-method
### Keywords: methods

### ** Examples

library(golubEsets)
data(Golub_Merge)
smallG <- Golub_Merge[200:250,]
lk1 <- xval(smallG, "ALL.AML", knnB, xvalMethod="LOO", group=as.integer(0))
table(lk1,smallG$ALL.AML)
lk2 <- xval(smallG, "ALL.AML", knnB, xvalMethod="LOG", group=as.integer(
 rep(1:8,each=9)))
table(lk2,smallG$ALL.AML)
balKfold
lk3 <- xval(smallG, "ALL.AML", knnB, xvalMethod="FUN", 0:0, indFun=balKfold(5), niter=5)
table(lk3, smallG$ALL.AML)
#
# illustrate the xval FUN method in comparison to LOO
#
LOO2 <- xval(smallG, "ALL.AML", knnB, "FUN", 0:0, function(x,y,i) {
  (1:ncol(exprs(x)))[-i] }, niter=72 )
table(lk1, LOO2)
#
# use Stephen Henderson's feature selection extensions
#
t.fun<-function(data, fac)
{
        require(genefilter)
        # deal with the integer storage of golubTrain@exprs!
        xd <- matrix(as.double(exprs(data)), nrow=nrow(exprs(data)))
        return(abs(rowttests(xd,pData(data)[[fac]], tstatOnly=FALSE)$statistic))
}
lk3f <- xval(smallG, "ALL.AML", knnB, xvalMethod="LOO", 0:0, fsFun=t.fun)
table(lk3f$out, smallG$ALL.AML)
# use MLearn xval
XXml = xvalML(ALL.AML~., smallG, "knn", "LOO")
# show that it agrees with the fB approach
table(XXml, lk1)
# use MLearn xval with feature selection
XXmlfs = xvalML(ALL.AML~., smallG, "knn", "LOO", fsFun=t.fun)
# show that it agrees with the previous approach
table(XXmlfs$out, lk3f$out)



