Skip to contents

Simulate a complex trait as a function of latent genetic values and environmental noise.

Usage

simulate_polygenic_trait(g, h2g)

Arguments

g

Vector of latent genetic values.

h2g

Heritability of the trait in the population.

Value

Simulated phenotype.

Examples

R <- matrix(c(1, 0.5, 0.5, 1), nrow = 2)  # LD matrix
n <- 100                                  # Number of samples
G <- sim_geno_LD(n, R)                     # Simulate genotypes
ncausal <- 1                               # Number of causal SNPs
b <- sim_beta(G, ncausal, ntrait = 1, is_h2g_total = TRUE, shared_pattern = "all")
g <- G %*% b                               # latent genetic values
y <- simulate_polygenic_trait(g, h2g = 0.5)  # Simulate the complex trait