na.replace-methods {adegenet} | R Documentation |
The generic function na.replace
replaces NA in an object by
appropriate values as defined by the argument method
.
Methods are defined for genind and genpop objects.
## S4 method for signature 'genind': na.replace(x,method, quiet=FALSE) ## S4 method for signature 'genpop': na.replace(x,method, quiet=FALSE)
x |
a genind and genpop object |
method |
a character string: can be "0" or "mean" for genind objects, and "0" or "chi2" for genpop objects. |
quiet |
logical stating whether a message should be printed (TRUE,default) or not (FALSE). |
The argument "method" have the following effects:
- "0": missing values are set to "0". An entity (individual or
population) that is not type on a locus has zeros for all alleles of
that locus.
- "mean": missing values are set to the mean of the concerned
allele, computed on all available observations (without distinction
of population).
- "chi2": if a population is not typed for a marker, the corresponding count is set to that of a theoretical count in of a Chi-squared test. This is obtained by the product of the sums of both margins divided by the total number of alleles.
A genind and genpop object without missing values.
Thibaut Jombart jombart@biomserv.univ-lyon1.fr
data(nancycats) obj1 <- genind2genpop(nancycats) # note missing data in this summary summary(obj1) # NA are all in pop 17 and marker fca45 which(is.na(obj1$tab),TRUE) truenames(obj1)[17,] # replace missing values obj2 <- na.replace(obj1,"chi2") obj2$loc.names # missing values where replaced truenames(obj2)[,obj2$loc.fac=="L4"]