maxmarg: Find genotypes with maximum marginal probabilities

View source: R/maxmarg.R

maxmargR Documentation

Find genotypes with maximum marginal probabilities

Description

For each individual at each position, find the genotype with the maximum marginal probability.

Usage

maxmarg(
  probs,
  map = NULL,
  minprob = 0.95,
  chr = NULL,
  pos = NULL,
  return_char = FALSE,
  quiet = TRUE,
  cores = 1,
  tol = 0.0000000000001
)

Arguments

probs

Genotype probabilities, as calculated from calc_genoprob().

map

Map of pseudomarkers in probs. Used only if chr and pos are provided.

minprob

Minimum probability for making a call. If maximum probability is less then this value, give NA.

chr

If provided (along with pos), consider only the single specified position.

pos

If provided (along with chr), consider only the single specified position.

return_char

If TRUE, return genotype names as character strings.

quiet

IF FALSE, print progress messages.

cores

Number of CPU cores to use, for parallel calculations. (If 0, use parallel::detectCores().) Alternatively, this can be links to a set of cluster sockets, as produced by parallel::makeCluster().

tol

Tolerance value; genotypes with probability that are within tol of each other are treated as equivalent.

Details

If multiple genotypes share the maximum probability, one is chosen at random.

Value

If chr and pos are provided, a vector of genotypes is returned. In this case, map is needed.

Otherwise, the result is a object like that returned by viterbi(), A list of two-dimensional arrays of imputed genotypes, individuals x positions. Also includes these attributes:

  • crosstype - The cross type of the input cross.

  • is_x_chr - Logical vector indicating whether chromosomes are to be treated as the X chromosome or not, from input cross.

  • alleles - Vector of allele codes, from input cross.

See Also

sim_geno(), viterbi()

Examples

# load data and calculate genotype probabilities
iron <- read_cross2(system.file("extdata", "iron.zip", package="qtl2"))
pr <- calc_genoprob(iron, error_prob=0.002)

# full set of imputed genotypes
ginf <- maxmarg(pr)

# imputed genotypes at a fixed position
g <- maxmarg(pr, iron$gmap, chr=8, pos=45.5)

# return genotype names rather than integers
g <- maxmarg(pr, iron$gmap, chr=8, pos=45.5, return_char=TRUE)

qtl2 documentation built on May 29, 2024, 11:46 a.m.