R/vaf.R

Defines functions vaf

Documented in vaf

vaf <- function(X,hw=FALSE) {
  if (is.vector(X)) {
      n <- sum(X)
      pA <- af(X)
      pAA <- X[1]/n
  }
  else if (is.matrix(X)) {
      n <- rowSums(X)
      pA <- af(X)
      pAA <- X[,1]/n
  }
  if(!hw) y <- (pA+pAA-2*(pA^2))/(2*n) else y <- pA*(1-pA)/(2*n)
  return(y)
}

Try the HardyWeinberg package in your browser

Any scripts or data that you put into this service are public.

HardyWeinberg documentation built on May 7, 2022, 5:05 p.m.