profileSim: Simulation of complete DNA profiles

View source: R/profileSim.R

profileSimR Documentation

Simulation of complete DNA profiles

Description

Simulation of DNA profiles for specified pedigree members. Some pedigree members may already be genotyped; in that case the simulation is conditional on these. The main work of this function is done by markerSim().

Usage

profileSim(
  x,
  N = 1,
  ids = NULL,
  markers = NULL,
  seed = NULL,
  numCores = 1,
  simplify1 = TRUE,
  verbose = TRUE,
  ...
)

Arguments

x

A ped object or a list of such.

N

The number of complete simulations to be performed.

ids

A character (or coercible to character) with ID labels indicating whose genotypes should be simulated.

markers

Either a vector indicating a subset of markers attached to x, or a named list of frequency vectors. By default (NULL), all attached markers are used. If a frequency list is given, marker objects are created and attached to x. Simulations are conditional on the locus attributes (allele frequencies, mutation models, etc) and any existing genotypes in the indicated markers.

seed

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

numCores

The number of cores to be used. The default is 1, i.e., no parallelisation.

simplify1

A logical, by default TRUE, removing the outer list layer when N = 1. See Value.

verbose

A logical, by default TRUE.

...

Further arguments passed on to markerSim().

Value

A list of N objects similar to x, but with simulated genotypes. Any previously attached markers are replaced by the simulated profiles. If the indicated markers contained genotypes for some pedigree members, these are still present in the simulated profiles.

If N = 1 and simplify1 = TRUE, the outer list layer is removed, i.e., profileSim(..., N = 1, simplify1 = T) is equivalent to profileSim(..., N = 1, simplify1 = F)[[1]]. This is usually the desired object in interactive use, and works well with piping.

When using profileSim() in other functions, it is recommended to add simplify1 = FALSE to safeguard against issues with N = 1.

Examples

# Example pedigree with two brothers
x = nuclearPed(children = c("B1", "B2"))

### Simulate profiles using built-in freq database
profileSim(x, markers = NorwegianFrequencies[1:3])

### Conditioning on known genotypes for one brother

# Attach two SNP markers with genotypes for B1
y = x |>
  addMarker(B1 = "1/2", alleles = 1:2) |>
  addMarker(B1 = "1",   alleles = 1:2, chrom = "X")

# Simulate 2 profiles of B2 conditional on the above
profileSim(y, N = 2, ids = "B2", seed = 123)




forrel documentation built on Nov. 19, 2023, 5:14 p.m.