Convert Data to genind Format

Share:

Description

This is a function for exporting data to the package adegenet.

Usage

1
gendata.to.genind(object, samples = Samples(object), loci = Loci(object))

Arguments

object

A "genambig" or (preferably) a "genbinary" object.

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

freq.to.genpop

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
require(adegenet)

# 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"
mydata2 <- gendata.to.genind(mydata)
mydata2@tab
locNames(mydata2)
indNames(mydata2)
popNames(mydata2)
pop(mydata2)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.