Simulate populations of RADseq data following island or stepping stone models. Inside the function, allele frequency can be created with fastsimcoal2 and then used inside rmetasim simulation engine. The function requires strataG to be installed.

simulate_rad(
  num.pops = 5,
  num.loci = 1000,
  div.time = 25000,
  ne = 50,
  nm = c(0, 5),
  theta = 0.2,
  mig.type = c("island", "stepping.stone"),
  num.reps = 10,
  num.rms.gens = 10,
  label = NULL,
  fsc.exec = "fsc26",
  parallel.core = parallel::detectCores() - 1,
  use.wd = FALSE
)

Arguments

num.pops

(integer) Number of populations. Default: num.pops = 5.

num.loci

(integer) Number of independent RADseq loci. To use more than 2000 loci, rmetasim needs to be modified (vignette). Default: num.loci = 1000.

div.time

(integer) Time since divergence of populations. Default: div.time = 25000.

ne

(integer) Effective populations size. Default: ne = c(50, 500).

nm

(integer) Number of migrants per generation. Default: nm = c(0, 0.1, 0.5, 1, 5).

theta

(integer) Value of theta (= ne * migration rate). Default: theta = 0.2.

mig.type

(integer) Migration topology type: "island" or "stepping.stone".

num.reps

(integer) Number of replicates for each scenario. Default: num.reps = 10.

num.rms.gens

(integer) Number of rmetasim generations to establish linkage disequilibrium. Default: num.rms.gens = 10.

label

(integer) Label for the output folder. With default label = NULL, the label will be "sim.results.YYYYMMDD.HHMM".

fsc.exec

(character) Name of fastsimcoal executable. See details. Default: fsc.exec = "fsc26" (for latest version: v.2.6.0.3 - 14.10.17)

parallel.core

(optional, integer) The number of core used for parallel execution. Default: parallel.core = parallel::detectCores() - 1.

use.wd

(optional, logical) Use the working directory for output files? Default: use.wd = FALSE means that files are written to temporary folder.

Value

invisibly, a list containing the parameters used to run the simulation and the filenames of the genotypes for each scenario and replicate

Details

fastsimcoal2: The function requires that the executable for fastsimcoal be installed in a location where it can be executed from the current working directory.

How to set up your PATH.

How to install fastsimcoal2 v.2.6.0.3

Note

The following arguments can be specified as single values or vectors: num.pops, num.loci, div.time, ne, nm, theta, mig.type. One simulation scenario will be generated for each combination of unique values of these arguments.

The function will create a folder in the current working directory with the name provided by label. Within this folder there will be an R workspace file ("scenarios.rdata") containing a data frame with the parameters for each scenario (scenarios), and one R workspace file for each scenario, named "gtypes.#.rdata" where "#" is the scenario number. Each scenario file contains a list named sim.data, which contains a strataG::gtypes representation of the simulated SNP data for every replicate in that scenario. The list has a "scenario" attribute which is a one row data.frame providing the parameters that generated the data and a "label" attribute which is the label of the set of scenarios that were run.

See also

Author

Eric Archer eric.archer@noaa.gov and Thierry Gosselin thierrygosselin@icloud.com

Examples

if (FALSE) { library(grur) sim <- grur::simulate_rad( num.pops = 3, num.loci = 200, div.time = 1000, ne = c(50,200), nm = c(0, 0.1), theta = 0.2, mig.type = c("island", "stepping.stone"), num.reps = 3, num.rms.gens = 5, label = NULL, fsc.exec = "fsc26", parallel.core = 4 ) }