Learn R Programming

forrel (version 1.1.0)

markerSimParametric: 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")
)

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

NULL, or a numeric seed for the random number generator.

returnValue

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

Value

If returnValue == "singleton", a list of two singletons with the simulated marker data attached.

If returnValue == "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.

If returnValue == "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".

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 = T, 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 = T, prob = delta).

Examples

Run this code
# NOT RUN {
# 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)

# }

Run the code above in your browser using DataLab