moran_deme: Run Metacommunity Moran Simulation.

View source: R/Main_functions.R

moran_demeR Documentation

Run Metacommunity Moran Simulation.

Description

This functions runs a single metacommunity simulation using an adapted version of a population genetics Moran model with selection and migration.

Usage

moran_deme(x, t, params, outgens = NULL, output = TRUE)

Arguments

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 make_params.

outgens

Numeric vector of generations for which output is desired.

output

Logical, if True outputs progress bar.

Details

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).

Value

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.

See Also

make_params set_sel set_fd set_mig make_mig

Examples

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)


trevorjwilli/CommSimABCR documentation built on Feb. 4, 2025, 1:22 a.m.