Skip to content

Instantly share code, notes, and snippets.

@jotech
jotech / bacarena-ecoli.R
Last active October 25, 2018 02:09
How to get started in BacArena
#
# Doing a simple simulation using the E. coli model (iJO1366)
#
library(BacArena)
data(bcoli_orth)
bac <- Bac(ecoli)
arena <- Arena()
@jotech
jotech / flux_distribution.R
Last active August 1, 2023 04:04
Working with flux distribution
#
# In BacArena the activity of each reaction of an organism (flux distribution) is stored in arena@mflux.
# After finishing a simulation, the time series of the reaction activities can be accessed via eval@simlist.
#
library(BacArena)
data("Ec_core")
bac <- Bac(Ec_core)
arena <- Arena(n=20, m=20)
arena <- addOrg(arena,bac,amount=20)
@jotech
jotech / 0-crossfeeding.R
Last active October 12, 2021 09:13
Analyzing bacterial interaction and cross-feeding patterns with BacArena
#
# The sihumi example data set consists of a simulation of 8 gut microbes growing on a western diet for 8 hours.
# Here, we use it to study microbial interactions
#
library(BacArena)
data("sihumi_test")
@jotech
jotech / no-space.R
Last active April 10, 2019 12:11
bacarena_no-space
library(BacArena)
data("Ec_core")
arena <- Arena(n=10,m=10)
# by setting maxweight to infinity, duplication is disabled
# speed=0 indicates no movement
# limit_growth=FALSE removes the limit of biomass increase
bac <- Bac(Ec_core, speed=0, limit_growth=FALSE, maxweight=Inf)
@jotech
jotech / delayed-o2.R
Last active August 1, 2023 03:39
Adding oxygen after some time
library(BacArena)
data("Ec_core")
bac <- Bac(Ec_core)
arena <- Arena(n=20, m=20)
arena <- addOrg(arena,bac,amount=30)
arena <- addSubs(arena, smax=0.05, mediac="EX_glc(e)", unit="mM")
arena <- addSubs(arena, smax=1, mediac=c("EX_pi(e)", "EX_h2o(e)", "EX_nh4(e)"), unit="mM")
# Aenaerobic simulation for 6h
@jotech
jotech / 0_matlab_example.R
Last active October 10, 2023 11:20
import matlab models
library("BacArena")
library("R.matlab")
mod <- readMATmod("Actinobacillus_pleuropneumoniae_L20.mat")
arena <- Arena(n=10,m=10)
arena <- addOrg(arena, Bac(mod), 10)
arena <- addDefaultMed(arena, Bac(mod))
sim <- simEnv(arena, time=5)
@jotech
jotech / _syntrophy.R
Last active July 13, 2022 09:22
syntrophy of a Clostridium and a Methanogen
library(BacArena)
SYBIL_SETTINGS("SOLVER", "cplexAPI")
set.seed(115)
# C. beijerinckii:
# - publication https://doi.org/10.1007/s00253-008-1654-4
# - model http://bigg.ucsd.edu/models/iAF692
# M. barkeri:
# - publication: https://doi.org/10.1186/1752-0509-5-130