Learn R Programming

bnpsd (version 1.0.4)

q1d: Construct admixture proportion matrix for 1D geography

Description

Assumes \(k\) intermediate subpopulations placed along a line at locations \(1:k\) spread by random walks, then \(n\) individuals sampled equally spaced in \([a,b]\) (default \([0.5, k+0.5]\)) draw their admixture proportions relative to the Normal density that models the random walks of each of these intermediate subpopulations. The spread of the random walks (the \(\sigma\) of the Normal densities) is set to sigma if not missing, otherwise \(\sigma\) is found numerically to give the desired bias coefficient s, the vector F of \(F_{ST}\)'s for the intermediate subpopulations up to a scalar factor, and the final \(F_{ST}\) of the admixed individuals (see details below).

Usage

q1d(n, k, sigma, a = 0.5, b = k + 0.5, s, F, Fst, interval = c(0.1,
  10), tol = .Machine$double.eps)

Arguments

n

Number of individuals

k

Number of intermediate subpopulations

sigma

Spread of intermediate subpopulations (standard deviation of normal densities)

a

Location of first individual

b

Location of last individual

OPTIONS FOR BIAS COEFFICIENT VERSION

s

The desired bias coefficient, which specifies \(\sigma\) indirectly. Required if sigma is missing

F

The length-\(k\) vector of inbreeding coefficients (or \(F_{ST}\)'s) of the intermediate subpopulations, up to a scaling factor (which cancels out in calculations). Required if sigma is missing

Fst

The desired final \(F_{ST}\) of the admixed individuals. Required if sigma is missing

interval

Restrict the search space of \(\sigma\) to this interval

tol

The numerical tolerance used to declare the solution found

Value

If sigma was provided, the \(n \times k\) admixture proportion matrix \(Q\). If sigma is missing, a named list is returned containing Q, the rescaled F, and the sigma that together give the desired \(s\) and final \(F_{ST}\) of the admixed individuals.

Details

When sigma is missing, the function determines its value using the desired s, F up to a scalar factor, and Fst. Uniform weights for the final generalized \(F_{ST}\) are assumed. The scaling factor of the input F is irrelevant because it cancels out in s; after sigma is found, F is rescaled to give the desired final \(F_{ST}\). However, the function stops with a fatal error if the rescaled F takes on any values greater than 1, which are not allowed since F are IBD probabilities.

Examples

Run this code
# NOT RUN {
## admixture matrix for 1000 individuals drawing alleles from 10 subpops
## and a spread of 2 standard deviations along the 1D geography
Q <- q1d(n=1000, k=10, sigma=2)

## a similar model but with a bias coefficient "s" of exactly 1/2
k <- 10
F <- 1:k # Fst vector for intermediate subpops, up to a factor (will be rescaled below)
Fst <- 0.1 # desired final Fst of admixed individuals
obj <- q1d(n=1000, k=k, s=0.5, F=F, Fst=Fst)
## in this case return value is a named list with three items:
Q <- obj$Q # admixture proportions
F <- obj$F # rescaled Fst vector for intermediate subpops
sigma <- obj$sigma # and the sigma that gives the desired s and final Fst

# }

Run the code above in your browser using DataLab