Skip to content

Commit

Permalink
build based on 7f856e5
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Aug 31, 2023
1 parent 009af59 commit eeb4801
Show file tree
Hide file tree
Showing 77 changed files with 18,738 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stable
1 change: 1 addition & 0 deletions v0.2
100 changes: 100 additions & 0 deletions v0.2.0/API.html

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions v0.2.0/APIdevelopers.html

Large diffs are not rendered by default.

265 changes: 265 additions & 0 deletions v0.2.0/Aggregation.html

Large diffs are not rendered by default.

Binary file added v0.2.0/Aggregation_files/Aggregation_10_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added v0.2.0/Aggregation_files/Aggregation_12_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added v0.2.0/Aggregation_files/Aggregation_15_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added v0.2.0/Aggregation_files/Aggregation_17_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added v0.2.0/Aggregation_files/Aggregation_23_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added v0.2.0/Aggregation_files/Aggregation_27_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added v0.2.0/Aggregation_files/Aggregation_6_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
394 changes: 394 additions & 0 deletions v0.2.0/Bacteries.html

Large diffs are not rendered by default.

Binary file added v0.2.0/Bacteries_files/Bacteries_15_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added v0.2.0/Bacteries_files/Bacteries_6_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added v0.2.0/Bacteries_files/Bacteries_9_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
204 changes: 204 additions & 0 deletions v0.2.0/Chemotaxis.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Bacterial chemotaxis · CellBasedModels.jl</title><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="index.html"><img src="assets/logo.png" alt="CellBasedModels.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit">CellBasedModels.jl</span></div><form class="docs-search" action="search.html"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="index.html">Home</a></li><li><span class="tocitem">Usage</span><ul><li><a class="tocitem" href="Usage_intro.html">Introduction</a></li><li><a class="tocitem" href="Usage_Agent.html">Defining an ABM model</a></li><li><a class="tocitem" href="Usage_Community.html">Creating and evolving a Community</a></li><li><a class="tocitem" href="Usage_Fitting.html">Model Fitting</a></li></ul></li><li><span class="tocitem">Examples</span><ul><li><a class="tocitem" href="Patterning.html">Patterning</a></li><li><a class="tocitem" href="Development.html">ICM Development</a></li><li><a class="tocitem" href="Aggregation.html">Particle aggregation</a></li><li><a class="tocitem" href="Bacteries.html">Bacterial Colony Growth</a></li><li class="is-active"><a class="tocitem" href="Chemotaxis.html">Bacterial chemotaxis</a><ul class="internal"><li><a class="tocitem" href="#Load-packages"><span>Load packages</span></a></li><li><a class="tocitem" href="#Modify-the-model"><span>Modify the model</span></a></li><li><a class="tocitem" href="#Initialising-the-community"><span>Initialising the community</span></a></li><li><a class="tocitem" href="#Evolving-the-community"><span>Evolving the community</span></a></li><li><a class="tocitem" href="#Plot-of-the-results"><span>Plot of the results</span></a></li></ul></li></ul></li><li><a class="tocitem" href="Models.html">Models</a></li><li><a class="tocitem" href="API.html"><strong>API</strong></a></li><li><a class="tocitem" href="APIdevelopers.html">API for Developers</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Examples</a></li><li class="is-active"><a href="Chemotaxis.html">Bacterial chemotaxis</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="Chemotaxis.html">Bacterial chemotaxis</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/dsb-lab/CellBasedModels.jl/blob/master/docs/src/Chemotaxis.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Chemotaxis"><a class="docs-heading-anchor" href="#Chemotaxis">Bacterial chemotaxis</a><a id="Chemotaxis-1"></a><a class="docs-heading-anchor-permalink" href="#Chemotaxis" title="Permalink"></a></h1><p>We use the model of bacterial cells by <a href="https://www.pnas.org/doi/abs/10.1073/pnas.0706805105">Volfson et al. (2008)</a> and modify it to add active movement to the bacteries.</p><p>Over the physical model we add some active forces and a tumbling displacement model. The original physical model can be found in <code>Models/rods.jl</code>. We can copy its code and modify it in the following.</p><ul><li>Add to the moving force an additional propulsion term.</li><li>Add to the agents a tumble and run protocol.</li><li>Add a medium which the model will detect.</li><li>Keep cells inside some boundaries.</li></ul><h2 id="Load-packages"><a class="docs-heading-anchor" href="#Load-packages">Load packages</a><a id="Load-packages-1"></a><a class="docs-heading-anchor-permalink" href="#Load-packages" title="Permalink"></a></h2><pre><code class="language-julia">using CellBasedModels
using GLMakie
Makie.inline!(true)
using GeometryBasics
using Distributions</code></pre><h2 id="Modify-the-model"><a class="docs-heading-anchor" href="#Modify-the-model">Modify the model</a><a id="Modify-the-model-1"></a><a class="docs-heading-anchor-permalink" href="#Modify-the-model" title="Permalink"></a></h2><p>The model is a copy of the model as provided in <code>Models/rods.jl</code>. We mark the added lines to the code to adapt it to a chemotaxis model.</p><pre><code class="language-julia">rods2DChemotaxis = ABM(2,
agent = Dict(
:vx=&gt;Float64,
:vy=&gt;Float64,
:theta=&gt;Float64,
:ω=&gt;Float64,
:d=&gt;Float64,
:l=&gt;Float64,
:m=&gt;Float64,
:fx=&gt;Float64,
:fy=&gt;Float64,
:W=&gt;Float64,
:pressure=&gt;Float64,
:tTumble=&gt;Float64, #We add to the agent a time to tumble or to run
:active=&gt;Bool, #Add a switch to change between tumbling and running
),

model = Dict(
:kn=&gt;Float64,
:γn=&gt;Float64,
:γt=&gt;Float64,
:μcc=&gt;Float64,
:μcw=&gt;Float64,
:β=&gt;Float64,
:βω=&gt;Float64,
:ωTumble=&gt;Float64, #Add a torque of tumbling
:τTumble=&gt;Float64, #Add a frequency of tumbling
:fChem=&gt;Float64, #Add a force of propulsion
:DMedium=&gt;Float64, #Add a diffusion constant of the medium
:ωMedium=&gt;Float64 #Add a frequency of the oscillating medium
),

medium = Dict(
:mm =&gt; Float64 #Add a medium parameter
),

agentODE = quote

fx = 0
fy = 0
W = 0
pressure = 0
@loopOverNeighbors i2 begin

Fijx, Fijy, Wij = CBMModels.rodForces(
x,y,d,l,theta,vx,vy,m,
x[i2],y[i2],d[i2],l[i2],theta[i2],vx[i2],vy[i2],m[i2],
kn,γn,γt,μcc,μcw
)

#Append the interaction forces
fx += Fijx
fy += Fijy
#Append radial forces
W += Wij
#Keep track of preassure in the media
pressure += sqrt(Fijx^2+Fijy^2)

end

#Equations
dt(x) = vx
dt(y) = vy
dt(vx) = -β*vx+fx/m + active * fChem * cos(theta) #Add the propulsion force
dt(vy) = -β*vy+fy/m + active * fChem * sin(theta) #Add the propulsion force
dt(theta) = ω
dt(ω) = W/(m*(d+l)^2/12+m*d^2)-βω*ω

end,

agentRule = quote
#Code rule switch between tumbling and running
if tTumble &lt; t &amp;&amp; active #Activate tumbling if the particle was active (running) and the tumbling time ended
vx = 0
vy = 0
active = false
ω += ωTumble
tTumble += 1.
elseif tTumble &lt; t &amp;&amp; !active # Activate tumbling if the particle was tumbling (active off) and the running time ended (we resuse the tTumble time)
ω = 0
active = true
tTumble += CBMDistributions.exponential((2-mm)*τTumble)
end

# Very rudementary rule to to fix the bacteries to move inside the boundaries using onluy the center of the rod
if x &lt; simBox[1,1]
x = simBox[1,1]
elseif x &gt; simBox[1,2]
x = simBox[1,2]
end
if y &lt; simBox[2,1]
y = simBox[2,1]
elseif y &gt; simBox[2,2]
y = simBox[2,2]
end

end,

#Medium dynamics with dirichlet conditions and a wall that is as oscillating source of material
mediumODE=quote
if @mediumInside()
dt(mm) = DMedium*@∂2(1,mm)# we only diffuse in x as the symmetry is in x
elseif @mediumBorder(1,-1)
mm = 0
elseif @mediumBorder(1,1)
mm = sin(ωMedium*t)+1 #Oscillatory behaviour
elseif @mediumBorder(2,-1)
mm = 0
elseif @mediumBorder(2,-1)
mm = 0
end
end,

neighborsAlg=CBMNeighbors.CellLinked(cellEdge=4)
);</code></pre><h2 id="Initialising-the-community"><a class="docs-heading-anchor" href="#Initialising-the-community">Initialising the community</a><a id="Initialising-the-community-1"></a><a class="docs-heading-anchor-permalink" href="#Initialising-the-community" title="Permalink"></a></h2><pre><code class="language-julia">com = Community(
rods2DChemotaxis,
N=75,
dt=0.1,
simBox=[-20 20;-20 20.],
NMedium=[200,200],
)

