library(SubLasso) # Version: 1.2 # Authors: Youxi Luo, Qinghan Meng, Ruiquan Ge, Guoqin Mai, Jikui Liu, Fengfeng Zhou(#corresponding) # Update: 2014-08-11 # Contact: Fengfeng Zhou (FengfengZhou@gmail.com) #### load the training data data<-read.table("GSE9574.txt",head=T) featuresNames<-as.vector(data[-1,1]) features<-apply(data[-1,-1],2,as.numeric) classes<-as.vector(as.matrix(data[1,-1])) y<- ifelse(classes=="RM",0,1) X<-features rownames(X)=featuresNames nfold<-5 ################ ### feature selection without pre-selected feature subset f1=SubLasso(X,y) f1$valid predy<-f1$cv.predy table(y,predy) f1$selname f1$w cat(f1$intercept, " + ", paste(f1$w,f1$selname,collapse=" + ",sep="*"))## The linear discriminating function f1$show.heatmap() f1$show.boxplot() #### save the training model and so as to predict on test data save(f1, file="nofix.RData") ### feature selection with the pre-selected feature "BRCA1" ## If some of the pre-selected features are not in the list of all features, an error will occur f2=SubLasso(X, y, subset=c("211851_x_","204531_s_at")) ## Error message: ## Error in SubLasso(X, y, subset = c("211851_x_", "204531_s_at")) : ## 211851_x_ out of range, please check it! f2=SubLasso(X, y, subset=c("211851_x_at","204531_s_at")) f2$valid predy<-f2$cv.predy table(y,predy) f2$selname f2$w cat(f2$intercept, " + ", paste(f2$w,f2$selname,collapse=" + ",sep="*"))## The linear discriminating function f2$show.heatmap() f2$show.boxplot() #### save the training model and predict on test data save(f2, file="fixBRCA1.RData") ### Give a report of SubLasso results write("Selected feature names:",file="Summary.txt",append=T) write.table(f2$selname,file="Summary.txt",append=T,sep="\t") write("Weight of selected features:",file="Summary.txt",append=T) write.table(f2$w,file="Summary.txt",append=T,sep="\t") write(paste("\t",nfold,"folds CV result"),file="Summary.txt",append=T) write.table(f2$valid,file="Summary.txt",append=T,sep="\t") write(paste("\t",nfold,"folds CV result"),file="Summary.txt",append=T) write.table(table(y,predy),file="Summary.txt",append=T,sep="\t") write("The predicted classes in cross validation :",file="Summary.txt",append=T) write.table(f2$cv.predy,file="Summary.txt",append=T,sep="\t") write("Descripion of selected features:",file="Summary.txt",append=T) write(paste("Class label",names(f2$description)[1]),file="Summary.txt",append=T) write.table(f2$description[[1]],file="Summary.txt",append=T,sep="\t") write(paste("Class label",names(f1$description)[2]),file="Summary.txt",append=T) write.table(f2$description[[2]],file="Summary.txt",append=T,sep="\t") write("Correlation of selected features:",file="Summary.txt",append=T) write.table(f2$correlation,file="Summary.txt",append=T,sep="\t") "The trained model without pre-selected features is saved in: nofix.RData" "The trained model with fixed features from BRCA1 is saved in: fixBRCA1.RData" "The summary of the training process is saved in: Summary.txt"