simulateGLV {miaSim}R Documentation

Generalized Lotka-Volterra (gLV) simulation

Description

Simulates time series with the generalized Lotka-Volterra model and forms a SummarizedExperiment object.

Usage

simulateGLV(
  n.species,
  A,
  x = runif(n.species),
  b = runif(n.species),
  t.start = 0,
  t.store,
  norm = FALSE,
  ...
)

Arguments

n.species

Integer: number of species

A

interaction matrix

x

Numeric: initial abundances

b

Numeric: growth rates

t.start

Numeric scalar indicating the initial time of the simulation. (default: t.start = 0)

t.store

Integer scalar indicating the number of evenly distributed time points to keep (default: t.store = 100)

norm

Logical scalar: returns normalised abundances (proportions in each generation) (default: norm = FALSE)

...

additional arguments that can be called from miaSim::tDyn

Details

Simulates a community time series using the generalized Lotka-Volterra model, defined as dx/dt = diag(x)(b+Ax), where x is the vector of species abundances ,diag(x) is a diagonal matrix with the diagonal values set to x. A is the interaction matrix and b is the vector of growth rates.

The resulting abundance matrix model is used to construct SummarizedExperiment object.

Value

simulateGLV returns a SummarizedExperiment object containing abundance matrix

Examples

row_data <- data.frame(Kingdom = "Animalia",
                Phylum = rep(c("Chordata", "Echinodermata"), c(500, 500)),
                Class = rep(c("Mammalia", "Asteroidea"), each = 500),
                ASV = paste0("X", seq_len(1000)),
                row.names = rownames(paste0("species", seq_len(1000))),
                stringsAsFactors = FALSE)

row_data <- t(row_data)

col_data <- DataFrame(sampleID = seq_len(1000),
                    time = as.Date(1000, origin = "2000-01-01"),
                    row.names = colnames(paste0("sample", seq_len(1000))))

A <- miaSim::powerlawA(4, alpha = 1.01)

SEobject <- simulateGLV(n.species = 4, A, t.start = 0, t.store = 1000)
rowData(SEobject) <- row_data
colData(SEobject) <- col_data


[Package miaSim version 0.99.1 Index]