planarPlot-methods       package:MLInterfaces       R Documentation

_M_e_t_h_o_d_s _f_o_r _F_u_n_c_t_i_o_n _p_l_a_n_a_r_P_l_o_t _i_n _P_a_c_k_a_g_e _M_L_I_n_t_e_r_f_a_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     show the classification boundaries on the plane dictated by two
     genes in an ExpressionSet

_M_e_t_h_o_d_s:

     _c_l_o = "_c_l_a_s_s_i_f_O_u_t_p_u_t", _e_s_e_t = "_E_x_p_r_e_s_s_i_o_n_S_e_t", _c_l_a_s_s_i_f_L_a_b = "_c_h_a_r_a_c_t_e_r" 
          uses two genes in the ExpressionSet to exhibit the decision
          boundaries in the plane

     _c_l_o = "_c_l_a_s_s_i_f_O_u_t_p_u_t", _e_s_e_t = "_d_a_t_a._f_r_a_m_e", _c_l_a_s_s_i_f_L_a_b = "_c_h_a_r_a_c_t_e_r" 
          uses two columns in the data.frame to exhibit the decision
          boundaries in the plane

_E_x_a_m_p_l_e_s:

     library(ALL)
     data(ALL)
     #
     # restrict to BCR/ABL or NEG
     #
     bio <- which( ALL$mol.biol %in% c("BCR/ABL", "NEG"))
     #
     # restrict to B-cell
     #
     isb <- grep("^B", as.character(ALL$BT))
     kp <- intersect(bio,isb)
     all2 <- ALL[,kp]
     #
     # sample 2 genes at random
     #
     set.seed(1234)
     ng <- nrow(exprs(all2))
     pick <- sample(1:ng, size=2, replace=FALSE)
     library(hgu95av2)
     gg <- all2[pick,]
     sym <- unlist(mget(featureNames(gg), hgu95av2SYMBOL))
     featureNames(gg) <- sym
     gg$class = factor(ifelse(all2$mol.biol=="NEG", "NEG", "POS"))

     cl1 <- which( gg$class == "NEG" )
     cl2 <- which( gg$class != "NEG" )
     #
     # create balanced training sample
     #
     trainInds <- c( sample(cl1, size=floor(length(cl1)/2) ),
           sample(cl2, size=floor(length(cl2)/2)) )
     #
     # run rpart
     #
     tgg <- rpartB( gg, "class", trainInds, minsplit=4 )
     opar <- par(no.readonly=TRUE)
     par(mfrow=c(2,2))
     planarPlot( tgg, gg, "class" )
     title("rpart")
     points(exprs(gg)[1,trainInds], exprs(gg)[2,trainInds], col=ifelse(gg$class[trainInds]=="NEG", "yellow", "black"), pch=16)
     #
     # run nnet
     #
     ngg <- nnetB( gg, "class", trainInds, size=8 )
     planarPlot( ngg, gg, "class" )
     points(exprs(gg)[1,trainInds], exprs(gg)[2,trainInds], col=ifelse(gg$class[trainInds]=="NEG", "yellow", "black"), pch=16)
     title("nnet")
     #
     # run knn
     #
     kgg <- knnB( gg, "class", trainInds, k=3, l=1 )
     planarPlot( kgg, gg, "class" )
     points(exprs(gg)[1,trainInds], exprs(gg)[2,trainInds], col=ifelse(gg$class[trainInds]=="NEG", "yellow", "black"), pch=16)
     title("3-nn")
     #
     # run svm
     #
     sgg <- svmB( gg, "class", trainInds )
     planarPlot( sgg, gg, "class" )
     points(exprs(gg)[1,trainInds], exprs(gg)[2,trainInds], col=ifelse(gg$class[trainInds]=="NEG", "yellow", "black"), pch=16)
     title("svm")
     par(opar)

