## load transcription factor binding site data
data(TFBS)
enhancerFB
## we use 70 of the samples for training and the rest for test
train <- sample(1:length(enhancerFB), length(enhancerFB) * 0.7)
test <- c(1:length(enhancerFB))[-train]
## create the kernel object for dimers without normalization
specK2 <- spectrumKernel(k=2)
## show details of kernel object
specK2
## run training with kernel matrix on e1071 (via the
## dense LIBSVM implementation integrated in kebabs)
model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=specK2,
pkg="e1071", svm="C-svc", C=10, explicit="no")
## show KeBABS model
model
## show class of KeBABS model
class(model)
## show native SVM model contained in KeBABS model
svmModel(model)
## show class of native SVM model
class(svmModel(model))
## Not run:
# ## examples for package and SVM selection
# ## now run the same samples with the same kernel on e1071 via
# ## explicit representation
# model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=specK2,
# pkg="e1071", svm="C-svc", C=10, explicit="yes")
#
# ## show KeBABS model
# model
# ## show native SVM model contained in KeBABS model
# svmModel(model)
# ## show class of native SVM model
# class(svmModel(model))
#
# ## run the same samples with the same kernel on e1071 with nu-SVM
# model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=specK2,
# pkg="e1071", svm="nu-svc",nu=0.7, explicit="yes")
#
# ## show KeBABS model
# model
#
# ## training with feature weights
# model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=specK2,
# pkg="e1071", svm="C-svc", C=10, explicit="yes",
# featureWeights="yes")
#
# ## show feature weights
# dim(featureWeights(model))
# featureWeights(model)[,1:5]
#
# ## training without feature weights
# model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=specK2,
# pkg="e1071", svm="C-svc", C=10, explicit="yes",
# featureWeights="no")
#
# ## show feature weights
# featureWeights(model)
#
# ## pruning of feature weights
# model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=specK2,
# pkg="e1071", svm="C-svc", C=10, explicit="yes",
# featureWeights="yes", weightLimit=0.5)
#
# dim(featureWeights(model))
#
# ## training with precomputed kernel matrix
# ## feature weights cannot be computed for precomputed kernel matrix
# km <- getKernelMatrix(specK2, x=enhancerFB, selx=train)
# model <- kbsvm(x=km, y=yFB[train], kernel=specK2,
# pkg="e1071", svm="C-svc", C=10, explicit="no")
#
# ## training with precomputed explicit representation
# exrep <- getExRep(enhancerFB, sel=train, kernel=specK2)
# model <- kbsvm(x=exrep, y=yFB[train], kernel=specK2,
# pkg="e1071", svm="C-svc", C=10, explicit="yes")
#
# ## computing of probability model via Platt scaling during training
# ## in prediction class membership probabilities can be computed
# ## from this probability model
# model <- kbsvm(x=enhancerFB[train], y=yFB[train], kernel=specK2,
# pkg="e1071", svm="C-svc", C=10, explicit="yes",
# probModel=TRUE)
#
# ## show parameters of the fitted probability model which are the parameters
# ## probA and probB for the fitted sigmoid function in case of classification
# ## and the value sigma of the fitted Laplacian in case of a regression
# probabilityModel(model)
#
# ## cross validation, grid search and model selection are also performed
# ## via the kbsvm method. Examples can be found on the respective help pages
# ## (see Details section)
# ## End(Not run)
Run the code above in your browser using DataLab