rmbayes {hwep} | R Documentation |
Bayes test for random mating with known genotypes
Description
Bayes test for random mating with known genotypes
Usage
rmbayes(
nvec,
lg = TRUE,
alpha = NULL,
beta = NULL,
nburn = 10000,
niter = 10000,
type = c("auto", "allo")
)
Arguments
nvec |
A vector containing the observed genotype counts,
where |
lg |
A logical. Should we return the log Bayes factor ( |
alpha |
The concentration hyperparameters of the gamete frequencies under the null of random mating. Should be length ploidy/2 + 1. |
beta |
The concentration hyperparameters of the genotype frequencies under the alternative of no random mating. Should be length ploidy + 1. |
nburn |
The number of iterations in the Gibbs sampler to burn-in. |
niter |
The number of sampling iterations in the Gibbs sampler. |
type |
If |
Author(s)
David Gerard
References
Gerard D (2022). "Bayesian tests for random mating in autopolyploids." bioRxiv. doi:10.1101/2022.08.11.503635.
Examples
set.seed(1)
ploidy <- 8
## Simulate under the null
p <- stats::runif(ploidy / 2 + 1)
p <- p / sum(p)
q <- stats::convolve(p, rev(p), type = "open")
## See BF increase
nvec <- c(stats::rmultinom(n = 1, size = 100, prob = q))
rmbayes(nvec = nvec)
nvec <- c(stats::rmultinom(n = 1, size = 1000, prob = q))
rmbayes(nvec = nvec)
nvec <- c(stats::rmultinom(n = 1, size = 10000, prob = q))
rmbayes(nvec = nvec)
## Simulate under the alternative
q <- stats::runif(ploidy + 1)
q <- q / sum(q)
## See BF decrease
nvec <- c(stats::rmultinom(n = 1, size = 100, prob = q))
rmbayes(nvec = nvec)
nvec <- c(stats::rmultinom(n = 1, size = 1000, prob = q))
rmbayes(nvec = nvec)
nvec <- c(stats::rmultinom(n = 1, size = 10000, prob = q))
rmbayes(nvec = nvec)