sim_trial: Simulate an experimental field trial

View source: R/sim_phenotypes.R

sim_trialR Documentation

Simulate an experimental field trial

Description

Simulates a trial in which phenotypic data on a quantitative trait is gathered.

Usage

sim_trial(pop, h2, n.env = 1, n.rep = 1, check.pop, check.rep, ...)

Arguments

pop

An object of class pop, the individuals in which are to be phenotyped.

h2

The heritability of the trait or traits. May be a double (heritability is the same for all traits) or a numeric vector with length equal to the number of traits.

n.env

The number of environments in which to phenotype.

n.rep

The number of replicates of each experimental (i.e. non-check) individual in each environment.

check.pop

A pop object with individuals to be used as repeated checks (e.g. for an augmented design). If missing (default), then no checks are included.

check.rep

A scalar specifying the number of times each check is replicated in each environment.

...

Other arguments. See Details.

Details

Other arguments that can be specified are :

V_E

The variance of environmental effects. May be a double (V_E is the same for all traits) or a numeric vector with length equal to the number of traits.

V_R

The variance of the residual effects. May be a double (V_R is the same for all traits) or a numeric vector with length equal to the number of traits.

Value

An object of class pop with all information in the input pop object, plus simulated phenotypes.

Examples


## Not run: 

# Load some historic data
data("s2_cap_genos")
data("s2_snp_info")

map <- s2_snp_info %>% 
  select(-alleles) %>% 
  data.frame(row.names = .$rs, stringsAsFactors = FALSE) %>% 
  select(-rs) %>% 
  table_to_map()

# Create a genome with genetic architecture
genome <- sim_genome(map = map)

# Simulate a a trait with 15 QTL
qtl.model <- matrix(nrow = 15, ncol = 4)

genome <- sim_gen_model(genome, qtl.model, add.dist = "geometric", max.qtl = 15)

pop <- create_pop(genome = genome, geno = s2_cap_genos)

# Sample the population for checks
set.seed(1035)
check_pop <- pop %>%
  subset_pop(individual = sample(indnames(.), 5))
  
# Remove the checks from the original pop
exp_pop <- pop %>% 
  subset_pop(setdiff(indnames(.), indnames(check_pop)))

# Simulate a trial
pop_pheno <- sim_trial(pop = exp_pop, h2 = 0.5, n.env = 3, n.rep = 1,
  check.pop = check_pop, check.rep = 3)
  

## End(Not run)
  

neyhartj/pbsim documentation built on Nov. 11, 2023, 4:07 p.m.