Learn R Programming

bnpsd (version 1.0.4)

coanc_to_kinship: Transform coancestry matrix to kinship matrix

Description

Let \(\Theta = (\theta_{jk})\) be the coancestry matrix and \(\Phi = (\varphi_{jk})\) be the kinship matrix. These matrices agree off-diagonal, but the diagonal gets transformed as $$\phi_{jj} = \frac{1 + \theta_{jj}}{2}.$$ Below \(n\) is the number of individuals.

Usage

coanc_to_kinship(Theta)

Arguments

Theta

The \(n \times n\) coancestry matrix

Value

The \(n \times n\) kinship matrix

Details

This function starts by copying the input matrix, so it preserves column and row names.

Note that this function is the inverse of popkin::inbrDiag

Examples

Run this code
# NOT RUN {
# a trivial case: unadmixed individuals from independent subpopulations
n <- 5 # number of individuals/subpops
Q <- diag(rep.int(1, n)) # unadmixed individuals
F <- 0.2 # equal Fst for all subpops
Theta <- coanc(Q, F) # diagonal coancestry matryx
Phi <- coanc_to_kinship(Theta)

# a more complicated admixture model
n <- 5 # number of individuals
k <- 2 # number of intermediate subpops
sigma <- 1 # dispersion parameter of intermediate subpops
Q <- q1d(n, k, sigma) # non-trivial admixture proportions
F <- c(0.1, 0.3) # different Fst for each of the k subpops
Theta <- coanc(Q, F) # non-trivial coancestry matrix
Phi <- coanc_to_kinship(Theta)

# }

Run the code above in your browser using DataLab