Bayes test for random mating using genotype log-likelihoods
A matrix of genotype log-likelihoods. The rows index the
individuals and the columns index the genotypes. So gl[i,k]
is the genotype log-likelihood for individual i
at
dosage k-1
. We assume the natural log is used (base e).
Should we use Stan ("stan"
) or Gibbs sampling
("gibbs"
)?
A logical. Should we return the log Bayes factor (TRUE
)
or the Bayes factor (FALSE
)?
The concentration hyperparameters of the gamete frequencies under the null of random mating. Should be length ploidy/2 + 1.
The concentration hyperparameters of the genotype frequencies under the alternative of no random mating. Should be length ploidy + 1.
If alpha
is NULL
, then the default priors depend
on if you have autopolyploids ("auto"
) or allopolyploids
("allo"
).
Number of MCMC chains. Almost always 1 is enough, but we use 2 as a default to be conservative.
Number of cores to use.
Total number of iterations.
Number of those iterations used in the burnin.
Control arguments passed to sampling()
.
Gerard D (2023). "Bayesian tests for random mating in polyploids." Molecular Ecology Resources, In press. doi:10.1111/1755-0998.13856 .
if (FALSE) {
set.seed(1)
ploidy <- 4
## Simulate under the null ----
p <- stats::runif(ploidy / 2 + 1)
p <- p / sum(p)
q <- stats::convolve(p, rev(p), type = "open")
## See BF increases
nvec <- c(stats::rmultinom(n = 1, size = 10, prob = q))
gl <- simgl(nvec = nvec)
rmbayesgl(gl = gl)
rmbayesgl(gl = gl, method = "gibbs")
nvec <- c(stats::rmultinom(n = 1, size = 100, prob = q))
gl <- simgl(nvec = nvec)
rmbayesgl(gl = gl)
rmbayesgl(gl = gl, method = "gibbs")
nvec <- c(stats::rmultinom(n = 1, size = 1000, prob = q))
gl <- simgl(nvec = nvec)
rmbayesgl(gl = gl)
rmbayesgl(gl = gl, method = "gibbs")
## Simulate under the alternative ----
q <- stats::runif(ploidy + 1)
q <- q / sum(q)
## See BF decreases
nvec <- c(stats::rmultinom(n = 1, size = 10, prob = q))
gl <- simgl(nvec = nvec)
rmbayesgl(gl = gl)
rmbayesgl(gl = gl, method = "gibbs")
nvec <- c(stats::rmultinom(n = 1, size = 100, prob = q))
gl <- simgl(nvec = nvec)
rmbayesgl(gl = gl)
rmbayesgl(gl = gl, method = "gibbs")
nvec <- c(stats::rmultinom(n = 1, size = 1000, prob = q))
gl <- simgl(nvec = nvec)
rmbayesgl(gl = gl)
rmbayesgl(gl = gl, method = "gibbs")
}