Learn R Programming

mmod (version 0.2.1)

rgenotypes: Randomly create genotypes

Description

Use the multinomial distribution to randomly create genotpes for individuals for given allele frequences.

Usage

rgenotypes(n, ploidy, probs)

Arguments

n
integer number of indviduals
ploidy
integer number of alleles to asign to each indivudal
probs
vector of probabilies corresponding to allele frequences

Value

  • A matrix with individuals in columns, alleles in rows

Details

Used in chao_bootstrap, also exported as it may come in handy for other simulations

See Also

rmultinom which this function wraps

Examples

Run this code
data(nancycats)
obs_allele_freqs <- apply(nancycats$tab[,1:16], 2,mean)
rgenotypes(10, 2, obs_allele_freqs)
obs_allele_freqs_noNA <- apply(nancycats$tab[,1:16], 2,mean, na.rm=TRUE)
rgenotypes(10, 2, obs_allele_freqs_noNA)

Run the code above in your browser using DataLab