##################################################
### Load gene expression data for the training set
data(trainingData)
### Show group variable for the TRAINING set
table(trainingGroup)
##################################################
### Train a classifier using default filtering function based on the Wilcoxon test
classifier <- SWAP.KTSP.Train(matTraining, trainingGroup, krange=c(3, 5, 8:15))
### Show the classifier
classifier
##################################################
### Train another classifier from the top 4 best features
### according to the deafault filtering function
classifier <- SWAP.KTSP.Train(matTraining, trainingGroup,
FilterFunc=SWAP.Filter.Wilcoxon, featureNo=4)
### Show the classifier
classifier
##################################################
### To use all features "FilterFunc" must be set to NULL
classifier <- SWAP.KTSP.Train(matTraining, trainingGroup, FilterFunc=NULL)
### Show the classifier
classifier
##################################################
### Train a classifier using and alternative filtering function.
### For instance we can use the a "t.test" to selec the features
### with an absolute t-statistics larger than a specified quantile
topRttest <- function(situation, data, quant = 0.75) {
out <- apply(data, 1, function(x, ...) t.test(x ~ situation)$statistic )
names(out[ abs(out) > quantile(abs(out), quant) ])
}
### Show the top features selected
topRttest(trainingGroup, matTraining, quant=0.95)
### Train a classifier using the alternative filtering function
### and also define the maximum number of TSP using "krange"
classifier <- SWAP.KTSP.Train(matTraining, trainingGroup,
FilterFunc = topRttest, quant = 0.75, krange=c(15:30) )
### Show the classifier
classifier
##################################################
### Training with restricted pairs
### Define a set of specific pairs to be used for classifier development
### For this example we will a random set of features
### In a real example these pairs should be provided by the user.
set.seed(123)
somePairs <- matrix(sample(rownames(matTraining), 6^2, replace=FALSE), ncol=2)
head(somePairs, n=3)
dim(somePairs)
### Train a classifier using the restricted feature pairs and the default filtering
classifier <- SWAP.KTSP.Train(matTraining, trainingGroup,
RestrictedPairs = somePairs, krange=3:16)
### Show the classifier
classifier
Run the code above in your browser using DataLab