Learn R Programming

metan (version 1.12.0)

data_simula: Simulate genotype and genotype-environment data

Description

  • g_simula() simulate replicated genotype data.

  • ge_simula() simulate replicated genotype-environment data.

Usage

ge_simula(
  ngen,
  nenv,
  nrep,
  nvars = 1,
  gen_eff = 20,
  env_eff = 15,
  rep_eff = 5,
  ge_eff = 10,
  intercept = 100,
  seed = NULL
)

g_simula( ngen, nrep, nvars = 1, gen_eff = 20, rep_eff = 5, intercept = 100, seed = NULL )

Arguments

ngen

The number of genotypes.

nenv

The number of environments.

nrep

The number of replications.

nvars

The number of traits.

gen_eff

The genotype effect.

env_eff

The environment effect

rep_eff

The replication effect

ge_eff

The genotype-environment interaction effect.

intercept

The intercept.

seed

The seed.

Value

A data frame with the simulated traits

Details

The functions simulate genotype or genotype-environment data given a desired number of genotypes, environments and effects. All effects are sampled from an uniform distribution. For example, given 10 genotypes, and gen_eff = 30, the genotype effects will be sampled as runif(10, min = -30, max = 30). Use the argument seed to ensure reproducibility. If more than one trait is used (nvars > 1), the effects and seed can be passed as a numeric vector. Single numeric values will be recycled with a warning when more than one trait is used.

Examples

Run this code
# NOT RUN {
library(metan)
# Genotype data (5 genotypes and 3 replicates)
gen_data <-
   g_simula(ngen = 5,
            nrep = 3)
gen_data
inspect(gen_data, plot = TRUE)

 # Genotype-environment data
 # 5 genotypes, 3 environments, 4 replicates and 2 traits
df <-
ge_simula(ngen = 5,
          nenv = 3,
          nrep = 4,
          nvars = 2)
inspect(df, plot = TRUE)

# Change genotype effect (trait 1 with fewer differences among genotypes)
# Define different intercepts for the two traits
df2 <-
ge_simula(ngen = 10,
          nenv = 3,
          nrep = 4,
          nvars = 2,
          gen_eff = c(1, 50),
          intercept = c(80, 1500))
inspect(df2, plot = TRUE)
# }

Run the code above in your browser using DataLab