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.
Usage
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
rmetasimgenerations 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 = FALSEmeans 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.
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.
Author
Eric Archer eric.archer@noaa.gov and Thierry Gosselin thierrygosselin@icloud.com
