Learn R Programming

bnpsd (version 1.1.1)

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(coancestry)

Arguments

coancestry

The \(n \times n\) coancestry matrix

Value

The \(n \times n\) kinship matrix, preserving column and row names.

See Also

The inverse function is given by inbr_diag.

Examples

Run this code
# NOT RUN {
# a trivial case: unadmixed individuals from independent subpopulations
# number of individuals/subpops
n_ind <- 5
# unadmixed individuals
admix_proportions <- diag(rep.int(1, n_ind))
# equal Fst for all subpops
inbr_subpops <- 0.2
# diagonal coancestry matryx
coancestry <- coanc_admix(admix_proportions, inbr_subpops)
kinship <- coanc_to_kinship(coancestry)

# a more complicated admixture model
# number of individuals
n_ind <- 5
# number of intermediate subpops
k_subpops <- 2
# non-trivial admixture proportions
admix_proportions <- admix_prop_1d_linear(n_ind, k_subpops, sigma = 1)
# different Fst for each of the k subpops
inbr_subpops <- c(0.1, 0.3)
# non-trivial coancestry matrix
coancestry <- coanc_admix(admix_proportions, inbr_subpops)
kinship <- coanc_to_kinship( coancestry )

# }

Run the code above in your browser using DataLab