Skip to content
Consumer-resource model on microbial community migration
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
data
figure
man
parameter_script
src
.DS_Store
.Rbuildignore
.gitignore
DESCRIPTION
NAMESPACE
README.md
example001.R
micro.crm.Rproj
migration-global.R
migration-parent.R
migration-parent_analysis.R
migration-parent_analysis.Rmd
migration-parent_analysis.nb.html
migration-size.Rmd
migration-size.nb.html
migration-size_analysis.R
migration.Rmd
migration_analysis.Rmd
migration_temp.Rmd
motif_null.R
motif_null.Rmd
motif_null.nb.html
self-assembly-batch.R
self-assembly-batch_analysis.Rmd
self-assembly-batch_analysis.nb.html
self-assembly.R
self-assembly_analysis.R
self-assembly_analysis.Rmd
self-assembly_analysis.nb.html
self-assembly_isolate.R
self-assembly_pair.R
self_assembly.Rmd
self_assembly.nb.html
template_function.R
tutorial.Rmd
tutorial.nb.html

README.md

micro.crm

This package is for the simulation of microbial consumer-resource model.

Getting Started

These instructions will go through the basic functions for consumer-resource dynamics. Please see tutorial.Rmd for description on models and more details.

Installing

Install this package from github using devtools.

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)

Example

The first step is to call the example parameters for the model. The parameters will be saved in global environment.

data(example_parameter)

To generate a species regional pool, use the function pool_build. The parameters will be save in a Rdata file, data/species_pool.RData.

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 community_coalesce().

com2 <- community_generate(I = .01, threshold = 1e-3, r = 2)
community_coalesce(com1, com2)

Self-assembly

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

Built With

  • XX - Description about it

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Author

  • Chang-Yu Chang - Initial work

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Hat tip to anyone whose code was used
  • Inspiration
  • etc
You can’t perform that action at this time.