conversion: Conversion Among Allelic Data Classes

Description Usage Arguments Details Value Author(s) See Also Examples

Description

These functions do conversion among different allelic data classes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
as.loci(x, ...)
## S3 method for class 'genind'
as.loci(x, ...)
genind2loci(x)
## S3 method for class 'data.frame'
as.loci(x, allele.sep = "/", col.pop = NULL, col.loci = NULL, ...)
loci2genind(x)
## S3 method for class 'factor'
as.loci(x, allele.sep = "/", ...)
## S3 method for class 'character'
as.loci(x, allele.sep = "/", ...)

Arguments

x

an object of class "loci" or "genind", a data frame, a factor, or a vector of mode character.

allele.sep

the character(s) separating the alleles for each locus in the data file (a forward slash by default).

col.pop

specifies whether one of the column of the data file identifies the population; default NULL, otherwise an integer or a character giving the number or the name of the column.

col.loci

a vector of integers or of characters specifying the indices or the names of the columns that are loci. By default, all columns are taken as loci except the one labelled "population", if present or specified.

...

further arguments to be passed to or from other methods.

Details

The main objectives of these functions is to provide easy conversion between the data structures of adegenet and pegas, so both packages can be used together smoothly. In addition, it is possible to create a "loci" object directly from a data frame, a vector, or a factor.

genind2loci(x) and as.loci(x) are the same if x is of class "genind".

Value

An object of class c("loci", "data.frame") for as.loci and genind2loci; an object of class "genind" for loci2genind.

Author(s)

Emmanuel Paradis

See Also

read.loci, genind, df2genind for converting data frames to "genind"

Examples

1
2
3
4
5
6
7
8
x <- c("A-A", "A-a", "a-a")
as.loci(x, allele.sep = "-")
require(adegenet)
data(nancycats)
x <- as.loci(nancycats)
y <- loci2genind(x) # back to "genind"
identical(nancycats@tab, y@tab)
identical(nancycats@pop, y@pop)

dwinter/Pegas documentation built on May 15, 2019, 6:21 p.m.