MetaWorm: An Integrative Data-Driven Model Simulating <i>C. elegans</i> Brain, Body and Environment Interactions — part 4/6

Cleaned-text code points [45292, 59157). Bibliography omitted here; source.md includes it.

21 Bergs, A. C. et al. All-optical closed-loop voltage clamp for precise control of muscles
and neurons in live animals. bioRxiv, 2022.2006. 2003.494532 (2022).
22 Leifer, A. M., Fang-Yen, C., Gershow, M., Alkema, M. J. & Samuel, A. D. Optogenetic
manipulation of neural activity in freely moving Caenorhabditis elegans. Nature
methods 8, 147-152 (2011).
23 Schrödel, T., Prevedel, R., Aumayr, K., Zimmer, M. & Vaziri, A. Brain-wide 3D imaging of
neuronal activity in Caenorhabditis elegans with sculpted light. Nature methods 10,
1013-1020 (2013).
24 Uzel, K., Kato, S. & Zimmer, M. A set of hub neurons and non-local connectivity features
support global brain dynamics in C. elegans. Current Biology 32, 3443-3459,
doi:https://doi.org/10.1016/j.cub.2022.06.039 (2022).
25 Bargmann, C. I. Genetic and Cellular Analysis of Behavior in C. Elegans. Annual Review of
Neuroscience 16, 47-71, doi:10.1146/annurev.ne.16.030193.000403 (1993).
26 Rankin, C. H. From gene to identified neuron to behaviour in Caenorhabditis elegans.
Nature Reviews Genetics 3, 622-630, doi:10.1038/nrg864 (2002).
27 Gray, J. M., Hill, J. J. & Bargmann, C. I. A circuit for navigation in <i>Caenorhabditis
elegans</i>. Proceedings of the National Academy of Sciences 102, 3184-3191,
doi:doi:10.1073/pnas.0409009101 (2005).
28 Chalasani, S. H. et al. Dissecting a circuit for olfactory behaviour in Caenorhabditis
elegans. Nature 450, 63-70 (2007).
29 Larsch, J. et al. A circuit for gradient climbing in C. elegans chemotaxis. Cell reports 12,
1748-1760 (2015).
30 Bargmann, C. I., Hartwieg, E. & Horvitz, H. R. Odorant-selective genes and neurons
mediate olfaction in C. elegans. Cell 74, 515-527 (1993).
31 Piggott, B. J., Liu, J., Feng, Z., Wescott, S. A. & Xu, X. S. The neural circuits and synaptic
mechanisms underlying motor initiation in C. elegans. Cell 147, 922-933 (2011).
32 Gleeson, P., Lung, D., Grosu, R., Hasani, R. & Larson, S. D. c302: a multiscale framework
for modelling the nervous system of <i>Caenorhabditis elegans</i>. Philosophical
Transactions of the Royal Society B: Biological Sciences 373, 20170379,
doi:doi:10.1098/rstb.2017.0379 (2018).
33 Grove, C. & Sternberg, P. in 18th International C. elegans Meeting.
34 Nicoletti, M. et al. Biophysical modeling of C. elegans neurons: Single ion currents and
whole-cell dynamics of AWCon and RMD. PLOS ONE 14, e0218738,
doi:10.1371/journal.pone.0218738 (2019).
35 Sheng, K. et al. Domain Adaptive Neural Inference for Neurons, Microcircuits and
Networks. bioRxiv 2022.2010. 2003.510694 (2022).
36 Ramot, D., MacInnis, B. L. & Goodman, M. B. Bidirectional temperature-sensing by a
single thermosensory neuron in C. elegans. Nature neuroscience 11, 908-915 (2008).
37 Liu, Q., Kidd, P. B., Dobosiewicz, M. & Bargmann, C. I. C. elegans AWA Olfactory
Neurons Fire Calcium-Mediated All-or-None Action Potentials. Cell 175, 57-70.e17
(2018).
38 Mellem, J. E., Brockie, P. J., Madsen, D. M. & Maricq, A. V. Action potentials contribute to
neuronal signaling in C. elegans. Nature neuroscience 11, 865-867 (2008).
39 Liu, P., Chen, B. & Wang, Z.-W. SLO-2 potassium channel is an important regulator of
(which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission. 
The copyright holder for this preprintthis version posted March 10, 2024. ; https://doi.org/10.1101/2024.02.22.581686doi: bioRxiv preprint

neurotransmitter release in Caenorhabditis elegans. Nature communications 5, 5155
(2014).
40 Mainen, Z. F. & Sejnowski, T. J. Influence of dendritic structure on firing pattern in model
neocortical neurons. Nature 382, 363 (1996).
41 Wicks, S. R., Roehrig, C. J. & Rankin, C. H. A dynamic network simulation of the
nematode tap withdrawal circuit: predictions concerning synaptic function using
behavioral criteria. Journal of Neuroscience 16, 4017-4031 (1996).
42 Prinz, A. A., Bucher, D. & Marder, E. Similar network activity from disparate circuit
parameters. Nature Neuroscience 7, 1345-1352, doi:10.1038/nn1352 (2004).
43 Sakata, K. & Shingai, R. Neural network model to generate head swing in locomotion of
Caenorhabditis elegans. Network: Computation in Neural Systems 15, 199 (2004).
44 Min, S., Won, J., Lee, S., Park, J. & Lee, J. Softcon: Simulation and control of soft-bodied
animals with biomimetic actuators. ACM Transactions on Graphics (TOG) 38, 1-12
(2019).
45 Sznitman, J., Purohit, P. K., Krajacic, P., Lamitina, T. & Arratia, P. E. Material Properties of
<em>Caenorhabditis elegans</em> Swimming at Low Reynolds Number. Biophysical
Journal 98, 617-626, doi:10.1016/j.bpj.2009.11.010 (2010).
46 Bilbao, A., Patel, A. K., Rahman, M., Vanapalli, S. A. & Blawzdziewicz, J. Roll maneuvers
are essential for active reorientation of Caenorhabditis elegans in 3D media.
Proceedings of the National Academy of Sciences 115, E3616-E3625 (2018).
47 Salfelder, F. et al. Markerless 3D spatio-temporal reconstruction of microscopic
swimmers from video. visual observation and analysis of vertebrate and insect behavior
(2020).
48 Bhovad, P. & Li, S. Physical reservoir computing with origami and its application to
robotic crawling. Scientific Reports 11, 13002, doi:10.1038/s41598-021-92257-1 (2021).
49 Wen, Q. et al. Proprioceptive coupling within motor neurons drives C. elegans forward
locomotion. Neuron 76, 750-761 (2012).
50 Kwon, N., Pyo, J., Lee, S.-J. & Je, J. H. 3-D worm tracker for freely moving C. elegans.
PloS one 8, e57484 (2013).
(which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission. 
The copyright holder for this preprintthis version posted March 10, 2024. ; https://doi.org/10.1101/2024.02.22.581686doi: bioRxiv preprint

Methods 
1 Details of Neural Network Model 
1.1 Neuron models 
Neurons were modeled by morphologically derived multi-compartmental models with 
somatic Hodgkin-Huxley dynamics1 and passive neurites. These neuron models captured both 
the biophysical properties and spatial complexity of neurons. The models integrated three 
kinds of neuron data: ion channel, morphology, and electrophysiology.  
Ion channel models were determined according to published studies2. There were 14 ion 
channels divided into 4 categories: voltage-gated potassium channels (SHK-1, EGL-36, SHL-
1, KVS-1, KQT-3, EGL-2, IRK1/3), calcium-regulated potassium channels (SLO1, SLO2, 
KCNL), voltage- gated calcium channels (EGL19, UNC2, CCA1), and passive sodium 
channel (NCA). Model equations and parameters for ion channels are given in Supplementary 
Table S1 and Supplementary Table S2. 
As for morphologies of neuron models, the spatial structures were adopted from the C. 
elegans neuronal anatomy models created by the Virtual Worm Project3 and the OpenWorm 
Project4. Each neuron model had a soma section and several neurite sections. Neurite sections 
were further divided into several compartments, each of which was shorter than 2 μm. 
Only soma compartment had active i on currents. Soma compartments and neurite 
compartments shared the same passive properties. To identify the passive and active 
parameters of neuron models, a deep learning tool5, was used to fine-tune these parameters to 
reproduce experimental data of voltage /current clamp. The value of the parameters can be 
found in Supplement Table S3. 
Less than 20% of the C. elegans  neurons have been recorded for the desired 
electrophysiology data. To estimate model parameters for those neurons that were not 
recorded, a method was implemented to generalize parameter values. First, considering the 
available data and hierarchy of information flow in C. elegans nervous system6,7, the neurons 
were divided into 5 functional groups (sensory neuron, interneuron, command interneuron, 
head motor neuron, and body motor neuron, see Supplement Table S4). Second, 5 neurons of 
each functional group (AWA8, AIY8, AVA9, RIM8, and VD510) were selected and their model 
parameters were optimized as described above. These parameter values of optimized neuron 
models were then generalized to other neuron models according to their functional categories. 
In other words, neuron models in the same functional group share identical electrical 
parameters. Each neuron models have their own morphologies yet similar electrical properties 
to those neurons in the same functional group. 
1.2 Graded synapse and gap junction models 
The neuron models were connected by graded synapses8,11 and gap junctions12 in C. elegans 
neural network. Graded synapses, include excitatory and inhibitory synapses, were modeled 
according to published C. elegans  models 4,13,14. The synaptic conductance is continuously 
changed with presynaptic membrane potential. Postsynaptic current is given by: 
(which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission. 
The copyright holder for this preprintthis version posted March 10, 2024. ; https://doi.org/10.1101/2024.02.22.581686doi: bioRxiv preprint

⎩
⎪
⎨
⎪
⎧ 𝐼𝐼 = −𝑤𝑤𝑤𝑤(𝐸𝐸 − 𝑉𝑉 )
𝑑𝑑𝑤𝑤
𝑑𝑑
𝑑𝑑 = 𝑤𝑤∞ − 𝑤𝑤
𝜏𝜏
𝑤𝑤∞ = 1
1 + 𝑒𝑒
𝑉𝑉𝑡𝑡ℎ−𝑉𝑉𝑝𝑝𝑝𝑝𝑝𝑝
𝛿𝛿
, 𝜏𝜏 = 1 − 𝑤𝑤∞
𝑘𝑘
 
where 𝑤𝑤 is maximal postsynaptic membrane conductance for the synapse, 𝑤𝑤 is a voltage-
sensitive parameter controlling the conductance, 𝐸𝐸 is the reversal potential, 𝜏𝜏 is the time 
constant of s, 𝑉𝑉𝑡𝑡ℎ  is the presynaptic equilibrium potential at the middle of the voltage 
sensitive range, 𝑉𝑉𝑝𝑝𝑝𝑝𝑝𝑝 is the pre-synaptic membrane potential. 
Ga
p junctions were modeled as simple resistances, where current flowing from presynaptic 
cell to postsynaptic cell is given by: 
𝐼𝐼 = −𝑤𝑤�𝑉𝑉pre − 𝑉𝑉� 
where 𝑤𝑤 is the conductance of gap junction. 
The parameter values of these synapses were set according to published models12: the 
conductance of the synapses and gap junctions had the same order of magnitude of 1e-4 μS. 
The specific weight of each synaptic connection in a specific neural network can be set 
randomly or be optimized according to a target, as described in Method 1.4. 
1.3 Connection locations 
Detailed neuron connections in the neural network model were located on the neuronal 
neurite (axons or dendrites) of the neurons, which were based on the neuron connectivity 
matrices and a neurite connectivity algorithm. 
The neuron connectivity matrices were acquired from published connectome data6,15. The 
original data in the matrices was the total number of electron microscopy (EM) series of all 
synapses (or gap junctions) between two neurons. In our work, the number of EM series was 
transformed into the number of synapses (or gap junctions) by: 
𝑁𝑁 = 𝑎𝑎 ∙ tanh(𝑏𝑏 ∙ 𝐶𝐶) 
where 𝐶𝐶  is the number of EM series, 𝑎𝑎  and 𝑏𝑏  are constants. For synapses number 
transformation, 𝑎𝑎 = 23.91,𝑏𝑏 = 0.02285, while for gap junction, 𝑎𝑎 = 20.49, 𝑏𝑏 = 0.02184. 
These parameters were inferred from partial-animal connectome data6. 
After the number of synapses (or gap junctions) was determined, the locations of synapses 
(or gap junction) on neural neurites were identified by a connection algorithm. The algorithm 
was based on the rule that distances between the centroid coordinates of possible presynaptic 
and postsynaptic neurites follow a certain statistical distribution16. We fitted synapse and gap 
junction distribution by two Inverse Gaussian distributions: 
𝑓𝑓(𝑥𝑥, 𝜇𝜇) = 1
𝑘𝑘 ∙ √2𝜋𝜋𝑥𝑥3 exp �− (𝑥𝑥 − 𝜇𝜇)2
2𝑥𝑥𝜇𝜇2 � 
where 𝜇𝜇 = 0.44, 𝑘𝑘  = 0.63 for synapse distribution, 𝜇𝜇 = 0.70, 𝑘𝑘 = 0.40 for gap junction 
distribution. The algorithm of generating connection locations was designed: 
Algorithm 1. Generate connection locations. 
Input: 
𝐴𝐴�𝑎𝑎0, 𝑎𝑎1, … ,𝑎𝑎𝑁𝑁𝑎𝑎−1�: set of all compartments of neuron A. 
𝐵𝐵�𝑏𝑏0, 𝑏𝑏1, … ,𝑏𝑏𝑁𝑁𝑏𝑏−1�: set of all compartments of another neuron B. 
𝑁𝑁𝑠𝑠 �𝑁𝑁𝑔𝑔�: desired synapses (gap junctions) number between these two neurons. 
𝐷𝐷𝑠𝑠 �𝐷𝐷𝑔𝑔� : Inverse Gaussian distribution of synapses (gap junctions) fitted 
(which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission. 
The copyright holder for this preprintthis version posted March 10, 2024. ; https://doi.org/10.1101/2024.02.22.581686doi: bioRxiv preprint

above. 
𝑑𝑑𝑡𝑡ℎ: distance threshold of one synapse (gap junction).  
𝜌𝜌: arrangement priority factor between synapse and gap junction.  
Output: 
𝐶𝐶𝑠𝑠��𝑎𝑎𝑖𝑖1
𝑠𝑠 , 𝑏𝑏𝑗𝑗1
𝑠𝑠 �, �𝑎𝑎𝑖𝑖2
𝑠𝑠 , 𝑏𝑏𝑗𝑗2
𝑠𝑠 �, … ,�𝑎𝑎𝑖𝑖𝑁𝑁
𝑠𝑠 , 𝑏𝑏𝑗𝑗𝑁𝑁
𝑠𝑠 ��  ( 𝐶𝐶𝑔𝑔 ): set of synapse (gap junction) 
compartments that best approximates 𝐷𝐷𝑠𝑠 (𝐷𝐷𝑔𝑔) distribution. 
A
lgorithm: 
r
andomly sample synapses (gap junction) distances 𝑇𝑇𝑠𝑠�𝑑𝑑0
𝑠𝑠, 𝑑𝑑1
𝑠𝑠, … ,𝑑𝑑𝑁𝑁𝑠𝑠−1
𝑠𝑠 � ( 𝑇𝑇𝑔𝑔 ) 
according to 𝐷𝐷𝑠𝑠(𝐷𝐷𝑔𝑔). 
in
itialize distance matrix 𝑀𝑀 
for 𝑖𝑖 = 0 … ( 𝑁𝑁𝑎𝑎 − 1) do 
for 𝑗𝑗 = 0  …  (𝑁𝑁𝑏𝑏 − 1) do 
 𝑀𝑀𝑖𝑖,𝑗𝑗 ≔ Euclidean_Distance�𝑎𝑎𝑖𝑖, 𝑏𝑏𝑗𝑗� 
        end for  
end for 
i
nitial index pointer 𝑝𝑝𝑑𝑑𝑟𝑟𝑠𝑠(𝑝𝑝𝑑𝑑𝑟𝑟𝑔𝑔) of synapses (gap junction) allocation status 
𝑝𝑝𝑑𝑑𝑟𝑟𝑠𝑠  ≔  0  
𝑝𝑝𝑑𝑑𝑟𝑟𝑔𝑔  ≔  0  
w
hile (𝑝𝑝𝑑𝑑𝑟𝑟𝑠𝑠 < 𝑁𝑁𝑠𝑠) 𝑜𝑜 𝑟𝑟 �𝑝𝑝𝑑𝑑𝑟𝑟𝑔𝑔 < 𝑁𝑁𝑔𝑔� do 
r
andomly sampled a uniform[0,1] variable 𝑟𝑟 
if �(𝑟𝑟 < ρ) 𝑜𝑜
𝑟𝑟 �𝑝𝑝𝑑𝑑𝑟𝑟𝑔𝑔 == 𝑁𝑁𝑔𝑔��  𝑎𝑎𝑎𝑎𝑑𝑑 (𝑝𝑝𝑑𝑑𝑟𝑟𝑠𝑠 < 𝑁𝑁𝑠𝑠) then 
f
ind connection �𝑎𝑎𝑝𝑝, 𝑏𝑏𝑞𝑞� in distance matrix 𝑀𝑀 closest to 𝑑𝑑𝑝𝑝𝑡𝑡𝑝𝑝𝑠𝑠
𝑠𝑠  
if �𝑀𝑀𝑝𝑝,𝑞𝑞 < 𝑑𝑑𝑡𝑡ℎ � then 
Append �𝑎𝑎𝑝𝑝, 𝑏𝑏𝑞𝑞� to 𝐶𝐶𝑠𝑠 
 
𝑀𝑀𝑝𝑝,∗ ≔ 𝑖𝑖 𝑎𝑎𝑓𝑓  
 
𝑀𝑀𝑞𝑞,∗ ≔ 𝑖𝑖 𝑎𝑎𝑓𝑓  
e
nd if 
           𝑝𝑝𝑑𝑑𝑟𝑟𝑠𝑠 ≔ 𝑝𝑝𝑑𝑑𝑟𝑟𝑠𝑠 + 1; 
el
se 
f
ind connection �𝑎𝑎𝑝𝑝, 𝑏𝑏𝑞𝑞� in distance matrix 𝑀𝑀 closest to 𝑑𝑑𝑝𝑝𝑡𝑡𝑝𝑝𝑔𝑔
𝑔𝑔  
if �𝑀𝑀𝑝𝑝,𝑞𝑞 < 𝑑𝑑𝑡𝑡ℎ � then 
Append �𝑎𝑎𝑝𝑝, 𝑏𝑏𝑞𝑞� to 𝐶𝐶𝑔𝑔 
 
𝑀𝑀𝑝𝑝,∗ ≔ 𝑖𝑖 𝑎𝑎𝑓𝑓 
 
𝑀𝑀𝑞𝑞,∗ ≔ 𝑖𝑖 𝑎𝑎𝑓𝑓 
e
nd if 
           𝑝𝑝𝑑𝑑𝑟𝑟𝑔𝑔 ≔ 𝑝𝑝𝑑𝑑𝑟𝑟𝑔𝑔 + 1; 
e
nd if 
end while 
return 𝐶𝐶𝑠𝑠, 𝐶𝐶𝑔𝑔 
1.4 C. elegans neural network model 
(which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission. 
The copyright holder for this preprintthis version posted March 10, 2024. ; https://doi.org/10.1101/2024.02.22.581686doi: bioRxiv preprint