gendata.to.genind {polysat} | R Documentation |
Convert Data to genind Format
Description
This is a function for exporting data to the package adegenet.
Usage
gendata.to.genind(object, samples = Samples(object), loci = Loci(object))
Arguments
object |
A |
samples |
A character vector indicating the samples to include in the output. |
loci |
A character vector indicating the loci to include in the output. |
Details
gendata.to.genind
converts a "genambig"
or
"genbinary"
object to a "genind"
object using the package
adegenet. Each individual must have a single ploidy.
Ploidy and population information are carried over to the new
object. Data will be coded as presence/absence in the new object. The
locus names in the new object are locus and allele names
seperated by a hyphen.
adegenet must be installed in order to use this function.
Value
A genetic dataset in the "genind"
class, ready for use in
adegenet.
Author(s)
Lindsay V. Clark
References
http://adegenet.r-forge.r-project.org/
Jombart, T. (2008) adegenet: a R package for the multivariate analysis of genetic markers. Bioinformatics 24, 1403–1405.
See Also
Examples
# create a "genambig" object
mydata <- new("genambig", samples=c("a","b","c","d"), loci=c("e","f"))
PopNames(mydata) <- c("G","H")
PopInfo(mydata) <- c(1,1,2,2)
mydata <- reformatPloidies(mydata, output="one")
Ploidies(mydata) <- 3
Genotypes(mydata, loci="e") <- list(c(100),c(100,102),
c(98,102,104),c(102,106))
Genotypes(mydata, loci="f") <- list(c(200,202,204),Missing(mydata),
c(210,212),c(204,210,214))
# convert to "genind"; not tested as it takes several seconds to load adegenet
if(require("adegenet")){
mydata2 <- gendata.to.genind(mydata)
mydata2@tab
locNames(mydata2)
indNames(mydata2)
popNames(mydata2)
pop(mydata2)
}