sim_geno: Simulate genotypes from an admixed family structure

View source: R/sim_geno.R

sim_genoR Documentation

Simulate genotypes from an admixed family structure

Description

This function draws genotypes from an admixture model and optionally propagates them through a pedigree. The admixture genotypes are calculated using bnpsd::draw_all_admix() and simply returned if fam is NULL. If fam is not NULL, genotypes are propagated through the pedigree using simfam::geno_last_gen(). The admixture model by default redraws fixed loci from the model. However, loci may become fixed after propagation through the pedigree. This function identifies these fixed loci (using bnpsd::fixed_loci()) and redraws them first from the admixture model and then through the pedigree, iterating until no loci are fixed.

Usage

sim_geno(
  admix_proportions_1,
  inbr_subpops,
  fam = NULL,
  ids = NULL,
  m_loci = 1e+05,
  p_anc = NULL,
  beta = NA,
  verbose = TRUE
)

Arguments

admix_proportions_1

The admixture proportions matrix of the founders (required to draw the founder genotypes from the admixture model).

inbr_subpops

The vector of intermediate subpopulation inbreeding/FST values for admixture model.

fam

The pedigree structure as a plink FAM table, or NULL if no family structure is to be simulated.

ids

The list of IDs from fam above split into non-overlapping generations. Ignored if fam is NULL.

m_loci

The number of loci.

p_anc

The desired ancestral allele frequencies (scalar or length-m_loci vector passed to bnpsd::draw_all_admix()). By default (NULL), ancestral allele frequencies are drawn randomly.

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]. Has no effect if p_anc option is non-NULL.

verbose

If TRUE reports progress, otherwise it is silent.

Value

A list containing the following elements:

  • X: The simulated genotype matrix.

  • p_anc: The vector of ancestral allele frequencies (required to simulate traits with desired heritability).

Examples

# draw population parameters using `sim_pop` first
# a small example
data_pop <- sim_pop( n_ind = 50, G = 3 )

# now draw genotypes!
m_loci <- 100
data_geno <- sim_geno(
    data_pop$admix_proportions_1,
    data_pop$inbr_subpops,
    data_pop$fam,
    data_pop$ids,
    m_loci
)

# genotype matrix
data_geno$X

# ancestral allele frequencies
data_geno$p_anc


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