Description Usage Arguments Details Value Examples
View source: R/admix_prop_1d_circular.R
Assumes k_subpops
intermediate subpopulations placed along a circumference (the [0
, 2 * pi
] line that wraps around) with even spacing spread by random walks (see details below), then n_ind
individuals sampled equally spaced in [coord_ind_first
,coord_ind_last
] (default [0
, 2 * pi
] with a small gap so first and last individual do not overlap) draw their admixture proportions relative to the Von Mises density that models the random walks of each of these intermediate subpopulations.
The spread of the random walks is sigma = 1 / sqrt(kappa)
of the Von Mises density.
If sigma
is missing, it can be set indirectly by providing three variables: (1) the desired bias coefficient bias_coeff
, (2) the coancestry matrix of the intermediate subpopulations coanc_subpops
(up to a scalar factor), and (3) the final fst
of the admixed individuals (see details below).
1 2 3 4 5 6 7 8 9 10 |
n_ind |
Number of individuals |
k_subpops |
Number of intermediate subpopulations |
sigma |
Spread of intermediate subpopulations (approximate standard deviation of Von Mises densities, see above)
The edge cases |
coord_ind_first |
Location of first individual |
coord_ind_last |
Location of last individual OPTIONS FOR BIAS COEFFICIENT VERSION |
bias_coeff |
If |
coanc_subpops |
If |
fst |
If |
Assuming the full range of [0
, 2 * pi
] is considered, and the first and last individuals do not overlap, the gap between individuals is delta = 2 * pi / n
.
To not have any individuals on the edge, we place the first individual at delta / 2
and the last at 2 * pi - delta / 2
.
The location of subpopulation j
is delta / 2 + ( j - 1/2 ) / k * (2 * pi - delta)
, chosen to agree with the default correspondence between individuals and subpopulations of the linear 1D geography admixture scenario (admix_prop_1d_linear()
).
If sigma
is NA
, its value is determined from the desired bias_coeff
, coanc_subpops
up to a scalar factor, and fst
.
Uniform weights for the final generalized FST are assumed.
The scale of coanc_subpops
is irrelevant because it cancels out in bias_coeff
; after sigma
is found, coanc_subpops
is rescaled to give the desired final FST.
However, the function stops if any rescaled coanc_subpops
values are greater than 1, which are not allowed since they are IBD probabilities.
If sigma
was provided, returns the n_ind
-by-k_subpops
admixture proportion matrix (admix_proportions
).
If sigma
is missing, returns a named list containing:
admix_proportions
: the n_ind
-by-k_subpops
admixture proportion matrix.
If coanc_subpops
had names, they are copied to the columns of this matrix.
coanc_subpops
: the input coanc_subpops
rescaled.
sigma
: the fit value of the spread of intermediate subpopulations
coanc_factor
: multiplicative factor used to rescale coanc_subpops
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # admixture matrix for 1000 individuals drawing alleles from 10 subpops
# simple version: spread of about 2 standard deviations along the circular 1D geography
# (just set sigma)
admix_proportions <- admix_prop_1d_circular(n_ind = 1000, k_subpops = 10, sigma = 2)
# advanced version: a similar model but with a bias coefficient of exactly 1/2
# (must provide bias_coeff, coanc_subpops, and fst in lieu of sigma)
k_subpops <- 10
# FST vector for intermediate independent subpops, up to a factor (will be rescaled below)
coanc_subpops <- 1 : k_subpops
obj <- admix_prop_1d_circular(
n_ind = 1000,
k_subpops = k_subpops,
bias_coeff = 0.5,
coanc_subpops = coanc_subpops,
fst = 0.1 # desired final FST of admixed individuals
)
# in this case return value is a named list with three items:
admix_proportions <- obj$admix_proportions
# rescaled coancestry data (matrix or vector) for intermediate subpops
coanc_subpops <- obj$coanc_subpops
# and the sigma that gives the desired bias_coeff and final FST
sigma <- obj$sigma
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.