## load package provided sequence dataset
data(TFBS)
## display sequences
enhancerFB
## display part of label vector
head(yFB, 20)
## display no of samples of positive and negative class
table(yFB)
## split dataset into training and test samples
train <- sample(1:length(enhancerFB), 0.7*length(enhancerFB))
test <- c(1:length(enhancerFB))[-train]
## create the kernel object for the normalized spectrum kernel
spec <- spectrumKernel(k=5)
## train model
## pass sequence subset, label subset, kernel object, the package and
## svm which should be used for training together with the SVM parameters
model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=spec,
pkg="LiblineaR", svm="C-svc", cost=10)
## predict the test samples
pred <- predict(model, enhancerFB, sel=test)
## evaluate the prediction result
evaluatePrediction(pred, yFB[test], allLabels=unique(yFB))
Run the code above in your browser using DataLab