r_cibd {ibdsegments} | R Documentation |
Random generation for IBD on a continuous genome
Description
The r_cibd
function generates random Identity-by-Descent (IBD) segments
along a continuous genome, given a specified pedigree and observed
individuals.
Usage
r_cibd(
n,
pedigree,
ids = pedtools::leaves(pedigree),
states = "ibd",
ibd_state = 1L,
chromosome_length = 267.77
)
Arguments
n |
Number of observations |
pedigree |
Pedigree in |
ids |
Ids for which IBD is observed. Default is |
states |
One of |
ibd_state |
Default is 1. |
chromosome_length |
Default is 267.77 cM (an estimate of the length of chromosome 1). |
Value
A list containing:
samples |
Data frame of simulated IBD segments along the chromosome. |
stats |
Data frame with summary statistics per sample, including total IBD length and the segment count. |
Examples
## Basic example: IBD along one chromosome for half siblings
L <- 300
r_hs <- r_cibd(n = 1e4, pedigree = pedtools::halfSibPed(), chromosome_length = 300)
# half sibs alternate between IBD (state 1) and not IBD (state 0)
head(r_hs$samples)
# the total_length and number of segments per sample are also returned
head(r_hs$stats)
## Comparing half siblings and grandparent-grandchild
r_gp <- r_cibd(n = 1e4, pedigree = pedtools::linearPed(2), ids = c(1, 5),
chromosome_length = 300)
hist(r_gp$stats$total_length)
hist(r_hs$stats$total_length)
[Package ibdsegments version 1.0.1 Index]