numFP                  package:puma                  R Documentation

_N_u_m_b_e_r _o_f _F_a_l_s_e _P_o_s_i_t_i_v_e_s _f_o_r _a _g_i_v_e_n _p_r_o_p_o_r_t_i_o_n _o_f _T_r_u_e _P_o_s_i_t_i_v_e_s.

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

     Often when evaluating a differential expression method, we are
     interested in how well a classifier performs for very small
     numbers of false positives. This method gives one way of
     calculating this, by determining the number of false positives for
     a set proportion of true positives.

_U_s_a_g_e:

     numFP(scores, truthValues, TPRate = 0.5)

_A_r_g_u_m_e_n_t_s:

  scores: A vector of scores. This could be, e.g. one of the columns of
          the statistics of a 'DEResult' object. 

truthValues: A boolean vector indicating which scores are True
          Positives. 

  TPRate: A number between 0 and 1 identify the proportion of true
          positives for which we wish to determine the number of false
          positives. 

_V_a_l_u_e:

     An integer giving the number of false positives.

_A_u_t_h_o_r(_s):

     Richard D. Pearson

_S_e_e _A_l_s_o:

     Related methods 'plotROC' and 'calcAUC'.

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

     class1a <- rnorm(1000,0.2,0.1)
     class2a <- rnorm(1000,0.6,0.2)
     class1b <- rnorm(1000,0.3,0.1)
     class2b <- rnorm(1000,0.5,0.2)
     scores_a <- c(class1a, class2a)
     scores_b <- c(class1b, class2b)
     classElts <- c(rep(FALSE,1000), rep(TRUE,1000))
     print(numFP(scores_a, classElts))
     print(numFP(scores_b, classElts))

     ## The function is currently defined as
     function (scoresList, truthValues, TPRate = 0.5) 
     {
         numberOfTPToCount <- length(which(truthValues)) * TPRate
         scoresIndex <- sort(scoresList, decreasing = TRUE, index.return = TRUE)$ix
         numberOfFP <- 0
         numberOfTP <- 0
         for (i in 1:length(scoresIndex)) {
             if (truthValues[scoresIndex[i]]) 
                 numberOfTP <- numberOfTP + 1
             else numberOfFP <- numberOfFP + 1
             if (numberOfTP >= numberOfTPToCount) 
                 return(numberOfFP)
         }
       }

