## read positive/negative sequence from files.
tmpfile1 = file.path(path.package("BioSeqClass"), "example", "acetylation_K.pos40.pep")
tmpfile2 = file.path(path.package("BioSeqClass"), "example", "acetylation_K.neg40.pep")
posSeq = as.matrix(read.csv(tmpfile1,header=FALSE,sep="\t",row.names=1))[,1]
negSeq = as.matrix(read.csv(tmpfile2,header=FALSE,sep="\t",row.names=1))[,1]
data = data.frame(rbind(featureBinary(posSeq,elements("aminoacid")),
featureBinary(negSeq,elements("aminoacid")) ),
class=c(rep("+1",length(posSeq)),
rep("-1",length(negSeq))) )
## sample train and test data
tmp = c(sample(1:length(posSeq),length(posSeq)*0.8),
sample(length(posSeq)+(1:length(negSeq)),length(negSeq)*0.8))
train = data[tmp,]
test = data[-tmp,]
## Build classification model using training data
model1 = classifyModelLIBSVM(train,svm.kernel="linear",svm.scale=FALSE)
## Predict test data by classification model
testClass = predict(model1, test[,-ncol(test)])
Run the code above in your browser using DataLab