simulate_fl: Apply 'simulation_model' to the rows of the matrix...

Description Usage Arguments Value Examples

View source: R/simulate_fl.R

Description

Apply simulation_model to the rows of the matrix parameter either sequentially or in parallel (depends on ncore).

Usage

1
2
3
simulate_fl(parameter, simulation_model, empirical_fl = NULL,
  ncore = 1, file_output = NULL, multi_file = TRUE,
  fun_args = list(), output_args = list(), ...)

Arguments

parameter

A matrix of type numeric. Each row correspond to the arguments in simulation_model. the order of the column must be the same as the arguments in simulation_model.

simulation_model

A function or a character designing the model_type from generate_model. If a function is provided, its arguments must correspond to a row of parameter with same order.

empirical_fl

A matrix corresponding to an empirical fitness landscape. The first ncol-1 columns correspond to a genotype table. The rows correspond to different genotypes and the columns to the mutations that are considered for these genotypes. A genotype (at a certain row) has a given mutation when there is a 1 in the corresponding column. The column to of empirical_fl correspond to the fitness of each genotype. Only the fitness of the wt (i.e. the row in the genotype table with only zeros) is used.

ncore

A natural number. Number of cores used for the simulations. If ncore = 1 simulation_model is applied sequentially over the row of parameter. If ncore > 1 simulation_model is applied in parallel over the row of parameter. The parallelization is not avilable for "Windows".

file_output

Full path to the output file for the simulations. If NULL no output file is created.

multi_file

Logical. Applies only if file_output is not NULL. If TRUE the results of the simulations are saved in two separated files with the suffixes "-simulation" and "-parameter". If FALSE parameters and simulations are saved in the same file with first columns for the parameters and the last colums for the corresponding simulations.

fun_args

List of argument for a given model_type. Argument *_ref are mandatory parameters for the environment of reference in models with two environments

nb_mut_rand

optionnal for "fgmsmut", "fgmcsmut", "fgmsmut2env" and "fgmcsmut2env". See model_fgmrmut_2env

fitness_wt_ref

mandatory for "fgmsmut2env" and "fgmcsmut2env". See model_fgmrmut_2env

n_ref

mandatory for "fgmrmut2env", "fgmsmut2env" and "fgmcsmut2env". See model_fgmrmut_2env

lambda_ref

mandatory for "fgmrmut2env", "fgmsmut2env" and "fgmcsmut2env". See model_fgmrmut_2env

maxfitness_ref

mandatory for "fgmrmut2env", "fgmsmut2env" and "fgmcsmut2env". See model_fgmrmut_2env

alpha_ref

mandatory for ""fgmrmut2env", fgmsmut2env" and "fgmcsmut2env". See model_fgmrmut_2env

Q_ref

mandatory for "fgmrmut2env", "fgmsmut2env" and "fgmcsmut2env". See model_fgmrmut_2env

m_ref

mandatory for "fgmrmut2env", "fgmsmut2env" and "fgmcsmut2env". See model_fgmrmut_2env

output_args

List of arguments which will be passed to write.table if file_output = TRUE.

...

Extra arguments which will be passed to read.table if an empirical fitness landscape is provided as a file in empirical_fl

Value

A list of three elements. The first element is the matrix of parameter. If some parameters are unnamed, all the parameters are renamed to P1, P2... The second element is the matrix of simulations, in which each row is the result of simulation_model applied on the corresponding row in parameter. The columns of this matrix are named S1, S2... The third element is the output of system.time for the total simulation process.

Examples

1
2
3
simulation_model <- function(m, sd) {rnorm(n = 10, mean = m, sd = sd)}
parameter <- cbind(1:10, seq(0.1, 1, 0.1))
simulate_fl(parameter, simulation_model, ncore = 1)

YoannAnciaux/inferenceFitnessLandscape documentation built on Oct. 31, 2019, 1:19 a.m.