recode {HardyWeinberg}R Documentation

Recode genotype information

Description

function recode recodes bi-allelic genetic marker information expressed as strings (e.g. "AA", "AB", "BB") into numerical form.

Usage

recode(X, alleles, values = c(0, 1, 2), pos1 = 1, pos2 = 3, minor
= FALSE, verbose = FALSE)

Arguments

X

A matrix or dataframe of bi-allelic markers, individuals in rows, markers in columns

alleles

a vector with the alleles for each marker (e.g. c("A/T", "A/G", etc))

values

a vector of numerica values for AA, AB and BB, ((0,1,2) by default).

pos1

position of the first allele in the allele string (1 by default).

pos2

position of the second allele in the allele string (3 by default).

minor

coding is according to the number of copies of the minor allele. if minor = TRUE, the value of 2 reflects two copies of the minor allele, and the value 0 reflects no copies of the minor allele.

verbose

print progress on the conversion or not.

Details

recode is written for bi-allelic marker data only. Heterozygotes may be coded both as AB or BA. By default, the second allele specified (e.g. "T" in "A/T") is counted in the recoding, and homozygotes AA are coded as 0 and homozygotes TT as 2.

Value

A numerical matrix, individuals in rows, markers in columns

Author(s)

Jan Graffelman jan.graffelman@upc.edu

See Also

MakeCounts

Examples

SNP1 <- c("GG","GG","GG","GG","GG","GG","GG","GG","GG")
SNP2 <- c("CG","GG","CC","GG","GG","CG","CG","CG","CG")
SNP3 <- c("AA","AA","AA","AG","AA","AG","AA","AA","AA")
SNP4 <- c("GG","GG","GG","GG","GG","GG","GG","GG","GG")
SNP5 <- c("CC","CC","CC","CC","CC","CC","CT","CT","CT")
X <- cbind(SNP1,SNP2,SNP3,SNP4,SNP5)
Y <- recode(X,c("A/G","C/G","A/G","A/G","C/T"))
print(Y)

[Package HardyWeinberg version 1.7.8 Index]