alleles2loci | R Documentation |
These functions transform a matrix of alleles into an object of class
"loci"
, or the reverse operation.
alleles2loci(x, ploidy = 2, rownames = NULL, population = NULL,
phased = FALSE)
loci2alleles(x)
x |
a matrix or a data frame where each column is an allele, or
an object of class |
ploidy |
an integer specifying the level of ploidy. |
rownames |
an integer giving the column number to be used as rownames of the output. |
population |
an integer giving the column number to be used as population (if any). |
phased |
a logical specifying whether the genotypes should be output as phased. By default, they are unphased. |
Genetic data matrices are often arranged with one allele
in each column of the matrix (particularly for micro-satellites), so
that the number of columns is equal to the number of loci times the
level of ploidy. alleles2loci
transforms such matrices into a
"loci"
object.
If the rownames of the input matrix are already set, they are used in the output. Alternatively, it is possible to specify which column to use as rownames (this column will be deleted before creating the genotypes).
If the input matrix has colnames, then the names of the first column of each genotype is used as names of the output loci (see examples).
loci2alleles
checks that all individuals have the ploidy for a
given locus (if not an error occurs), but ploidy can vary among loci.
an object of class "loci"
or a matrix.
Emmanuel Paradis
read.loci
, as.loci
The vignette “ReadingFiles” explains how to read such a data set from Dryad (https://datadryad.org/stash).
x <- matrix(c("A", "A", "A", "a"), 2)
colnames(x) <- c("Loc1", NA)
y <- alleles2loci(x)
print(y, details = TRUE)
loci2alleles(y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.