miaSim 1.9.0

`miaSim`

implements tools for microbiome data simulation based on
varying ecological modeling assumptions. These can be used to simulate
species abundance matrices, including time series. Detailed function
documentation is available at the function reference

The miaSim package supports the R/Bioconductor framework based on the TreeSummarizedExperiment data container. For more information on operating with this data format in microbial ecology, see the online tutorial.

The stable Bioconductor release version can be installed as follows.

```
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
if (!requireNamespace("miaSim", quietly = TRUE))
BiocManager::install("miaSim")
```

The experimental Bioconductor devel version can be installed as follows.

```
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
# The following initializes usage of Bioc devel
BiocManager::install(version='devel')
BiocManager::install("miaSim")
```

Load the library

`library(miaSim)`

Some of the models rely on interaction matrices that represents interaction heterogeneity between species. The interaction matrix can be generated with different distributional assumptions.

Generate interactions from normal distribution:

`A_normal <- powerlawA(n_species = 4, alpha = 3)`

Generate interactions from uniform distribution:

```
A_uniform <- randomA(n_species = 10,
diagonal = -0.4,
connectance = 0.5,
interactions = runif(n = 10^2, min = -0.8, max = 0.8))
```

Ricker model is a discrete version of the gLV:

`tse_ricker <- simulateRicker(n_species=4, A = A_normal, t_end=100, norm = FALSE)`

The number of species specified in the interaction matrix must be the same as the species used in the models.

Hubbell Neutral simulation model characterizes diversity and relative abundance of species in ecological communities assuming migration, births and deaths but no interactions. Losses become replaced by migration or birth.

```
tse_hubbell <- simulateHubbell(n_species = 8,
M = 10,
carrying_capacity = 1000,
k_events = 50,
migration_p = 0.02,
t_end = 100)
```

One can also simulate parameters for the Hubbell model.

```
params_hubbell <- simulateHubbellRates(x0 = c(0,5,10),
migration_p = 0.1, metacommunity_probability = NULL, k_events = 1,
growth_rates = NULL, norm = FALSE, t_end=1000)
```

The Self-Organised Instability (SOI) model generates time series for communities and accelerates stochastic simulation.

```
tse_soi <- simulateSOI(n_species = 4, carrying_capacity = 1000,
A = A_normal, k_events=5,
x0 = NULL,t_end = 150, norm = TRUE)
```

Stochastic logistic model is used to determine dead and alive counts in community.

`tse_logistic <- simulateStochasticLogistic(n_species = 5)`

The consumer resource model requires the `randomE`

function. This
returns a matrix containing the production rates and consumption rates
of each species. The resulting matrix is used as a determination of
resource consumption efficiency.

```
# Consumer-resource model as a TreeSE object
tse_crm <- simulateConsumerResource(n_species = 2,
n_resources = 4,
E = randomE(n_species = 2, n_resources = 4))
```

You could visualize the simulated dynamics using tools from the miaTime package.

The generalized Lotka-Volterra simulation model generates time-series assuming microbial population dynamics and interaction.

```
tse_glv <- simulateGLV(n_species = 4,
A = A_normal,
t_start = 0,
t_store = 1000,
stochastic = FALSE,
norm = FALSE)
```

The simulated data sets are returned as `TreeSummarizedExperiment`

objects. This provides access to a broad range of tools for microbiome
analysis that support this format (see
microbiome.github.io). More examples on
the object manipulation and analysis can be found at OMA Online
Manual.

For instance, to plot population density we can use the `miaViz`

package:

```
library(miaViz)
p1 <- plotAbundanceDensity(tse_hubbell, assay.type = "counts")
p2 <- plotSeries(tse_hubbell, x = "time")
print(p1+p2)
```