hwp               package:GeneticsPed               R Documentation

_U_t_i_l_i_t_y _f_u_n_c_t_i_o_n_s _f_o_r _g_p_i()

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

     'gpLong2Wide' changes data.frame with genotype probabilities in
     long form (one genotype per row) to wide form (one individual per
     row) for use in 'gpi'.

     'hwp' calculates genotype probabilities according to
     Hardy-Weinberg law for use in 'gpi'.

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

       gpLong2Wide(x, id, genotype, prob, trim=TRUE)
       hwp(x, trim=TRUE)

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

       x: data.frame for 'gpLong2Wide', 'genotype' for 'hwp'

      id: character, column name in 'x' holding individual
          identifications

genotype: character, column name in 'x' holding genotypes

    prob: character, column name in 'x' holding genotype probabilities

    trim: logical, remove last column (for 'gpLong2Wide') or value (for
          'hwp') of a result

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

     Hardy-Weinberg probabilities for a gene with two alleles A and B,
     with probabilities Pr(A) and Pr(B) are:

        *  Pr(AA) = Pr(A)^2

        *  Pr(AB) = 2 * Pr(A) * Pr(A)

        *  Pr(BB) = Pr(B)^2

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

     'gpLong2Wide' returns a matrix with number of rows equal to number
     of individuals and number of columns equal to number of possible
     genotypes.

     'hwp' returns a vector with Hardy-Weinberg genotype probabilities.

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

     Gregor Gorjanc

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

     'gpi', 'genotype', 'expectedGenotypes'

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

       if(require(genetics)) {
         gen <- genotype(c("A/A", "A/B"))
         hwp(x=gen)
         hwp(x=gen, trim=FALSE)
       }

