Learn R Programming

updog (version 1.2.0)

rgeno: Simulate individual genotypes from one of the supported flexdog models.

Description

This will simulate genotypes of a sample of individuals drawn from one of the populations supported by flexdog. See the details of flexdog for the models allowed. These genotype distributions are described in detail in Gerard and Ferr<U+00E3>o (2019).

Usage

rgeno(
  n,
  ploidy,
  model = c("hw", "bb", "norm", "ash", "f1", "s1", "f1pp", "s1pp", "flex", "uniform"),
  allele_freq = NULL,
  od = NULL,
  p1geno = NULL,
  p2geno = NULL,
  mode = NULL,
  pivec = NULL,
  mu = NULL,
  sigma = NULL,
  p1_pair_weights = NULL,
  p2_pair_weights = NULL
)

Arguments

n

The number of observations.

ploidy

The ploidy of the species.

model

What form should the prior take? See Details in flexdog.

allele_freq

If model = "hw", then this is the allele frequency of the population. For any other model, this should be NULL.

od

If model = "bb", then this is the overdispersion parameter of the beta-binomial distribution. See betabinom for details. For any other model, this should be NULL.

p1geno

Either the first parent's genotype if model = "f1" (or model = "f1pp"), or the only parent's genotype if model = "s1" (or model = "s1pp"). For any other model, this should be NULL.

p2geno

The second parent's genotype if model = "f1" (or model = "f1pp"). For any other model, this should be NULL.

mode

If model = "ash", this is the center of the distribution. This should be a non-integer value (so the mode is either the floor or the ceiling of mode). For any other model, this should be NULL.

pivec

A vector of probabilities. If model = "ash", then this represents the mixing proportions of the discrete uniforms. If model = "flex", then element i is the probability of genotype i - 1. For any other model, this should be NULL.

mu

If model = "norm", this is the mean of the normal. For any other model, this should be NULL.

sigma

If model = "norm", this is the standard deviation of the normal. For any other model, this should be NULL.

p1_pair_weights

The mixing weights for the bivalent pairs output in get_bivalent_probs at the lvec level of p1geno. If model = "f1pp" then this is for the first parent. If model = "s1pp", then this is for the only parent. This should be NULL for all other values of model.

p2_pair_weights

If model = "s1pp", these are the mixing weights for the bivalent pairs output in get_bivalent_probs at the lvec level of p2geno for the second parent. This should be NULL for all other values of model.

Value

A vector of length n with the genotypes of the sampled individuals.

Details

The allowable variable values of allele_freq, od, p1geno, p2geno, pivec, and mode varies based on the value of model. If model = "ash", then only mode and pivec can be non-NULL. If model = "flex" then only pivec can be non-NULL. If model = "hw", then only allele_freq can be non-NULL. If model = "f1" then only p1geno and p2geno can be non-NULL. If model = "s1" then only p1geno can be non-NULL. If model = "uniform", then none of the above variables can be non-NULL. If model = "bb", then only allele_freq, and od can be non-NULL. If model == "norm", then only mu and sigma can be non-NULL.

References

  • Gerard, D., Ferr<U+00E3>o, L. F. V., Garcia, A. A. F., & Stephens, M. (2018). Genotyping Polyploids from Messy Sequencing Data. Genetics, 210(3), 789-807. doi: 10.1534/genetics.118.301468.

  • Gerard, D. and Ferr<U+00E3>o, L. F. V. (2019). Priors for Genotyping Polyploids. Bioinformatics. doi: 10.1093/bioinformatics/btz852.

Examples

Run this code
# NOT RUN {
## F1 Population where parent 1 has 1 copy of the referenc allele
## and parent 2 has 4 copies of the reference allele.
ploidy <- 6
rgeno(n = 10, ploidy = ploidy, model = "f1", p1geno = 1, p2geno = 4)

## A population in Hardy-Weinberge equilibrium with an
## allele frequency of 0.75
rgeno(n = 10, ploidy = ploidy, model = "hw", allele_freq = 0.75)

# }

Run the code above in your browser using DataLab