af: Function to compute allele frequencies

View source: R/af.R

afR Documentation

Function to compute allele frequencies

Description

Function af computes the allele frequency for a vector with autosomal or X-chromosomal genotype counts or compositions.

Usage

af(x)

Arguments

x

a vector or matrix with counts or compositions. x must have either three elements (autosomal) or five elements (X-chromosomal)

Details

Function af calculates the A allele frequency for the given order of autosomal genotype counts (AA,AB,BB) or the given order of X chromosomal genotype counts (A,B,AA,AB,BB). The genotypes must be supplied this order. Use maf to calculate the minor allele frequency and more flexible coding.

Value

a vector with allele frequencies

Author(s)

Jan Graffelman (jan.graffelman@upc.edu)

See Also

maf, afx

Examples

#
# A simulated random marker
#
X <- as.vector(rmultinom(1,100,c(0.5,0.4,0.1)))
X <- X/sum(X)
print(X)
print(af(X))
#
# MN blood group counts
#
x <- c(MM=298,MN=489,NN=213)
#
# Calculate frequency M allele
#
af(x)
#
# Calculate frequency N allele
#
af(rev(x))
1 - af(x)
#
# Calculated allele frequencies (p) for a matrix of genotype counts.
#
X <- HWData(nm=10,n=100)
X
p <- af(X)
p

HardyWeinberg documentation built on May 29, 2024, 6:17 a.m.