View source: R/Main_functions.R
moran_deme | R Documentation |
This functions runs a single metacommunity simulation using an adapted version of a population genetics Moran model with selection and migration.
moran_deme(x, t, params, outgens = NULL, output = TRUE)
x |
Numeric matrix, starting metacommunity (species x site) matrix where columns are species, rows are communities and cell ij is the count of species j in community i. |
t |
Numeric, number of generations for simulation to run. |
params |
S3 class params object, see |
outgens |
Numeric vector of generations for which output is desired. |
output |
Logical, if True outputs progress bar. |
Metacommunity simulations in CommSimABC are based upon Moran models with selection and migration. As input, these simulations require a starting metacommunity, the number of generations for the simulation to run, a selection matrix, where columns are species, rows are sites, and cell ij is the selection coefficient for species j in community i, frequency dependence parameters for each species, and migration matrices for each species. For details on the selection matrix, frequency dependence parameters, and migration matrices see the links in see also. For details on model algorithm and mathematics see Williams et al. (XXXX).
Returns an object of class simrun, list containing four objects: Metacommunity: A list containing the metacommunity matrices from generations specified in outgens Incidence: A list containing presence-absence matrices from generations specified in outgens Metafreq: A matrix where each column is a species and each row is a generation. Values are the frequencies of species summed across the entire metacommunity. Comfreq: A list of matrices (one for each community )where each column is a species and each row is a generation. Values are the frequencies of the species in that community at the start of that generation.
make_params
set_sel
set_fd
set_mig
make_mig
meta <- rand_meta(N = 5, S = 5, 25)
xy <- matrix(sample(50, 10, replace = TRUE), ncol = 2)
inparam <- make_params(5,5)
inparam$s <- set_sel(inparam, 'gamma', 2, .15)
inparam$fd <- set_fd(inparam, -.5, -.2)
inparam$mig <- set_mig(inparam, xy, 25, .05)
moran_deme(meta, 5, inparam)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.