genotype_matrix: Genotype matrix functions

Genotype matrix functionsR Documentation

Genotype matrix functions

Description

Functions which modify a matrix or vector of genotypes.

Usage

alleles2consensus(x, sep = "/", NA_to_n = TRUE)

get.alleles(x2, split = "/", na.rm = FALSE, as.numeric = FALSE)

Arguments

x

a matrix of alleles as genotypes (e.g., A/A, C/G, etc.)

sep

a character which delimits the alleles in a genotype (/ or |)

NA_to_n

logical indicating whether NAs should be scores as n

x2

a vector of genotypes

split

character passed to strsplit to split the genotype into alleles

na.rm

logical indicating whether to remove NAs

as.numeric

logical specifying whether to convert to a numeric

Details

The function alleles2consensus converts genotypes to a single consensus allele using IUPAC ambiguity codes for heterozygotes. Note that some functions, such as ape::seg.sites do not recognize ambiguity characters (other than 'n'). This means that these functions, as well as functions that depend on them (e.g., pegas::tajima.test), will produce unexpected results.

Missing data are handled in a number of steps. When both alleles are missing ('.') the genotype is converted to NA. Secondly, if one of the alleles is missing ('.') the genotype is converted to NA> Lastly, NAs can be optionally converted to 'n' for compatibility with DNAbin objects.

The function get.alleles takes a vector of genotypes and returns the unique alleles.


vcfR documentation built on Feb. 16, 2023, 8:12 p.m.