Randomly create genotypes

Usage

rgenotypes(n, ploidy, probs, genind = FALSE, pop_name = "A", loc_name = "L1")

Arguments

n
integer number of indviduals.
ploidy
integer number of alleles to asign to each individual.
probs
vector of probabilies corresponding to allele frequences.
genind
boolean if TRUE return a genind object
pop_name
charcter Name for population defined in genind object (not required if genind is not TRUE)
loc_name
character name to five locus in genind object

Value

Either a matrix with individuals in columns, alleles in rows or, if genind is TRUE a genind object for one population and locus.

Description

Use the multinomial distribution to randomly create genotpes for individuals for given allele frequences. By default this function returns a matrix of with alleles in rows and individuals in columns. There is an option to return a genind object representing the same data (see examples).

Details

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

Examples

data(nancycats) obs_allele_freqs <- apply(nancycats$tab[,1:16], 2,mean, na.rm=TRUE) rgenotypes(10, 2, obs_allele_freqs)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] L1.01 0 0 0 0 0 0 0 0 0 0 L1.02 0 1 0 0 0 0 0 0 0 0 L1.03 0 0 0 0 0 0 0 0 0 0 L1.04 0 0 2 1 0 0 0 0 0 0 L1.05 0 0 0 0 0 0 0 0 0 0 L1.06 0 0 0 1 0 0 0 0 0 0 L1.07 0 0 0 0 0 0 0 0 0 0 L1.08 0 1 0 0 1 0 0 0 0 0 L1.09 0 0 0 0 1 1 0 1 2 0 L1.10 1 0 0 0 0 0 2 1 0 1 L1.11 1 0 0 0 0 0 0 0 0 0 L1.12 0 0 0 0 0 0 0 0 0 0 L1.13 0 0 0 0 0 1 0 0 0 1 L1.14 0 0 0 0 0 0 0 0 0 0 L1.15 0 0 0 0 0 0 0 0 0 0 L1.16 0 0 0 0 0 0 0 0 0 0

See also

rmultinom which this function wraps.