markerSimParametric: Simulate marker data given IBD coefficients

View source: R/pairwiseSim.R

markerSimParametricR Documentation

Simulate marker data given IBD coefficients

Description

This function simulates genotypes for two individuals given their IBD distribution, for N identical markers.

Usage

markerSimParametric(
  kappa = NULL,
  delta = NULL,
  states = NULL,
  N = 1,
  alleles = NULL,
  afreq = NULL,
  seed = NULL,
  returnValue = c("singletons", "alleles", "genotypes", "internal")
)

Arguments

kappa

A probability vector of length 3, giving a set of realised kappa coefficients (between two noninbred individuals).

delta

A probability vector of length 9, giving a set of condensed identity coefficients (Jacquard coefficients).

states

An integer vector of length N, with entries in 1-9. Each entry gives the identity state of the corresponding marker. (See details.)

N

A positive integer: the number of independent markers to be simulated.

alleles

A vector with allele labels. If NULL, the following are tried in order:

  • names(afreq)

  • ‘seq_along(afreq)’

  • 1:2 (fallback if both alleles and afreq are NULL)

afreq

A numeric vector with allele frequencies, possibly named with allele labels.

seed

An integer seed for the random number generator (optional).

returnValue

Either "singleton" (default) or "alleles". (see Value).

Details

Exactly one of kappa, delta and states must be given; the other two should remain NULL.

If states is given, it explicitly determines the condensed identity state at each marker. The states are described by integers 1-9, using the tradition order introduced by Jacquard.

If kappa is given, the states are generated by the command states = sample(9:7, size = N, replace = TRUE, prob = kappa). (Note that identity states 9, 8, 7 correspond to IBD status 0, 1, 2, respectively.)

If delta is given, the states are generated by the command states = sample(1:9, size = N, replace = TRUE, prob = delta).

Value

The output depends on the value of the returnValue parameter:

  • "singletons": a list of two singletons with the simulated marker data attached.

  • "alleles": a list of four vectors of length N, named a, b, c and d. These contain the simulated alleles, where a/b and c/d are the genotypes of the to individuals.

  • "genotypes": a list of two vectors of length N, containing the simulated genotypes. Identical to paste(a, b, sep = "/") and paste(c, d, sep = "/"), where a, b, c, d are the vectors returned when returnValue == "alleles".

  • "internal": similar to "alleles", but using the index integer of each allele. (This option is mostly for internal use.)

Examples

# MZ twins
markerSimParametric(kappa = c(0,0,1), N = 5, alleles = 1:10)

# Equal distribution of states 1 and 2
markerSimParametric(delta = c(.5,.5,0,0,0,0,0,0,0), N = 5, alleles = 1:10)

# Force a specific sequence of states
markerSimParametric(states = c(1,2,7,8,9), N = 5, alleles = 1:10)


forrel documentation built on March 18, 2022, 5:19 p.m.