##################################################
### 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
### Apply the classifier to the TRAINING set using default decision rule
trainingPrediction <- SWAP.KTSP.Classify(matTraining, classifier)
### Resubstitution performance in the TRAINING set
### Define a "positive" test result if needed
table(trainingPrediction, trainingGroup)
### Use an alternative DecideFunction to classify each patient
### Here for instance at least two TSPs must agree
trainingPrediction <- SWAP.KTSP.Classify(matTraining, classifier,
DecisionFunc = function(x) sum(x) > 5.5 )
### Contingency table for the TRAINING set
table(trainingPrediction, trainingGroup)
##################################################
### Testing on new data
### Load the example data for the TEST set
data(testingData)
### Show group variable for the TEST set
table(testingGroup)
### Apply the classifier to one sample of the TEST set using default decision rule
testPrediction <- SWAP.KTSP.Classify(matTesting[ , 1, drop=FALSE], classifier)
### Show prediction
testPrediction
### Apply the classifier to the complete the TEST set
### using decision rule defined above (agreement of two TSPs)
testPrediction <- SWAP.KTSP.Classify(matTesting,
classifier, DecisionFunc = function(x) sum(x) > 5.5)
### Show prediction
head(testPrediction, n=10)
### Contingency table for the TEST set
table(testPrediction, testingGroup)
Run the code above in your browser using DataLab