Learn R Programming

adegenet (version 1.0-0)

export: Conversion functions from adegenet to other R packages

Description

The function genind2genotype and genind2hierfstat convert a genind object into, respectively, a list of genotypes (class genotypes, package genetics), and a data.frame to be used by the functions of the package hierfstat.

Usage

genind2genotype(x,pop=NULL,res.type=c("matrix","list"))
genind2hierfstat(x,pop=NULL)

Arguments

x
a genind object.
pop
a factor giving the population of each individual. If NULL, it is seeked in x$pop. If NULL again, all individuals are assumed from the same population.
res.type
a character (if a vector, only the first element is retained), indicating the type of result returned.

Value

  • The function genind2genotype converts a genind object into genotypes (package genetics). If res.type is set to "matrix" (default), the returned value is a individuals x locus matrix whose columns have the class genotype. Such data can be used by LDheatmap package to compute linkage disequilibrium. If res.type is set to "list", the returned value is a list of genotypes sorted first by locus and then by population.) genind2hierfstat returns a data frame where individuals are in rows. The first columns is a population factor (but stored as integer); each other column is a locus. Genotypes are coded as integers (e.g., 44 is an homozygote 4/4, 56 is an heterozygote 5/6).

References

Gregory Warnes and Friedrich Leisch (2007). genetics: Population Genetics. R package version 1.2.1.

Jerome Goudet (2005). HIERFSTAT, a package for R to compute and test hierarchical F-statistics. Molecular Ecology, 5:184-186 Fstat (version 2.9.3). Software by Jerome Goudet. http://www2.unil.ch/popgen/softwares/fstat.htm

See Also

import2genind

Examples

Run this code
if(require(hierfstat)){

obj <- fstat2genind(system.file("data/diploid.dat",package="hierfstat"))

X <- genind2hierfstat(obj)
X

read.fstat.data(paste(.path.package("hierfstat"),"/data/diploid.dat",sep="",collapse=""),nloc=5)
}
if(require(genetics)){
genind2genotype(obj)
}

Run the code above in your browser using DataLab