scaleGen-methods          package:adegenet          R Documentation

_C_o_m_p_u_t_e _s_c_a_l_e_d _a_l_l_e_l_e _f_r_e_q_u_e_n_c_i_e_s

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

     The generic function 'scaleGen' is an analogue to the 'scale'
     function, but is designed with further arguments giving scaling
     options.

     Methods are defined for genind and genpop objects. Both return
     data.frames of scaled allele frequencies.

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

     ## S4 method for signature 'genind':
     scaleGen(x, center=TRUE, scale=TRUE, method=c("sigma", "binom"), missing=c("NA","0","mean"),truenames=TRUE)
     ## S4 method for signature 'genpop':
     scaleGen(x, center=TRUE, scale=TRUE, method=c("sigma", "binom"), missing=c("NA","0","mean"),truenames=TRUE)

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

       x: a genind and genpop object

  center: a logical stating whether alleles frequencies should be
          centred to mean zero (default to TRUE). Alternatively, a
          vector of numeric values, one per allele, can be supplied:
          these values will be substracted from the allele frequencies.

   scale: a logical stating whether alleles frequencies should be
          scaled (default to TRUE). Alternatively, a vector of numeric
          values, one per allele, can be supplied: these values will be
          substracted from the allele frequencies.

  method: a character indicating the method to be used. See details.

truenames: a logical indicating whether true labels (as opposed to
          generic labels) should be used to name the output.

 missing: a character giving the treatment for missing values. Can be
          "NA", "0" or "mean"

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

     The argument 'method' is used as follows:

     - 'sigma': scaling is made using the usual standard deviation

     - 'binom': scaling is made using the theoretical variance of the
     allele frequency. This can be used to avoid that frequencies close
     to 0.5 have a stronger variance that those close to 0 or 1.

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

     A matrix of scaled allele frequencies with genotypes (genind) or
     populations in (genpop) in rows and alleles in columns.

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

     Thibaut Jombart t.jombart@imperial.ac.uk

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

     ## load data
     data(microbov)
     obj <- genind2genpop(microbov)

     ## compare different scaling
     X1 <- scaleGen(obj)
     X2 <- scaleGen(obj,met="bin")

     if(require(ade4)){
     ## compute PCAs
     pcaObj <- dudi.pca(obj,scale=FALSE,scannf=FALSE) # pca with no scaling
     pcaX1 <- dudi.pca(X1,scale=FALSE,scannf=FALSE,nf=100) # pca with usual scaling
     pcaX2 <- dudi.pca(X2,scale=FALSE,scannf=FALSE,nf=100) # pca with scaling for binomial variance

     ## get the loadings of alleles for the two scalings
     U1 <- pcaX1$c1
     U2 <- pcaX2$c1

     ## find an optimal plane to compare loadings
     ## use a procustean rotation of loadings tables
     pro1 <- procuste(U1,U2,nf=2)

     ## graphics
     par(mfrow=c(2,2))
     # eigenvalues
     barplot(pcaObj$eig,main="Eigenvalues\n no scaling")
     barplot(pcaX1$eig,main="Eigenvalues\n usual scaling")
     barplot(pcaX2$eig,main="Eigenvalues\n 'binomial' scaling")
     # differences between loadings of alleles
     s.match(pro1$scor1,pro1$scor2,clab=0,sub="usual -> binom (procustean rotation)")
     }

