R/allGenos.R

Defines functions allGenos

Documented in allGenos

#' Find all possible genotypes
#'
#' Finds all possible genotypes based on input alleles.
#' @param alleles Vector of input alleles, numeric or character
#' @return Matrix of all possible genotypes, one row per genotype
#' @author Guro Dorum
#' @export
#Reworked from paramlink's allGenotypes
allGenos <- function(alleles){

  n <- length(alleles)
  if (n < 2)
    return(matrix(nrow = 0, ncol = 2))
  v1 <- rep.int(alleles[-n],(n-1):1)
  v2 <-  NULL
  for (i in 2:n) v2 <- c(v2, alleles[i:n])
  rbind(cbind(v1=alleles, v2=alleles),cbind(v1, v2, deparse.level = 0))
}

Try the relMix package in your browser

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

relMix documentation built on Dec. 15, 2020, 5:11 p.m.