Simulate stochastic bipartite network based on trait values of species - in R
- by Scott Chamberlain
I would like to create bipartite networks in R. For example, if you have a data.frame of two types of species (that can only interact across species, not within species), and each species has a trait value (e.g., size of mouth in the predator allows who gets to eat which prey species), how do we simulate a network based on the traits of the species (that is, two species can only interact if their traits overlap in values for instance)?
UPDATE: Here is a minimal example of what I am trying to do. 1) create phylogenetic tree; 2) simulate traits on the phylogeny; 3) create networks based on species trait values.
# packages
install.packages(c("ape","phytools"))
library(ape); library(phytools)
# Make phylogenetic trees
tree_predator <- rcoal(10)
tree_prey <- rcoal(10)
# Simulate traits on each tree
trait_predator <- fastBM(tree_predator)
trait_prey <- fastBM(tree_prey)
# Create network of predator and prey
## This is the part I can't do yet. I want to create bipartite networks, where
## predator and prey interact based on certain crriteria. For example, predator
## species A and prey species B only interact if their body size ratio is
## greater than X.