blockSim: Perform relatives simulations using large memory blocks in C

View source: R/blockSim.R

blockSimR Documentation

Perform relatives simulations using large memory blocks in C

Description

Generate N pairs with a given relationship, calculate the LR for sibs, parent-child and the number of matching alleles and count the number of pairs that meet the threshold criteria.

Usage

blockSim(
  N,
  Freqs,
  rel = "UN",
  ibsthresh = NULL,
  kithresh = NULL,
  code = 1,
  falseNeg = TRUE,
  BlockSize = N/10,
  showProgress = FALSE
)

Arguments

N

The number of iterations to carry out

Freqs

A list containing two lists labelled loci and freqs. The second list is a list of vectors containing the allele frequencies of each allele at each locus in the multiplex.

rel

generate unrelated (rel = 'UN'), full-sibs (rel = 'FS'), or parent child (rel = 'PC') pairs

ibsthresh

A vector of one or more IBS thresholds

kithresh

A vector of one or more KI/LR thresholds

code

A code from 1 to 6 which dictates the events that will be counted.

  1. the LR for siblings will be compared to the values in kithresh and incremented if the LR is greater than the threshold

  2. the LR for parent/child will be compared to the values in kithresh and incremented if the LR is greater than the threshold

  3. the number of matching alleles (IBS) will be compared to the values in ibsthresh and incremented if the IBS is greater than the threshold

  4. the LR for siblings and the number of matching alleles will be compared to the values in kithresh and ibsthresh and incremented if both the LR and IBS is greater than the thresholds. ibsthresh and kithresh must be of equal length for this option to work

  5. the LR for parent/child and the number of matching alleles will be compared to the values in kithresh and ibsthresh and incremented if both the LR and IBS is greater than the thresholds. ibsthresh and kithresh must be of equal length for this option to work

  6. this option is equivalent to performing code 4 and 5 simulataneously. It is not currently implemented

falseNeg

if TRUE then the number of results that DO NOT satisfy the conditions are counted, otherwise the number of results DO satisfy the conditions are counted

BlockSize

Sets the number of random profiles to be generated in each iteration. By default the block size is set to 10 percent of the total sample size. It is unclear whether the procedure is more efficient if a bigger percentage of the total is used. Users must take care to make sure that the block size evenly divides N otherwise the procedure will exit. Users must also make sure that they have enough memory.

showProgress

If TRUE then a progress bar will be displayed in the console showing the progress of the simulation.

Details

This function is used for fast accurate estimation of false positive and false negative rates. It achieves part of its speed by block exectution in C, and part by not saving the LR or IBS results. It can do 1 billion iterations in about an hour.

Value

A vector containing the number of profile pairs that satisfied the threshold conditions

Author(s)

James M. Curran

See Also

sim

Examples


## not run
## this counts the number of unrelated pairs that are falsely identified
## as siblings using the policy that there are 16 or more matching
## alleles, and the LR/KI is greater than 100,000
## this is a very rare event for the FBI Caucasians with a frequency of
## about 4-5 times in 10 million pairs
## Not run: 
data(fbiCaucs)
N = 1e8
ki = 1e5
ibs = 16
code = 5
BlockSize = 1e6
blockSim(N, fbiCaucs, rel = "UN", ibsthresh = ibs, kithresh = ki,
         code = code, falseNeg = FALSE, BlockSize = BlockSize)

## End(Not run)

jmcurran/relSim documentation built on Jan. 13, 2024, 2:13 a.m.