generation            package:GeneticsPed            R Documentation

_C_a_l_c_u_l_a_t_e _g_e_n_e_r_a_t_i_o_n _v_a_l_u_e

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

     'generation' calculates generation value of individuals in given
     pedigree. 'generation<-' provides mean to properly add generation
     information into the pedigree.

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

     generation(x, start=1, generationOrder=NULL)
     generation(x, generationOrder=NULL, col=NULL) <- value

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

       x: pedigree object

   start: first generation value

generationOrder: character, should be generation values "increasing" or
          "decreasing" through generations, see details

     col: character, column name in 'x' for generation

   value: generation values for subjects in the pedigree

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

     Generation value for founders is set to value 'start', which is by
     default 1, while other individuals get it according to:


             G_s = max(G_{1a} + G_{2a} + ... G_{na}) + 1


     where G represents generation value for s - subject, a - ascendant
     e.g. father and mother, where n=2. N might be higher if there are
     multiple ascendants i.e. this function can also handle pedigrees
     with higher order ascendants e.g. grandfather.

     'generationOrder' can be used to define "increasing" or
     "decreasing" order of generation values. If this argument is
     'NULL', which is default, then this information is taken from the
     pedigree - see 'Pedigree' for more on this issue.

     'col' provides a mean to name or possibly also rename generation
     column with user specified value, say "generazione" in Italian.
     When 'col=NULL', which is default, "generation" is used.

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

     A vector of generation values (integers)

_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:

       # Nonoverlapping pedigree
       ped <- generatePedigree(nId=5, nGeneration=4, nFather=1, nMother=2)
       ped$generation1 <- generation(ped)
       ped

       # Overlapping Pedigree
       ped <- data.frame(     id=c(1, 2, 3, 4, 5, 6, 7),
                          father=c(0, 0, 2, 2, 2, 4, 4),
                          mother=c(0, 0, 1, 0, 3, 3, 5),
                         dtBirth=c(2, 1, 3, 4, 5, 6, 7))
       ped <- Pedigree(ped, unknown=0, dtBirth="dtBirth")
       generation(ped) <- generation(ped)

       # Overlapping pedigree + one individual (4) comes late in pedigree and
       # has no ascendants
       ped <- data.frame(     id=c(1, 2, 3, 4, 5, 6, 7),
                          father=c(0, 0, 2, 0, 2, 4, 4),
                          mother=c(0, 0, 1, 0, 3, 3, 5),
                         dtBirth=c(2, 1, 3, 2, 5, 6, 7))
       ped <- Pedigree(ped, unknown=0, dtBirth="dtBirth")
       generation(ped)
       generation(ped, generationOrder="decreasing",
                  col="generazione") <- generation(ped, generationOrder="decreasing")

