check              package:GeneticsPed              R Documentation

_C_h_e_c_k _c_o_n_s_i_s_t_e_n_c_y _o_f _d_a_t_a _i_n _p_e_d_i_g_r_e_e

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

     'check' performs a series of checks on pedigree object to ensure
     consistency of data.

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

     check(x, ...)
     checkId(x)

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

       x: pedigree, object to be checked

     ...: arguments to other methods, none for now

_D_e_t_a_i_l_s:

     'checkId' performs various checks on subjects and their
     ascendants. These checks are:

        *  idClass: all ids must have the same class

        *  subjectIsNA: subject can not be NA

        *  subjectNotUnique: subject must be unique

        *  subjectEqualAscendant: subject can not be equal (in
           identification) to its ascendant

        *  ascendantEqualAscendant: ascendant can not be equal to
           another ascendant

        *  ascendantInAscendant: ascendant can not appear again as
           asescendant of other sex i.e. father can not be a mother to
           someone else

        *  unusedLevels: in case factors are used for id presentation,
           there might be unused levels for some ids - some functions
           rely on number of levels and a check is provided for this

     'checkAttributes' is intended primarly for internal use and
     performs a series of checks on attribute values needed in various
     functions. It causes stop with error messages for all given
     attribute checks.

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

     List of more or less self-explanatory errors and "pointers" to
     these errors for ease of further work i.e. removing errors.

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

     Gregor Gorjanc

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

     'Pedigree'

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

       ## EXAMPLES BELLOW ARE ONLY FOR TESTING PURPOSES AND ARE NOT INTENDED
       ## FOR USERS, BUT IT CAN NOT DO ANY HARM.

       ## --- checkAttributes ---
       tmp <- generatePedigree(5)
       attr(tmp, "sorted") <- FALSE
       attr(tmp, "coded") <- FALSE
       GeneticsPed:::checkAttributes(tmp)
       try(GeneticsPed:::checkAttributes(tmp, sorted=TRUE, coded=TRUE))

       ## --- idClass ---
       tmp <- generatePedigree(5)
       tmp$id <- factor(tmp$id)
       class(tmp$id)
       class(tmp$father)
       try(GeneticsPed:::idClass(tmp))

       ## --- subjectIsNA ---
       tmp <- generatePedigree(2)
       tmp[1, 1] <- NA
       GeneticsPed:::subjectIsNA(tmp)

       ## --- subjectNotUnique ---
       tmp <- generatePedigree(2)
       tmp[2, 1] <- 1
       GeneticsPed:::subjectNotUnique(tmp)

       ## --- subjectEqualAscendant ---
       tmp <- generatePedigree(2)
       tmp[3, 2] <- tmp[3, 1]
       GeneticsPed:::subjectEqualAscendant(tmp)

       ## --- ascendantEqualAscendant ---
       tmp <- generatePedigree(2)
       tmp[3, 2] <- tmp[3, 3]
       GeneticsPed:::ascendantEqualAscendant(tmp)

       ## --- ascendantInAscendant ---
       tmp <- generatePedigree(2)
       tmp[3, 2] <- tmp[5, 3]
       GeneticsPed:::ascendantInAscendant(tmp)
       ## Example with multiple parents
       tmp <- data.frame(id=c("A", "B", "C", "D"),
                         father1=c("E", NA, "F", "H"),
                         father2=c("F", "E", "E", "I"),
                         mother=c("G", NA, "H", "E"))
       tmp <- Pedigree(tmp, ascendant=c("father1", "father2", "mother"),
                       ascendantSex=c(1, 1, 2),
                       ascendantLevel=c(1, 1, 1))
       GeneticsPed:::ascendantInAscendant(tmp)

       ## --- unusedLevels ---
       tmp <- generatePedigree(2, colClass="factor")
       tmp[3:4, 2] <- NA
       GeneticsPed:::unusedLevels(tmp)

