Learn R Programming

DNAprofiles (version 0.3.1)

sample.pairs: Sample random profile pairs with given relationship (sibs, parent/offspring, etc.)

Description

Sample random profile pairs with given relationship (sibs, parent/offspring, etc.)

Usage

sample.pairs(N = 1, type = "FS", freqs, markers = names(freqs))

Arguments

N
The number of pairs to be sampled (integer).
type
A character string giving the type of relative. Should be one of ibdprobs, e.g. "FS" (full sibling) or "PO" (parent/offspring) or "UN" (unrelated).
freqs
A list specifying the allelic frequencies. Should contain a vector of allelic frequencies for each locus, named after that locus.
markers
A character vector naming the markers of the resulting sample. Default to all markers of the freqs argument.

Value

A list containing two integer matrices of class profiles:
  1. x1 An integer matrix with $N$ profiles.
  2. x2 An integer matrix with $N$ profiles.

Details

The function randomly samples $N$ pairs of DNA profiles according to the specified allelic frequencies. It returns two matrices containing profiles. The $i$'th profile in the first and the second matrix are sampled as relatives.

See Also

sample.profiles, sample.relatives,ki,ibs.pairs

Examples

Run this code
## Compare the number of IBS alleles of simulated parent/offspring pairs
## with simulated unrelated pairs

data(freqsNLsgmplus)

#sample PO pairs and UN pairs
po.pairs <- sample.pairs(N=10^4,"PO",freqsNLsgmplus)
unr.pairs <- sample.pairs(N=10^4,"UN",freqsNLsgmplus)

#count the IBS alleles
po.pairs.ibs <- ibs.pairs(x1=po.pairs$x1,x2=po.pairs$x2)
unr.pairs.ibs <- ibs.pairs(x1=unr.pairs$x1,x2=unr.pairs$x2)

#plot together in a histogram
hist(po.pairs.ibs$ibs,breaks=0:20,xlim=c(0,20),
col="#FF0000FF",main="PO pairs vs. UN pairs",xlab="IBS")
hist(unr.pairs.ibs$ibs,breaks=0:20,col="#0000FFBB",add=TRUE)

Run the code above in your browser using DataLab