Simulate biallelic data from a simple statistical model. Inputs include the complexity of infection and some parameters dictating skew and error distributions. Outputs include the phased haplotypes and the un-phased read count and coverage data.
integer vector of the number of haplotypes within each sample.
matrix of haplotypes that correspond to within individual COI.
the alpha value for the beta binomial distribution, which the population-allele frequency for each allele is drawn from.
the beta value for the beta binomial distribution, which the population-allele frequency for each allele is drawn from.
coverage at each locus. If a single value then the same coverage is applied over all loci.
shape parameter of the symmetric Dirichlet prior on strain proportions.
the extent to which counts are over-dispersed relative
to the binomial distribution. Counts are Beta-binomially distributed, with
the beta distribution having shape parameters p/overdispersion and
(1-p)/overdispersion.
the probability of a single read being mis-called as the other allele. Applies in both directions.
List of non-referent within-sample allele frequency dataframe (unphased) and phased vectors of non-referent within-sample allele counts, overall coverage, strain proportions, and the biallelic haplotype matrix.
Simulated data are drawn from a simple statistical model:
Strain proportions are drawn from a symmetric Dirichlet
distribution with shape parameter alpha.
Phased haplotypes are drawn at every locus, one for each
COI. The allele at each locus is drawn from a Bernoulli
distribution with probability given by the PLAF.
The "true" within-sample allele frequency at every locus is
obtained by multiplying haplotypes by their strain proportions, and
summing over haplotypes. Errors are introduced through the equation
$$wsaf_{error} = wsaf*(1-e) + (1-wsaf)*e$$ where \(wsaf\) is the WSAF
without error and \(e\) is the error parameter epsilon.
Final read counts are drawn from a beta-binomial distribution with
expectation \(w_{error}\). The raw number of draws is given by the
coverage, and the skew of the distribution is given by the
overdispersion parameter. If overdispersion = 0 then the
distribution is binomial, rather than beta-binomial.