logo Netzschleuder network catalog, repository, and centrifuge

History of celegans_multiplex

The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.

[entries] New entry: celegans_multiplex by Tiago de Paula Peixoto 9a4816d
diff --git a/entries/celegans_multiplex/__init__.py b/entries/celegans_multiplex/__init__.py
new file mode 100644
index 0000000..292ec2f
--- /dev/null
+++ b/entries/celegans_multiplex/__init__.py
@@ -0,0 +1,74 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020-2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from .. import *
+
+title = "C. elegans multiplex connectome (2006)"
+description = r"""A multiplex network of the neurons of the hermaphrodite nematode *Caenorhabditis elegans*, distributed by M. De Domenico and based on the wiring diagram compiled by Chen, Hall and Chklovskii (2006) from the serial-section electron micrographs of White et al. (1986). Nodes are the 279 neurons, identified by their names, and an undirected edge in a layer connects two neurons joined by a synapse of the corresponding type. There are three layers:
+
+- `ElectrJ` (517 edges): electrical junctions (gap junctions);
+- `MonoSyn` (888 edges): monadic chemical synapses, with a single postsynaptic partner;
+- `PolySyn` (1,703 edges): polyadic chemical synapses, with several postsynaptic partners.
+
+The README of the data set describes the network as undirected and unweighted. Although it says that only one direction of each edge is specified, most pairs of neurons are listed in both orientations within a layer (all of them in `ElectrJ`, and about 90% in the two chemical layers), so the direction does not distinguish pre- from postsynaptic neurons; such pairs are included here only once, which reduces the 5,863 listed connections to 3,108 edges. The `ElectrJ` layer contains three self-loops (`RIBL`, `RIBR` and `VA08`). Neither the number of synapses nor their direction is available.
+
+The same neurons, with the direction and the number of synapses of each connection, are in the entry `celegans_varshney`, which is based on the updated and revised reconstruction of Varshney et al. (2011), in which chemical synapses are not separated into monadic and polyadic ones.
+
+The network has the following properties:
+
+- Nodes: `name` and `nodeLabel`, the neuron name (e.g. `ADAL`).
+- Edges: `layer`, the synapse type (1: electrical junction, 2: monadic chemical synapse, 3: polyadic chemical synapse; the names are stored in the graph property `layer_key`); `weight`, which is always 1."""
+tags = ['Biological', 'Connectome', 'Multilayer', 'Unweighted']
+url = 'https://manliodedomenico.com/data.php'
+citation = [('B. L. Chen, D. H. Hall, D. B. Chklovskii, "Wiring optimization can relate neuronal structure and function." Proceedings of the National Academy of Sciences 103(12), 4723-4728 (2006)', 'https://doi.org/10.1073/pnas.0506806103'),
+            ('M. De Domenico, M. A. Porter, A. Arenas, "MuxViz: a tool for multilayer analysis and visualization of networks." Journal of Complex Networks 3(2), 159-176 (2015)', 'https://doi.org/10.1093/comnet/cnu038')]
+icon_hash = None
+upstream_license = ('Open Data Commons Open Database License (ODbL)', 'https://opendatacommons.org/licenses/odbl/')
+upstream_prefix = 'https://manliodedomenico.com/data'
+files = [('CElegans_Multiplex_Neuronal.zip', None, 'comunelab')]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    global files
+    name = __name__.split(".")[-1]
+    for fnames, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        if isinstance(fnames, str):
+            fnames = [fnames]
+        with ExitStack() as stack:
+            fs = [stack.enter_context(open_upstream_file(name, fn, "rb")) for fn in fnames]
+            g = parse_graph(fs, fmt, directed=False)
+        # most pairs are listed in both orientations in the same layer (all
+        # weights are 1); keep only the first occurrence of each pair
+        E = g.get_edges([g.ep.layer, g.edge_index])
+        key = numpy.stack([E[:, 2], numpy.minimum(E[:, 0], E[:, 1]),
+                           numpy.maximum(E[:, 0], E[:, 1])], 1)
+        _, idx = numpy.unique(key, axis=0, return_index=True)
+        efilt = g.new_ep("bool")
+        efilt.a[E[idx, 3].astype("int")] = True
+        g.set_edge_filter(efilt)
+        g.purge_edges()
+        g.clear_filters()
+        yield alt, g