pr.next.allele: Probability of seeing next allele (Dirichlet sampling)

Description Usage Arguments Details Value See Also Examples

Description

Probability of seeing next allele (Dirichlet sampling)

Usage

1
pr.next.allele(i, seen, fr, theta = 0)

Arguments

i

Integer (vector), allele number

seen

Integer matrix with alleles already seen

fr

Numeric vector with allelic proportions

theta

Numeric giving the inbreeding coefficient

Details

When a population is subdivided into subpopulations, consecutively sampled alleles are not independent draws. This function implements the Dirichlet formula which states that after sampling n alleles, of which m are of type A_i, the probability that the next allele is of type A_i equals:

(m*θ+(1-θ)*p_i)/(1+(n-1)*θ)

The alleles already sampled are passed as the rows of the matrix seen, while the corresponding element of i specifies for which next allele the probability of sampling is computed. The length of i has to be equal to the number of rows of seen.

Value

numeric (vector) of probabilities

See Also

pr.next.alleles, rmp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# theta=0 means independent sampling, so after seeing
# allele 1 three times the pr. remains 1/2
pr.next.allele(1,seen=matrix(c(1,1,1),nrow=1),fr=c(1/2,1/2),theta=0)
# theta>0 slighly increases the pr. of
# seeing the same allele again
pr.next.allele(1,seen=matrix(c(1,1,1),nrow=1),fr=c(1/2,1/2),theta=0.05)

# the function also works on vectors
# after seeing 1,1,1, the pr. of 1 remains 1/2
# and the same applies to the pr. of 2 after 2,2,1
pr.next.allele(c(1,2),seen=matrix(c(1,1,1,2,2,1),nrow=2,byrow=TRUE),fr=c(1/2,1/2),theta=0)
pr.next.allele(c(1,2),seen=matrix(c(1,1,1,2,2,1),nrow=2,byrow=TRUE),fr=c(1/2,1/2),theta=0.05)

DNAprofiles documentation built on Jan. 15, 2017, 9:27 p.m.