as.genetics: Convert class genalex object to data frame encoding loci...

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

Description

Converts an object of class genalex to a data frame in which the genotype columns for each locus have been converted to genotypes encoded with class genotype as provided by the genetics package. All class genalex attributes are retained except for class genalex itself; see Details. Only conversion of diploid data are supported, a inherent limitation of the genetics package.

Usage

1
2
3
## S3 method for class 'genalex'
as.genetics(x, phased = FALSE, sep = "/",
  check.annotation = TRUE, ...)

Arguments

x

Annotated data frame of class genalex

phased

Default FALSE. If FALSE, assumes alleles in x are unphased so that a genotype of 101/107 is identical to a genotype of 107/101. This results in the application of class genotype to the genotype data, using makeGenotypes. Default ordering for alleles is applied, which for class genotype is to be sorted by frequency; for more information, see genotype If TRUE, assumes alleles are phased so that a genotype of 101/107 is different from a genotype of 107/101. This results in the application of class haplotype using makeHaplotypes. In this case, alleles are ordered as they are present in the genotype.

sep

Ignored, package genetics applies it inconsistently so we cannot reliably apply its effects. If it were ever to work, it would be the haracter to separate alleles in a locus, passed to makeGenotypes or makeHaplotypes

check.annotation

If TRUE, the annotations for the dataset are checked using is.genalex(x, force = TRUE, skip.strings = TRUE) prior to conversion. If that returns FALSE, nothing is converted and an error is generated.

...

Additional arguments, currently ignored

Details

A class genotype object is a special type of factor, and in contrast to class genalex a diploid genotype is encoded as a single level of a factor and thus is in a single column of a data frame. For diploid data, the number of columns in the resulting data frame will be reduced by the number of loci. The sample name and population columns are retained, as are the names of the loci.

If either allele of a genotype is missing, the entire genotype is treated as missing in class genotype.

This is a specialised wrapper around the functions makeGenotypes (phased = FALSE) and makeHaplotypes (phased = TRUE) from the genetics package.

Value

x as a data frame with the genotype of each locus encoded using class genotype. The class genalex is removed while many of the attributes are retained:

data.file.name

The original value, wrapped with "as.genetics(...)"

ploidy

Retained

n.loci

Retained

n.samples

Retained

n.pops

Retained

pop.labels

Retained

pop.sizes

Retained

dataset.title

Retained

sample.title

Retained

pop.title

Retained

locus.names

Retained

locus.columns

Modified to indicate the change to a single column per locus

extra.columns

Retained

Author(s)

Douglas G. Scofield

See Also

genotype, haplotype, makeGenotypes, makeHaplotypes

Examples

1
2
3

douglasgscofield/readGenalex documentation built on May 15, 2019, 10:43 a.m.