Learn R Programming

DNAprofiles (version 0.3.1)

ibs.pairs: Counts IBS alleles between profile pairs

Description

Counts IBS alleles between profile pairs

Usage

ibs.pairs(x1, x2)

Arguments

x1
N profiles
x2
N profiles

Value

Data frame with three columns, containing for each profile pair:
  1. ibs: the number of alleles IBS, ranges from $0$ to $2*nloci$
  2. full.matches: the number of loci for which 2 alleles are IBS, ranges from $0$ to $nloci$
  3. partial.matches: the number of loci for which 1 allele is IBS, ranges from $0$ to $nloci$

Details

A profile consists of two alleles at each locus. When two profiles are compared at a locus, there can be 0, 1 or 2 alleles IBS (identical by state). The function compares two databases of profiles (x1 and x2) and counts the number of IBS alleles between profile pairs. The function expects x1 and x2 to be of equal size.

See Also

ibs.db for comparing one profile against a db

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)
legend("topright",legend=c("PO","UN"),fill=c("red","blue"))

Run the code above in your browser using DataLab