This package is for the simulation of microbial consumer-resource model.
These instructions will go through the basic functions for consumer-resource dynamics. Please see
tutorial.Rmd for description on models and more details.
Install this package from github using
install.packages("devtools") library(devtools) install_github("Chang-Yu-Chang/micro.crm")
micro.rm also relies on a couple of packages
library(tidyverse) library(data.table) library(igraph) library(PlayerRatings) library(vegan)
The first step is to call the example parameters for the model. The parameters will be saved in global environment.
To generate a species regional pool, use the function
pool_build. The parameters will be save in a Rdata file,
pool_build(save_data = TRUE, data_names = "species_pool")
From this regional pool, subset micrbial communities by given species abundance. The output community compostion is a named vector.
com1 <- community_generate(I = .01, threshold = 1e-3, r = 1)
Now let's take this generated community
com1 as intial community. Because there are only consumers in the generated community, another named vector as the initial resource condition has to be concatenated.
resource <- setNames(rep(1, P), paste0("R", sprintf("%03d", 1:P))) result <- CR_model(c(resource, com1), time_limit = 100, time_step = 1) result %>% as.data.frame() %>% gather("index", "value", -1) %>% mutate(type = substr(index, 1, 1)) %>% ggplot(aes(x = time, y = value, color = index, lty = type)) + geom_line() + theme_bw() + theme(legend.position="none") + NULL
In the cases of migration, co-assembly, or community coalescence, the communities (named vectors) can be coalesced using function
com2 <- community_generate(I = .01, threshold = 1e-3, r = 2) community_coalesce(com1, com2)
Run the following scripts in bash environment.
# Self-assembly Rscript self-assembly.R self-assembly001 # Isolation Rscript self-assembly-isolate.R self-assembly001 # Pairwise competition Rscript self-assembly-pair.R self-assembly001 0.5 0.5
- XX - Description about it
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
- Chang-Yu Chang - Initial work
This project is licensed under the MIT License - see the LICENSE.md file for details
- Hat tip to anyone whose code was used