sim_gen_phen: Simulate genotypes and phenotypes

View source: R/sim_gen_phen.R

sim_gen_phenR Documentation

Simulate genotypes and phenotypes

Description

Simulate entire parameters and random variables, particularly random genotypes and phenotypes, with desired dimensions and other base parameters.

Usage

sim_gen_phen(
  n_ind = 1000,
  m_loci = 1e+05,
  k_subpops = 3,
  fst = 0.3,
  bias_coeff = 0.5,
  G = 1,
  m_causal = 100,
  herit = 0.8,
  env = NA,
  env_var = 1,
  fes = FALSE,
  n_chr = 22,
  beta = NA,
  verbose = TRUE
)

Arguments

n_ind

The number of individuals.

m_loci

The number of loci.

k_subpops

The number of intermediate subpopulations for admixture model.

fst

The FST of the admixed individuals (for the founders if G > 1).

bias_coeff

The bias coefficient of the admixed individuals (for the founders if G > 1).

G

The number of generations for random family. The G = 1 case is no family structure (just admixture). For G > 1 first admixed founders are simulated, then the family structure is simulated from them.

m_causal

The number of causal loci for the trait, selected randomly from among the simulated loci.

herit

The trait heritability.

env

A string describing environment model. Only NA (no environment) or "gcta" are accepted.

env_var

The variance of the environment effect. Ignored if env is NA.

fes

If FALSE (default) constructs trait from Random Coefficients (RC) model. If TRUE, the Fixed Effect Sizes (FES) model is used instead.

n_chr

Number of chromosomes to simulate. Chromosome assignments are not biologically meaningful, as all loci are drawn independently (no LD).

beta

Shape parameter for a symmetric Beta for ancestral allele frequencies p_anc. If NA (default), p_anc is uniform with range in [0.01, 0.5]. Otherwise, p_anc has a symmetric Beta distribution with range in [0, 1].

verbose

If TRUE reports progress, otherwise it is silent.

Value

A list containing the following elements:

  • X: The simulated genotype matrix.

  • bim: The variant info table.

  • p_anc: The ancestral allele frequency vector (aligned with rows of X).

  • kinship: The true kinship of the joint admixed family model (final generation only).

  • admix_proportions: The true admixture proportions of the joint admixed family model (final generation only).

  • trait: The simulated trait vector.

  • causal_indexes: The vector of randomly selected causal loci indexes.

  • causal_coeffs: The vector of simulated regression coefficients for causal loci.

See Also

This function is a wrapper around sim_pop(), sim_geno(), sim_bim(), and sim_trait_env(), see those for more details.

Examples

# run with default values, except smaller
data <- sim_gen_phen( n_ind = 50, G = 3, m_loci = 100, m_causal = 5 )

# main objects of interest:
# genotype matrix
data$X
# trait vector
data$trait


OchoaLab/simgenphen documentation built on Feb. 10, 2023, 3:32 p.m.