library(devtools)
library(CAMI)

1. Installation

We will begin by installing devtools. Devtools is an R package that enables the development of other R packages. You can use devtools to install a package that is managed in a github repository. We will install CAMI this way.

## install devtools with the line below if you do not already have it
install.packages("devtools")
library(devtools)

## install CAMI from github using devtools with the line below
devtools::install_github("ruffleymr/CAMI")
library("CAMI")

2. Simulation of Data

To simulate community assembly data we will be using the SimCommunityAssembly() function. This function simulates phylogenetic and phenotypic community assembly data in a species-based model. The function takes several parameters, which can be seen in the help documentation using ?SimCommunityAssembly. This function can be used to simulate 1 to many community assembly datasets, set using the sims argument.

Parameters

Before we simulate data, let's go through the parameters of the function.

For a single simulation, first, a regional community phylogeny is simulated under a constant birth-death process. CAMI uses the function sim.bd.taxa in the R package TreeSim (Stadler 2011).

Trait evolution is then modeled along this phylogeny under one of two models of trait evolution, Brownian Motion (BM; Felsenstein 1985) and Ornstein-Uhlenbeck (OU; Hansen 1997, Butler & King 2004), determined by the traitsim argument.

Once the regional community pool exists, the species are assembled into local communities under one of three assembly models, neutral, habitat filtering, and competitive exclusion, set using the comsim argument. The non-neutral assembly models use the phenotypic variation in the regional community and phenotypic matching and repulsion equations, for filtering and competition models respectively, to determine which species will survive in the local community.

For filtering models, the lower tau is, the stronger the environmental filter. For competition models, the higher tau, the stronger the effects of competition.

For all of these parameters, a uniform prior distribution of parameter values or a fixed value can be designated. Many of the parameters have default uniform prior distributions, see the help page for details on each parameter.

Again, you can view this information in the help documentation using '?SimCommunityAssembly'

SimCommunityAssembly()

Now we can start simulating data. We will first simulate 10 communities, where each community is comprised of 100 species in the regional community, half the amount of species in the local community, a "BM" model of trait evolution, and a "neutral" model of community assembly. We will leave all other parameters as their default settings.

#simulate neutral community assembly data
Neutral.Sims <- SimCommunityAssembly(sims = 10, N = 100, local = 0.5,
                                 traitsim = "BM",
                                 comsim = "neutral")

We can also simulate under alternative models of community assembly and trait evolution and add/change prior ranges.

Filtering.Sims <- SimCommunityAssembly(sims = 10, N = c(100,200), local = 0.5,
                                 traitsim = "OU",
                                 comsim = "filtering",
                                 sig2 = c(2.0, 5.0))

3. Output

The output of the function is a list of two data frames The first matrix is of all parameters and the second matrix contains all summary.stats. In both cases, each row in the matrix is a unique simulation and the rows between matrices correspond.

#two matrices, 'params' and 'summary.stats'
head(Neutral.Sims$params)
head(Neutral.Sims$summary.stats)


ruffleymr/CAMI documentation built on Aug. 21, 2019, 2:55 p.m.