df2genind           package:adegenet           R Documentation(utf8)

_C_o_n_v_e_r_t _a _d_a_t_a._f_r_a_m_e _o_f _g_e_n_o_t_y_p_e_s _t_o _a _g_e_n_i_n_d _o_b_j_e_c_t, _a_n_d _c_o_n_v_e_r_s_e_l_y.

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

     The function 'df2genind' converts a data.frame (or a matrix) into
     a genind object. The data.frame must meet the following
     requirements:
      - genotypes are in row (on row per genotype)
      - markers are in columns
      - each element is a string of characters coding alleles with or
     without separator. If no separator is used, the function tries to
     find how many characters code each genotypes at a locus, but it is
     safer to state it ('ncode' argument). Uncomplete strings are
     filled with "0" at the begining. 

     The function 'genind2df' converts a genind back to such a
     data.frame.

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

     df2genind(X, sep=NULL, ncode=NULL, ind.names=NULL, loc.names=NULL,
      pop=NULL, missing=NA, ploidy=2, type=c("codom","PA"))
     genind2df(x,pop=NULL, sep="", usepop=TRUE)

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

       X: a matrix or a data.frame (see decription)

     sep: a character string separating alleles. See details.

   ncode: an optional integer giving the number of characters used for
          coding one genotype at one locus. If not provided, this is
          determined from data.

ind.names: an optional character vector giving the individuals names;
          if NULL, taken from rownames of X.

loc.names: an optional character vector giving the markers names; if
          NULL, taken from colnames of X.

     pop: an optional factor giving the population of each individual.

 missing: can be NA, 0 or "mean". See details section.

  ploidy: an integer indicating the degree of ploidy of the genotypes.

    type: a character string indicating the type of marker: 'codom'
          stands for 'codominant' (e.g. microstallites, allozymes);
          'PA' stands for 'presence/absence' markers (e.g. AFLP, RAPD).

       x: a genind object

  usepop: a logical stating whether the population (argument 'pop' or
          'x@pop' should be used (TRUE, default) or not (FALSE).

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

     === There are 3 treatments for missing values === 
      - NA: kept as NA.

     - 0: allelic frequencies are set to 0  on all alleles of the
     concerned locus. Recommended for a PCA on compositionnal data.

     - "mean": missing values are replaced by the mean frequency of the
     corresponding allele, computed on the whole set of individuals.
     Recommended for a centred PCA.

     === Details for the 'sep' argument ===
      this character is directly used in reguar expressions like
     'gsub', and thus require some characters to be preceeded by double
     backslashes. For instance, "/" works but "|" must be coded as
     "\\|".

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

     an object of the class genind for 'df2genind'; a matrix of
     biallelic genotypes for 'genind2df'

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

     Thibaut Jombart t.jombart@imperial.ac.uk

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

     'import2genind', 'read.genetix', 'read.fstat', 'read.structure'

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

     df <- data.frame(loc1=c("11","11","12","32"),
     loc2=c(NA,"34","55","15"),loc3=c("22","22","21","22"))
     row.names(df) <- .genlab("geontype",4)
     df

     obj <- df2genind(df)
     obj
     truenames(obj)
     genind2df(obj)

