rgenotypes(n, ploidy, probs, genind = FALSE, pop_name = "A", loc_name = "L1")
Either a matrix with individuals in columns, alleles in rows or, if genind is TRUE a genind object for one population and locus.
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).
Used in chao_bootstrap
, also exported as it
may come in handy for other simulations.
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
rmultinom
which this function wraps.