m = 1/100
g = 1/10000
d = 1
com.kn = 2E6 * (m*g/d)
com.γn = 2.2E2 * sqrt(g/d)
com.γt = 2.2E2 * sqrt(g/d)
com.μcc = 0.1
com.μcw = 0.8
com.β = .8
com.βω = .8
com.fChem = 1
com.τTumble = 2
# com.τTumbleMin = 1
com.ωTumble = 1
com.ωMedium = .01
com.DMedium = 3

com.m = 1.
com.d = 1.
com.l = 3;
com.x = rand(Uniform(com.simBox[1,:]...),com.N)
com.y = rand(Uniform(com.simBox[2,:]...),com.N)
com.theta = rand(Uniform(0,2π),com.N);</code></pre><h2 id="Evolving-the-community"><a class="docs-heading-anchor" href="#Evolving-the-community">Evolving the community</a><a id="Evolving-the-community-1"></a><a class="docs-heading-anchor-permalink" href="#Evolving-the-community" title="Permalink"></a></h2><p>As the evolution function may take some time, we add a progress message to the evolution to provide information of progress.</p><pre><code class="language-julia">evolve!(com,steps=8000,saveEach=10,progressMessage=(com)-&gt;println(&quot;Step: &quot;,round(Int,com.t)*10))</code></pre><h2 id="Plot-of-the-results"><a class="docs-heading-anchor" href="#Plot-of-the-results">Plot of the results</a><a id="Plot-of-the-results-1"></a><a class="docs-heading-anchor-permalink" href="#Plot-of-the-results" title="Permalink"></a></h2><ul><li>We plot samples of the medium and bacteries.</li><li>The mean position of the bacteries over time.</li></ul><pre><code class="language-julia">fig = Figure(resolution=(1800,400))

