genind2genpop         package:adegenet         R Documentation(utf8)

_C_o_n_v_e_r_s_i_o_n _f_r_o_m _a _g_e_n_i_n_d _t_o _a _g_e_n_p_o_p _o_b_j_e_c_t

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

     The function 'genind2genpop' converts genotypes data (genind) into
     alleles counts per population (genpop).

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

     genind2genpop(x,pop=NULL,missing=c("NA","0","chi2"),quiet=FALSE,
                   process.other=FALSE, other.action=mean)

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

       x: an object of class 'genind'.

     pop: a factor giving the population of each genotype in 'x'. If
          note provided, seeked in x@pop, but if given, the argument
          prevails on x@pop.

 missing: can be "NA", "0", or "chi2". See details for more
          information.

   quiet: logical stating whether a conversion message must be printed
          (TRUE,default) or not (FALSE).

process.other: a logical indicating whether the '@other' slot should be
          processed (see details).

other.action: a function to be used when processing the '@other' slot.
          By default, 'mean' is used.

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

     === 'missing' argument ===
      The values of the 'missing' argument in 'genind2genpop' have the
     following effects:
      - "NA": if all genotypes of a population for a given allele are
     missing, count value will be NA

     - "0": if all genotypes of a population for a given allele are
     missing, count value will be 0

     - "chi2": if all genotypes of a population for a given allele are
     missing, count value will be that of a theoretical count in of a
     Chi-squared test. This is obtained by the product of the margins
     sums divided by the total number of alleles.

     === processing the '@other' slot ===
      Essentially, 'genind2genpop' is about aggregating data per
     population. The function can do the same for all numeric items in
     the '@other' slot provided they have the same length (for vectors)
     or the same number of rows (matrix-like objects) as the number of
     genotypes. When the case is encountered and if 'process.other' is
     TRUE, then these objects are processed using the function defined
     in 'other.action' per population. For instance, spatial
     coordinates of genotypes would be averaged to obtain population
     coordinates.

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

     A genpop object. The component @other in 'x' is passed to the
     created genpop object.

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

     Thibaut Jombart t.jombart@imperial.ac.uk

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

     genind, genpop, 'na.replace'

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

     ## simple conversion
       data(nancycats)
       nancycats
       catpop <- genind2genpop(nancycats)
       catpop
       summary(catpop)

     ## processing the @other slot
     data(sim2pop)
     sim2pop$other$foo <- letters
     sim2pop
     dim(sim2pop$other$xy) # matches the number of genotypes
     sim2pop$other$foo # does not match the number of genotypes

     obj <- genind2genpop(sim2pop, process.other=TRUE)
     obj$other # the new xy is the populations' centre

     pch <- as.numeric(pop(sim2pop))
     col <- pop(sim2pop)
     levels(col) <- c("blue","red")
     col <- as.character(col)
     plot(sim2pop$other$xy, pch=pch, col=col)
     text(obj$other$xy, lab=row.names(obj$other$xy), col=c("blue","red"), cex=2, font=2)

