utilities: Utily Functions for pegas

utilitiesR Documentation

Utily Functions for pegas

Description

The first three functions extract information on loci, expand.genotype creates a table of all possible genotypes given a set of alleles, proba.genotype calculates expected probabilities of genotypes under Hardy–Weinberg equilibrium, is.snp tests whether a locus is a SNP, is.phased tests whether a gentotype is phased, and unphase unphase phased genotypes.

Usage

getPloidy(x)
getAlleles(x)
getGenotypes(x)
expand.genotype(n, alleles = NULL, ploidy = 2, matrix = FALSE)
proba.genotype(alleles = c("1", "2"), p, ploidy = 2)
is.snp(x)
## S3 method for class 'loci'
is.snp(x)
is.phased(x)
unphase(x)

Arguments

x

an object of class "loci".

n

an integer giving how many alleles to consider (ignored if alleles is used).

alleles

the allele names as a vector of mode character.

ploidy

an integer giving the ploidy level (either 2 or 4 for the moment).

matrix

a logical specifying whether to return the genotypes in a matrix or as a character vector.

p

a vector of allele probabilities; if missing, equal probabilities are assumed.

Details

expand.genotype and proba.genotype accept any level of ploidy and any number of alleles.

For is.snp, a locus is defined as a SNP if it has two alleles and their labels are made of a single character (e.g., A and T, or 1 and 2, but not A and AT).

Value

getPloidy returns the ploidy level of all genotypes as a matrix of integers with rownames and colnames taken from x.

getAlleles and getGenotypes return the alleles and genotypes, respectively, observed in all loci in an object of class "loci" as a list.

expand.genotype returns a character vector (the default) or a matrix where the rows are the genotypes and the columns are the alleles. The matrix is numeric by default, or character if the argument alleles is given.

proba.genotype returns a numeric vector with names set as the genotypes.

is.snp returns a logical vector specifying whether each locus is a SNP.

is.phased returns a matrix of the same size than the original data specifying whether each genotype is phased or not.

unphase unphases the genotypes and eventually pools those that become identical once unphased (e.g., A|T and T|A).

Author(s)

Emmanuel Paradis

Examples

data(jaguar)
X <- jaguar[, 1:2]
getAlleles(X)
getGenotypes(X)
expand.genotype(2)
expand.genotype(2, LETTERS[1:3])
expand.genotype(3, ploidy = 4)
proba.genotype() # classical HWE with 2 alleles
## an octoploid with a six-allele locus (1287 possible genotypes):
length(p <- proba.genotype(alleles = LETTERS[1:6], ploidy = 8))
max(p) # ~ 0.006
## back to the jaguar data:
s <- summary(X)
## allele counts from the first locus:
p <- s[[1]]$allele
## expected probabilities for the 136 possible genotypes...
proba.genotype(names(p), p/sum(p))
## ... to be compared with s[[1]]$genotype

pegas documentation built on May 29, 2024, 2:27 a.m.