infer_mixture {rubias} | R Documentation |
Estimate mixing proportions and origin probabilities from one or several mixtures
Description
Takes a mixture and reference dataframe of two-column genetic data, and a desired method of estimation for the population mixture proportions (MCMC, PB, BR). Returns the output of the chosen estimation method
Usage
infer_mixture(
reference,
mixture,
gen_start_col,
method = "MCMC",
alle_freq_prior = list(const_scaled = 1),
pi_prior = NA,
pi_init = NULL,
reps = 2000,
burn_in = 100,
pb_iter = 100,
prelim_reps = NULL,
prelim_burn_in = NULL,
sample_int_Pi = 1,
sample_theta = TRUE,
pi_prior_sum = 1
)
Arguments
reference |
a dataframe of two-column genetic format data, proceeded by "repunit", "collection", and "indiv" columns. Does not need "sample_type" column, and will be overwritten if provided |
mixture |
a dataframe of two-column genetic format data. Must have the same structure as
|
gen_start_col |
the first column of genetic data in both data frames |
method |
a choice between "MCMC", "PB", "BR" methods for estimating mixture proportions |
alle_freq_prior |
a one-element named list specifying the prior to be used when
generating Dirichlet parameters for genotype likelihood calculations. Valid methods include
|
pi_prior |
The prior to be added to the collection allocations, in order to generate pseudo-count
Dirichlet parameters for the simulation of new pi vectors in MCMC. Default value of NA leads to the
calculation of a symmetrical prior based on |
pi_init |
The initial value to use for the mixing proportion of collections. This lets the user start the chain from a specific value of the mixing proportion vector. If pi_init is NULL (the default) then the mixing proportions are all initialized to be equal. Otherwise, you pass in a data frame with one column named "collection" and the other named "pi_init". Every value in the pi_init column must be strictly positive (> 0), and a value must be given for every collection. If they sum to more than one the values will be normalized to sum to one. |
reps |
the number of iterations to be performed in MCMC |
burn_in |
how many reps to discard in the beginning of MCMC when doing the mean calculation. They will still be returned in the traces if desired. |
pb_iter |
how many bootstrapped data sets to do for bootstrap correction using method PB. Default is 100. |
prelim_reps |
for method "BR", the number of reps of conditional MCMC (as in method "MCMC")
to perform prior to MCMC with baseline resampling. The posterior mean of mixing proportions
from this conditional MCMC is then used as |
prelim_burn_in |
for method "BR", this sets the number of sweeps out of |
sample_int_Pi |
how many iterations between storing the mixing proportions trace. Default is 1. Can't be 0. Can't be so large that fewer than 10 samples are taken from the burn in and the sweeps. |
sample_theta |
for method "BR", whether or not the function should store the posterior mean of the updated allele frequences. Default is TRUE |
pi_prior_sum |
For |
Details
"MCMC" estimates mixing proportions and individual posterior probabilities of assignment through Markov-chain Monte Carlo conditional on the reference allele frequencies, while "PB" does the same with a parametric bootstrapping correction, and "BR" runs MCMC sweeps while simulating reference allele frequencies using the genotypes of mixture individuals and allocations from the previous sweep. All methods default to a uniform 1/(# collections or RUs) prior for the mixing proportions.
Value
Tidy data frames in a list with the following components: mixing_proportions: the estimated mixing proportions of the different collections. indiv_posteriors: the posterior probs of fish being from each of the collections. mix_prop_traces: the traces of the mixing proportions. Useful for computing credible intervals. bootstrapped_proportions: If using method "PB" this returns the bootstrap corrected reporting unit proportions.
Examples
mcmc <- infer_mixture(reference = small_chinook_ref,
mixture = small_chinook_mix,
gen_start_col = 5,
method = "MCMC",
reps = 200)