feat_selection {coala}R Documentation

Feature: Selection

Description

This feature adds selection to a model. Only one site per locus can be under selection. Using this feature requires that msms is installed, see activate_msms.

Usage

feat_selection(
  strength_AA = 0,
  strength_Aa = 0,
  strength_aa = 0,
  strength_A = NULL,
  population = "all",
  time,
  start = TRUE,
  start_frequency = 5e-04,
  Ne = 10000,
  position = 0.5,
  force_keep = TRUE,
  locus_group = "all"
)

Arguments

strength_AA

The selection strength for the selected homozygote. The parameter is valid for the chosen population and the time further past-wards from either time 0 on if start = TRUE, or from time onwards. The same applies for strength_Aa, strength_aa and strength_A.

strength_Aa

The selection strength for the heterozygote.

strength_aa

The selection strength for the recessive homozygote.

strength_A

This sets the strength for the selected allele in a haploid model or a diploid model with additive selection. strength_AA, strength_Aa, strength_aa are ignored when this is argument is given.

population

The population in which the allele is selected. Can either be all for all population, or the number of a population.

time

The time at which the selection starts if start == TRUE (looking forwards in time), or the time at which the selection strength changes if start == FALSE. The new strength applies for the time period further into the past in this case.

start

Whether selection should start at this time point. At this time, the selected allele is introduced in the population with an initial starting frequency. This must be set to TRUE for exactly one selection feature in the model. The values of start_frequency, Ne, position and force_keep are used for the model. You can add additional selection feature to the model to set the selection strength for more demes or change it at different time points, but these need to have start = FALSE.

start_frequency

The start frequency at which the selected allele is introduced at time. If the model has multiple population, this can either be a numeric vector that contains the initial frequency for each population or a single number. In the latter case, the value is used for all population specified with populations, and 0 is used for all other populations.

Ne

The effective population size that is used for the forward simulations.

position

The position of the selected site, relative to the simulated sequence. Values between 0 and 1 are within the simulated area, while smaller values are to the left of it and larger ones to the right.

force_keep

Whether to restart simulations in which the selected goes to extinction or not.

locus_group

The loci for which this features is used. Can either be "all" (default), in which case the feature is used for simulating all loci, or a numeric vector. In the latter case, the feature is only used for the loci added in locus_ commands with the corresponding index starting from 1 in order in which the commands where added to the model. For example, if a model has locus_single(10) + locus_averaged(10, 11) + locus_single(12) and this argument is c(2, 3), than the feature is used for all but the first locus (that is locus 2 - 12).

Value

The feature, which can be added to a model created with coal_model using +.

See Also

For using rates that variate between the loci in a model: par_variation, par_zero_inflation

For summary statistics that are sensitive for selection: sumstat_tajimas_d, sumstat_ihh, sumstat_omega, sumstat_mcmf

For creating a model: coal_model

Other features: feat_growth(), feat_ignore_singletons(), feat_migration(), feat_mutation(), feat_outgroup(), feat_pop_merge(), feat_recombination(), feat_size_change(), feat_unphased()

Examples

# Positive additive selection in population 2:
model <- coal_model(c(10, 13), 1, 10000) +
  feat_pop_merge(.5, 2, 1) +
  feat_selection(strength_A = 1000,
                 population = 2,
                 time = par_named("tau")) +
  feat_mutation(100) +
  feat_recombination(10) +
  sumstat_tajimas_d(population = 2)
## Not run: simulate(model, pars = c(tau = 0.03))

[Package coala version 0.7.2 Index]