Learn R Programming

gdmp (version 0.2.0)

is.hwEq: Check a SNP for Hardy-Weinberg equilibrium

Description

Given individual genotypes of a single SNP, the function checks a population of individuals for Hardy-Weinberg equilibrium.

Usage

is.hwEq(snpG, diff)

Arguments

snpG

is a column vector in the genotypes array, created by toArray and converted to integer genotypes by snpRecode. The column represents genotypes of a single SNP for all individuals in data.

diff

heterozygosity difference used in HW equilibrium, see ‘Details’.

Value

A logical TRUE for H-W equilibrium or FALSE for H-W disequilibrium is returned.

Details

A logical function to check for HW equilibrium, the expected frequency of the heterozygous genotype is estimated based on the two homozygous genetypes by ‘sqrt(4*p^2*q^2)’. The absolute difference between the expected and observed frequency of the heterozygous genotype of the SNP needs to be smaller than the minimum difference of diff.

References

Falconer and Mackay (1996). Introduction to Quantitative Genetics (4th Edition). Pearson Education Limited, Edinburgh, England.

Wiggans et al. (2009). Selection of single-nucleotide polymorphisms and quality of genotypes used in genomic evaluation of dairy cattle in the United States and Canada. Journal of Dairy Science, 92, 3431-3436.

See Also

snpSelect, snpRecode, toArray

Examples

Run this code
# NOT RUN {
## Simulate random allele designations for 100 bi-allelic SNPs
set.seed(2016)
desig <- array(sample(c('A','C','G','T'), size = 200, repl = TRUE), dim=c(100, 2))

## Simulate random SNP genotypes for 20 individuals - put them in array format
## '-' indicates an unknown base
ga <- array(0, dim=c(20, 100))
for(i in 1:20)
  for(j in 1:100)
    ga[i, j] <- paste(sample(c(desig[j,],"-"), 2, prob=c(.47, .47, .06), repl = TRUE), collapse='')

## Recode the matrix, place recoded genotypes in ga.r
desig <- data.frame(AlleleA_Forward = factor(desig[,1]), AlleleB_Forward = factor(desig[,2]))
ga.r <- array(5, dim=c(20, 100))
for(i in 1:100) ga.r[,i] <- snpRecode(ga[,i], desig[i,])

## Check the first 10 SNPs for H-W equilibrium based on a minimum
## allowed difference of 0.15 between observed and expected heterozygosity
apply(ga.r[,1:10], 2, is.hwEq, diff=.15)
# [1]  TRUE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE  TRUE FALSE
# }

Run the code above in your browser using DataLab