for (j,i) in enumerate(1:round(Int,length(com)/4):length(com))
begin
d = getParameter(com,[:x,:y,:d,:l,:theta,:pressure,:mm])

ax = Axis(fig[1,2*j-1])

m = heatmap!(ax,
range(com.simBox[1,1],com.simBox[1,2],length=size(com.mm)[1]),
range(com.simBox[2,1],com.simBox[2,2],length=size(com.mm)[1]),
d[:mm][i],
colorrange=(0,2.)
)

xlims!(com.simBox[1,:]...)
ylims!(com.simBox[2,:]...)

x = Observable(d[:x][i])
y = Observable(d[:y][i])
xs1 = Observable(d[:x][i]+d[:l][i]./2 .*cos.(d[:theta][i]))
ys1 = Observable(d[:y][i]+d[:l][i]./2 .*sin.(d[:theta][i]))
xs2 = Observable(d[:x][i]-d[:l][i]./2 .*cos.(d[:theta][i]))
ys2 = Observable(d[:y][i]-d[:l][i]./2 .*sin.(d[:theta][i]))
ms = Observable([Point3f0(i/2,i/2,0) for i in d[:d][i]])
mc = Observable([Point3f0(ll,dd/2,dd/2) for (ll,dd) in zip(d[:l][i],d[:d][i])])
theta = Observable(d[:theta][i])

plotRods2D!(ax,x,y,xs1,ys1,xs2,ys2,ms,mc,theta,color=:red)

Colorbar(fig[1,2*j],m)
end
end

display(fig)</code></pre><p><img src="Chemotaxis_files/Chemotaxis_10_0.png" alt="png"/></p><pre><code class="language-julia">d = getParameter(com,[:x])

fig = Figure(resolution=(400,400))
ax = Axis(fig[1,1],xlabel=&quot;time&quot;,ylabel=&quot;medium&quot;,
rightspinevisible=false,
topspinevisible=false,
xgridvisible=false,
ygridvisible=false
)

lines!(ax,[i.t for i in com.pastTimes],[1-cos(com.ωMedium[1]*i.t) for i in com.pastTimes])

ax2 = Axis(fig[2,1],xlabel=&quot;time&quot;,ylabel=&quot;mean(x)&quot;,
rightspinevisible=false,
topspinevisible=false,
xgridvisible=false,
ygridvisible=false
)
lines!(ax2,[i.t for i in com.pastTimes],[mean(i) for i in d[:x]])

display(fig)</code></pre><p><img src="Chemotaxis_files/Chemotaxis_11_0.png" alt="png"/></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="Bacteries.html">« Bacterial Colony Growth</a><a class="docs-footer-nextpage" href="Models.html">Models »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Thursday 31 August 2023 15:31">Thursday 31 August 2023</span>. Using Julia version 1.6.7.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Binary file added v0.2.0/Chemotaxis_files/Chemotaxis_10_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added v0.2.0/Chemotaxis_files/Chemotaxis_11_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit eeb4801

Please sign in to comment.