Connectomics

[2]:
!pip install vfb-connect python-catmaid navis --upgrade
Requirement already satisfied: vfb-connect in /root/venv/lib/python3.7/site-packages (1.2.5)
Requirement already satisfied: python-catmaid in /root/venv/lib/python3.7/site-packages (2.0.4)
Requirement already satisfied: navis in /root/venv/lib/python3.7/site-packages (0.5.3)
Requirement already satisfied: pypng>=0.0.18 in /root/venv/lib/python3.7/site-packages (from navis) (0.0.20)
Requirement already satisfied: trimesh>=3.8 in /root/venv/lib/python3.7/site-packages (from navis) (3.9.15)
Requirement already satisfied: pynrrd>=0.4.2 in /root/venv/lib/python3.7/site-packages (from navis) (0.4.2)
Requirement already satisfied: networkx>=2.4 in /root/venv/lib/python3.7/site-packages (from navis) (2.5.1)
Requirement already satisfied: six>=1.11 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from navis) (1.15.0)
Requirement already satisfied: vispy>=0.6.4 in /root/venv/lib/python3.7/site-packages (from navis) (0.6.6)
Requirement already satisfied: ncollpyde>=0.11 in /root/venv/lib/python3.7/site-packages (from navis) (0.14.0)
Requirement already satisfied: setuptools>=50.6 in /root/venv/lib/python3.7/site-packages (from navis) (54.1.2)
Requirement already satisfied: tqdm>=4.45 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from navis) (4.60.0)
Requirement already satisfied: typing-extensions>=3.7.4 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from navis) (3.7.4.3)
Requirement already satisfied: plotly>=4.9 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from navis) (4.14.3)
Requirement already satisfied: molesq>=0.2.0 in /root/venv/lib/python3.7/site-packages (from navis) (0.3.1)
Requirement already satisfied: pint>=0.10 in /root/venv/lib/python3.7/site-packages (from navis) (0.17)
Requirement already satisfied: seaborn>=0.10 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from navis) (0.11.1)
Requirement already satisfied: h5py>=3.1 in /root/venv/lib/python3.7/site-packages (from navis) (3.2.1)
Requirement already satisfied: requests>=2.20 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from navis) (2.25.1)
Requirement already satisfied: PyQt5>=5.15 in /root/venv/lib/python3.7/site-packages (from navis) (5.15.4)
Requirement already satisfied: numpy>=1.16 in /root/venv/lib/python3.7/site-packages (from navis) (1.20.2)
Requirement already satisfied: morphops>=0.1.11 in /root/venv/lib/python3.7/site-packages (from navis) (0.1.12)
Requirement already satisfied: scipy>=1.5 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from navis) (1.6.2)
Requirement already satisfied: fuzzywuzzy>=0.18 in /root/venv/lib/python3.7/site-packages (from navis) (0.18.0)
Requirement already satisfied: pandas>=1.0 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from navis) (1.2.4)
Requirement already satisfied: matplotlib>=3.2 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from navis) (3.4.1)
Requirement already satisfied: cached-property in /root/venv/lib/python3.7/site-packages (from h5py>=3.1->navis) (1.5.2)
Requirement already satisfied: python-dateutil>=2.7 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from matplotlib>=3.2->navis) (2.8.1)
Requirement already satisfied: pillow>=6.2.0 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from matplotlib>=3.2->navis) (8.2.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from matplotlib>=3.2->navis) (1.3.1)
Requirement already satisfied: cycler>=0.10 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from matplotlib>=3.2->navis) (0.10.0)
Requirement already satisfied: pyparsing>=2.2.1 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from matplotlib>=3.2->navis) (2.4.7)
Collecting decorator<5,>=4.3
  Using cached decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Requirement already satisfied: pytz>=2017.3 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from pandas>=1.0->navis) (2021.1)
Requirement already satisfied: packaging in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from pint>=0.10->navis) (20.9)
Requirement already satisfied: importlib-metadata in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from pint>=0.10->navis) (3.10.1)
Requirement already satisfied: retrying>=1.3.3 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from plotly>=4.9->navis) (1.3.3)
Requirement already satisfied: PyQt5-Qt5>=5.15 in /root/venv/lib/python3.7/site-packages (from PyQt5>=5.15->navis) (5.15.2)
Requirement already satisfied: PyQt5-sip<13,>=12.8 in /root/venv/lib/python3.7/site-packages (from PyQt5>=5.15->navis) (12.8.1)
Requirement already satisfied: chardet<5,>=3.0.2 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests>=2.20->navis) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests>=2.20->navis) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests>=2.20->navis) (2020.12.5)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests>=2.20->navis) (1.26.4)
Requirement already satisfied: freetype-py in /root/venv/lib/python3.7/site-packages (from vispy>=0.6.4->navis) (2.2.0)
Requirement already satisfied: requests-futures>=0.9.9 in /root/venv/lib/python3.7/site-packages (from python-catmaid) (1.0.0)
Requirement already satisfied: psutil>=5.4.3 in /root/venv/lib/python3.7/site-packages (from python-catmaid) (5.8.0)
Requirement already satisfied: jsonpath-rw in /root/venv/lib/python3.7/site-packages (from vfb-connect) (1.4.0)
Requirement already satisfied: zipp>=0.5 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from importlib-metadata->pint>=0.10->navis) (3.4.1)
Requirement already satisfied: ply in /root/venv/lib/python3.7/site-packages (from jsonpath-rw->vfb-connect) (3.11)
Installing collected packages: decorator
  Attempting uninstall: decorator
    Found existing installation: decorator 5.0.6
    Not uninstalling decorator at /shared-libs/python3.7/py-core/lib/python3.7/site-packages, outside environment /root/venv
    Can't uninstall 'decorator'. No files were found to uninstall.
Successfully installed decorator-4.4.2
WARNING: You are using pip version 21.0.1; however, version 21.1 is available.
You should consider upgrading via the '/root/venv/bin/python -m pip install --upgrade pip' command.
[ ]:
# Import libs and initialise API objects
from vfb_connect.cross_server_tools import VfbConnect
import pandas as pd
vc = VfbConnect()

import pymaid
import navis

navis.set_pbars(jupyter=False)
pymaid.set_pbars(jupyter=False)

# Connect to the VFB CATMAID server hosting the FAFB data
rm = pymaid.connect_catmaid(server="https://fafb.catmaid.virtualflybrain.org/", api_token=None, max_threads=10)

# Test call to see if connection works
print(f'Server is running CATMAID version {rm.catmaid_version}')

WARNING: Could not load OpenGL library.
INFO  : Global CATMAID instance set. Caching is ON. (pymaid)
Server is running CATMAID version 2020.02.15-990-gb5aac7433

VFB provides a simple methods for exploring connectomics data

get_connected_neurons_by_type allows queries for connections between defined upstream and downstream neuron types/classes. This supports a level of abstraction not available without VFB, where grouping of neurons by higher level classifications is limited to extraction of classification from standardised names. The following examples take advantage of the abstract clasifications on VFB to explore direct synaptic connections.

[ ]:
# Find all GABA-regic inputs onto descending neurons

vc.get_connected_neurons_by_type(upstream_type='GABAergic neuron',
                                 downstream_type='adult descending neuron',
                                 weight=10).sort_values('weight', ascending=False, ignore_index=True)
upstream_neuron_id upstream_neuron_name weight downstream_neuron_id downstream_neuron_name upstream_class downstream_class up_data_source up_accession down_source down_accession
0 VFB_jrchk7ji VP4_vPN(mlALT)_R - 634759240 65 VFB_jrchjthu DNp44_R - 542751938 adult antennal lobe projection neuron VP4 vPN descending neuron of the posterior brain DNp44 neuprint_JRC_Hemibrain_1point1 634759240 neuprint_JRC_Hemibrain_1point1 542751938
1 VFB_jrchk7jh VP4+_vPN(mlALT)_R - 543010474 50 VFB_jrchjthu DNp44_R - 542751938 adult antennal lobe projection neuron VP4+ vPN descending neuron of the posterior brain DNp44 neuprint_JRC_Hemibrain_1point1 543010474 neuprint_JRC_Hemibrain_1point1 542751938
2 VFB_jrchk7jh VP4+_vPN(mlALT)_R - 543010474 47 VFB_jrchjthj DNp25_R - 451689001 adult antennal lobe projection neuron VP4+ vPN descending neuron of the posterior brain DNp25 neuprint_JRC_Hemibrain_1point1 543010474 neuprint_JRC_Hemibrain_1point1 451689001
3 VFB_jrchk8dp oviIN_R - 423101189 43 VFB_jrchk8dm oviDNa_R - 550655668 oviposition inhibitory neuron oviposition descending neuron a neuprint_JRC_Hemibrain_1point1 423101189 neuprint_JRC_Hemibrain_1point1 550655668
4 VFB_jrchk8dq oviIN_L - 485934965 40 VFB_jrchk8do oviDNb_R - 519949044 oviposition inhibitory neuron oviposition descending neuron b neuprint_JRC_Hemibrain_1point1 485934965 neuprint_JRC_Hemibrain_1point1 519949044
5 VFB_jrchk8dp oviIN_R - 423101189 36 VFB_jrchk8do oviDNb_R - 519949044 oviposition inhibitory neuron oviposition descending neuron b neuprint_JRC_Hemibrain_1point1 423101189 neuprint_JRC_Hemibrain_1point1 519949044
6 VFB_jrchk8dp oviIN_R - 423101189 35 VFB_jrchk8dn oviDNb(PDM15)_L - 642763374 oviposition inhibitory neuron oviposition descending neuron b neuprint_JRC_Hemibrain_1point1 423101189 neuprint_JRC_Hemibrain_1point1 642763374
7 VFB_jrchk8dq oviIN_L - 485934965 32 VFB_jrchk8dn oviDNb(PDM15)_L - 642763374 oviposition inhibitory neuron oviposition descending neuron b neuprint_JRC_Hemibrain_1point1 485934965 neuprint_JRC_Hemibrain_1point1 642763374
8 VFB_jrchk7jh VP4+_vPN(mlALT)_R - 543010474 28 VFB_jrchjtg4 DNg30_R - 571346836 adult antennal lobe projection neuron VP4+ vPN descending neuron of the gnathal ganglion DNg30 neuprint_JRC_Hemibrain_1point1 543010474 neuprint_JRC_Hemibrain_1point1 571346836
9 VFB_jrchk8dq oviIN_L - 485934965 27 VFB_jrchk8dm oviDNa_R - 550655668 oviposition inhibitory neuron oviposition descending neuron a neuprint_JRC_Hemibrain_1point1 485934965 neuprint_JRC_Hemibrain_1point1 550655668
10 VFB_jrchjza4 LHPV2c1_b_R - 825032139 13 VFB_jrchjthr DNp32_R - 5813050455 adult lateral horn PV2c1 neuron descending neuron of the posterior brain DNp32 neuprint_JRC_Hemibrain_1point1 825032139 neuprint_JRC_Hemibrain_1point1 5813050455
11 VFB_jrchjtd8 CT1_L - 1311993208 12 VFB_jrchjtgf DNp11_R - 1281324958 tangential neuron CT1 descending neuron of the posterior brain DNp11 neuprint_JRC_Hemibrain_1point1 1311993208 neuprint_JRC_Hemibrain_1point1 1281324958
12 VFB_jrchjza6 LHPV2c1_c_R - 913345831 12 VFB_jrchjthr DNp32_R - 5813050455 adult lateral horn PV2c1 neuron descending neuron of the posterior brain DNp32 neuprint_JRC_Hemibrain_1point1 913345831 neuprint_JRC_Hemibrain_1point1 5813050455
13 VFB_jrchk7jh VP4+_vPN(mlALT)_R - 543010474 12 VFB_jrchjthh DNp24_R - 5813047199 adult antennal lobe projection neuron VP4+ vPN descending neuron of the posterior brain DNp24 neuprint_JRC_Hemibrain_1point1 543010474 neuprint_JRC_Hemibrain_1point1 5813047199
14 VFB_jrchjza3 LHPV2c1_b_R - 856066807 11 VFB_jrchjthr DNp32_R - 5813050455 adult lateral horn PV2c1 neuron descending neuron of the posterior brain DNp32 neuprint_JRC_Hemibrain_1point1 856066807 neuprint_JRC_Hemibrain_1point1 5813050455
15 VFB_jrchk7ji VP4_vPN(mlALT)_R - 634759240 10 VFB_jrchjtg4 DNg30_R - 571346836 adult antennal lobe projection neuron VP4 vPN descending neuron of the gnathal ganglion DNg30 neuprint_JRC_Hemibrain_1point1 634759240 neuprint_JRC_Hemibrain_1point1 571346836
16 VFB_jrchjymc LHAV1a3_R - 823999645 10 VFB_jrchjtht DNp42_R - 981000564 adult lateral horn AV1a3 neuron descending neuron of the posterior brain neuprint_JRC_Hemibrain_1point1 823999645 neuprint_JRC_Hemibrain_1point1 981000564
[ ]:
# Get connections between pacemaker neurons
vc.get_connected_neurons_by_type(upstream_type='pacemaker neuron',
                                 downstream_type='pacemaker neuron',
                                 weight=10).sort_values('weight', ascending=False)
upstream_neuron_id upstream_neuron_name weight downstream_neuron_id downstream_neuron_name upstream_class downstream_class up_data_source up_accession down_source down_accession
28 VFB_jrchjtex DN1a_R - 264083994 79 VFB_jrchjzxy LNd_R - 5813069648 DN1a neuron LNd neuron neuprint_JRC_Hemibrain_1point1 264083994 neuprint_JRC_Hemibrain_1point1 5813069648
26 VFB_jrchjtey DN1a_R - 5813022274 75 VFB_jrchjzxy LNd_R - 5813069648 DN1a neuron LNd neuron neuprint_JRC_Hemibrain_1point1 5813022274 neuprint_JRC_Hemibrain_1point1 5813069648
23 VFB_jrchjtey DN1a_R - 5813022274 63 VFB_jrchk8e0 5th s-LNv - 511051477 DN1a neuron s-LNv neuron neuprint_JRC_Hemibrain_1point1 5813022274 neuprint_JRC_Hemibrain_1point1 511051477
22 VFB_jrchjtex DN1a_R - 264083994 55 VFB_jrchk8e0 5th s-LNv - 511051477 DN1a neuron s-LNv neuron neuprint_JRC_Hemibrain_1point1 264083994 neuprint_JRC_Hemibrain_1point1 511051477
3 VFB_jrchk089 LPN_R - 480029788 43 VFB_jrchk08a LPN_R - 450034902 LP neuron LP neuron neuprint_JRC_Hemibrain_1point1 480029788 neuprint_JRC_Hemibrain_1point1 450034902
7 VFB_jrchk8e0 5th s-LNv - 511051477 40 VFB_jrchjzxy LNd_R - 5813069648 s-LNv neuron LNd neuron neuprint_JRC_Hemibrain_1point1 511051477 neuprint_JRC_Hemibrain_1point1 5813069648
1 VFB_jrchjzxy LNd_R - 5813069648 37 VFB_jrchk8e0 5th s-LNv - 511051477 LNd neuron s-LNv neuron neuprint_JRC_Hemibrain_1point1 5813069648 neuprint_JRC_Hemibrain_1point1 511051477
5 VFB_jrchjtf0 DN1pA_R - 324846570 37 VFB_jrchjzxy LNd_R - 5813069648 DN1p neuron LNd neuron neuprint_JRC_Hemibrain_1point1 324846570 neuprint_JRC_Hemibrain_1point1 5813069648
16 VFB_jrchjtf2 DN1pA_R - 387944118 34 VFB_jrchjzxy LNd_R - 5813069648 DN1p neuron LNd neuron neuprint_JRC_Hemibrain_1point1 387944118 neuprint_JRC_Hemibrain_1point1 5813069648
20 VFB_jrchjtf1 DN1pA_R - 325529237 33 VFB_jrchk8e0 5th s-LNv - 511051477 DN1p neuron s-LNv neuron neuprint_JRC_Hemibrain_1point1 325529237 neuprint_JRC_Hemibrain_1point1 511051477
29 VFB_jrchjtf3 DN1pA_R - 387166379 30 VFB_jrchjzxy LNd_R - 5813069648 DN1p neuron LNd neuron neuprint_JRC_Hemibrain_1point1 387166379 neuprint_JRC_Hemibrain_1point1 5813069648
11 VFB_jrchjtf1 DN1pA_R - 325529237 30 VFB_jrchjzxy LNd_R - 5813069648 DN1p neuron LNd neuron neuprint_JRC_Hemibrain_1point1 325529237 neuprint_JRC_Hemibrain_1point1 5813069648
21 VFB_jrchk08a LPN_R - 450034902 30 VFB_jrchk089 LPN_R - 480029788 LP neuron LP neuron neuprint_JRC_Hemibrain_1point1 450034902 neuprint_JRC_Hemibrain_1point1 480029788
14 VFB_jrchjzxy LNd_R - 5813069648 29 VFB_jrchjzxw LNd_R - 5813056917 LNd neuron LNd neuron neuprint_JRC_Hemibrain_1point1 5813069648 neuprint_JRC_Hemibrain_1point1 5813056917
10 VFB_jrchk8e0 5th s-LNv - 511051477 25 VFB_jrchjzxx LNd_R - 5813021192 s-LNv neuron LNd neuron neuprint_JRC_Hemibrain_1point1 511051477 neuprint_JRC_Hemibrain_1point1 5813021192
8 VFB_jrchjtf3 DN1pA_R - 387166379 25 VFB_jrchk8e0 5th s-LNv - 511051477 DN1p neuron s-LNv neuron neuprint_JRC_Hemibrain_1point1 387166379 neuprint_JRC_Hemibrain_1point1 511051477
4 VFB_jrchjtf0 DN1pA_R - 324846570 25 VFB_jrchk8e0 5th s-LNv - 511051477 DN1p neuron s-LNv neuron neuprint_JRC_Hemibrain_1point1 324846570 neuprint_JRC_Hemibrain_1point1 511051477
12 VFB_jrchjtez DN1pA_R - 5813010153 25 VFB_jrchk8e0 5th s-LNv - 511051477 DN1p neuron s-LNv neuron neuprint_JRC_Hemibrain_1point1 5813010153 neuprint_JRC_Hemibrain_1point1 511051477
15 VFB_jrchjtf2 DN1pA_R - 387944118 22 VFB_jrchk8e0 5th s-LNv - 511051477 DN1p neuron s-LNv neuron neuprint_JRC_Hemibrain_1point1 387944118 neuprint_JRC_Hemibrain_1point1 511051477
30 VFB_jrchjzxy LNd_R - 5813069648 21 VFB_jrchjzxx LNd_R - 5813021192 LNd neuron LNd neuron neuprint_JRC_Hemibrain_1point1 5813069648 neuprint_JRC_Hemibrain_1point1 5813021192
2 VFB_jrchk8e0 5th s-LNv - 511051477 17 VFB_jrchjzxw LNd_R - 5813056917 s-LNv neuron LNd neuron neuprint_JRC_Hemibrain_1point1 511051477 neuprint_JRC_Hemibrain_1point1 5813056917
13 VFB_jrchjtez DN1pA_R - 5813010153 15 VFB_jrchjzxy LNd_R - 5813069648 DN1p neuron LNd neuron neuprint_JRC_Hemibrain_1point1 5813010153 neuprint_JRC_Hemibrain_1point1 5813069648
24 VFB_jrchk8e0 5th s-LNv - 511051477 14 VFB_jrchjtf3 DN1pA_R - 387166379 s-LNv neuron DN1p neuron neuprint_JRC_Hemibrain_1point1 511051477 neuprint_JRC_Hemibrain_1point1 387166379
25 VFB_jrchjzxy LNd_R - 5813069648 14 VFB_jrchjtf1 DN1pA_R - 325529237 LNd neuron DN1p neuron neuprint_JRC_Hemibrain_1point1 5813069648 neuprint_JRC_Hemibrain_1point1 325529237
0 VFB_jrchjtf0 DN1pA_R - 324846570 13 VFB_jrchjzxx LNd_R - 5813021192 DN1p neuron LNd neuron neuprint_JRC_Hemibrain_1point1 324846570 neuprint_JRC_Hemibrain_1point1 5813021192
17 VFB_jrchjzxy LNd_R - 5813069648 13 VFB_jrchjtf3 DN1pA_R - 387166379 LNd neuron DN1p neuron neuprint_JRC_Hemibrain_1point1 5813069648 neuprint_JRC_Hemibrain_1point1 387166379
9 VFB_jrchk8e0 5th s-LNv - 511051477 12 VFB_jrchjtf1 DN1pA_R - 325529237 s-LNv neuron DN1p neuron neuprint_JRC_Hemibrain_1point1 511051477 neuprint_JRC_Hemibrain_1point1 325529237
19 VFB_jrchjtf5 DN1pB_R - 5813071319 11 VFB_jrchjzxy LNd_R - 5813069648 DN1p neuron LNd neuron neuprint_JRC_Hemibrain_1point1 5813071319 neuprint_JRC_Hemibrain_1point1 5813069648
31 VFB_jrchjtey DN1a_R - 5813022274 11 VFB_jrchjtex DN1a_R - 264083994 DN1a neuron DN1a neuron neuprint_JRC_Hemibrain_1point1 5813022274 neuprint_JRC_Hemibrain_1point1 264083994
18 VFB_jrchjzxy LNd_R - 5813069648 10 VFB_jrchjtez DN1pA_R - 5813010153 LNd neuron DN1p neuron neuprint_JRC_Hemibrain_1point1 5813069648 neuprint_JRC_Hemibrain_1point1 5813010153
27 VFB_jrchjtex DN1a_R - 264083994 10 VFB_jrchjtey DN1a_R - 5813022274 DN1a neuron DN1a neuron neuprint_JRC_Hemibrain_1point1 264083994 neuprint_JRC_Hemibrain_1point1 5813022274
6 VFB_jrchjzxy LNd_R - 5813069648 10 VFB_jrchjtf2 DN1pA_R - 387944118 LNd neuron DN1p neuron neuprint_JRC_Hemibrain_1point1 5813069648 neuprint_JRC_Hemibrain_1point1 387944118
[ ]:
vc.get_connected_neurons_by_type(upstream_type='pacemaker neuron',
                                 downstream_type='pacemaker neuron',
                                 weight=10).sort_values('weight', ascending=False)
[ ]:
vc.get_connected_neurons_by_type(upstream_type='adult neuron',
                                 downstream_type='neurosecretory cell of pars intercerebralis',
                                 weight=10)
upstream_neuron_id upstream_neuron_name weight downstream_neuron_id downstream_neuron_name upstream_class downstream_class up_data_source up_accession down_source down_accession
0 VFB_jrchk6pq SMP302_R (FlyEM-HB:481410841) 18 VFB_jrchk3rl PI1_c (FlyEM-HB:5813026416) adult superior medial protocerebrum neuron 302 adult neurosecretory cell of pars intercerebralis None None None None
1 VFB_jrchk70e SMP454(PDM12)_L (FlyEM-HB:328010530) 31 VFB_jrchk3rw PI3 (FlyEM-HB:859339195) adult superior medial protocerebrum neuron 454 adult neurosecretory cell of pars intercerebralis None None None None
2 VFB_jrchk541 SIFa(PDM34) (FlyEM-HB:699031185) 11 VFB_jrchk543 SIFa(PDM34) (FlyEM-HB:5813062866) adult SIFamide cell of pars intercerebralis adult SIFamide cell of pars intercerebralis None None None None
3 VFB_jrchk59h SIP076_R (FlyEM-HB:299954300) 13 VFB_jrchk3rc PI1_b (FlyEM-HB:514530654) adult superior intermediate protocerebrum neur... adult neurosecretory cell of pars intercerebralis None None None None
4 VFB_jrchk72y SMP484_R (FlyEM-HB:298254380) 12 VFB_jrchk3rd PI1_b (FlyEM-HB:5813057164) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
5 VFB_jrchk6k0 SMP218_R (FlyEM-HB:357940977) 11 VFB_jrchk544 SIFa(PDM34) (FlyEM-HB:1137590785) adult superior medial protocerebrum neuron 218 adult SIFamide cell of pars intercerebralis None None None None
6 VFB_jrchjti7 DSKMP3_R (FlyEM-HB:328559607) 10 VFB_jrchk3rd PI1_b (FlyEM-HB:5813057164) adult Drosulfakinin neuron adult neurosecretory cell of pars intercerebralis None None None None
7 VFB_jrchk731 SMP484_R (FlyEM-HB:329918685) 29 VFB_jrchk3re PI1_b (FlyEM-HB:5813047717) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
8 VFB_jrchk736 SMP486_a_R (FlyEM-HB:297251765) 18 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 486 adult neurosecretory cell of pars intercerebralis None None None None
9 VFB_jrchk731 SMP484_R (FlyEM-HB:329918685) 18 VFB_jrchk3rh PI1_b (FlyEM-HB:5813014245) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
10 VFB_jrchk736 SMP486_a_R (FlyEM-HB:297251765) 10 VFB_jrchk3rh PI1_b (FlyEM-HB:5813014245) adult superior medial protocerebrum neuron 486 adult neurosecretory cell of pars intercerebralis None None None None
11 VFB_jrchk6ph SMP298_R (FlyEM-HB:727285326) 10 VFB_jrchk3re PI1_b (FlyEM-HB:5813047717) adult superior medial protocerebrum neuron 298 adult neurosecretory cell of pars intercerebralis None None None None
12 VFB_jrchjti0 DPM_R (FlyEM-HB:5813105172) 15 VFB_jrchk542 SIFa(PDM34) (FlyEM-HB:1418618235) mushroom body dorsal paired medial cell adult SIFamide cell of pars intercerebralis None None None None
13 VFB_jrchk6pg SMP298_R (FlyEM-HB:5813011015) 14 VFB_jrchk3rh PI1_b (FlyEM-HB:5813014245) adult superior medial protocerebrum neuron 298 adult neurosecretory cell of pars intercerebralis None None None None
14 VFB_jrchk6jx SMP217_R (FlyEM-HB:5813063151) 10 VFB_jrchk544 SIFa(PDM34) (FlyEM-HB:1137590785) adult superior medial protocerebrum neuron 217 adult SIFamide cell of pars intercerebralis None None None None
15 VFB_jrchk736 SMP486_a_R (FlyEM-HB:297251765) 10 VFB_jrchk3rd PI1_b (FlyEM-HB:5813057164) adult superior medial protocerebrum neuron 486 adult neurosecretory cell of pars intercerebralis None None None None
16 VFB_jrchk70f SMP454_R (FlyEM-HB:326253554) 11 VFB_jrchk3rw PI3 (FlyEM-HB:859339195) adult superior medial protocerebrum neuron 454 adult neurosecretory cell of pars intercerebralis None None None None
17 VFB_jrchk734 SMP486_a_R (FlyEM-HB:297580512) 11 VFB_jrchk3rh PI1_b (FlyEM-HB:5813014245) adult superior medial protocerebrum neuron 486 adult neurosecretory cell of pars intercerebralis None None None None
18 VFB_jrchk70f SMP454_R (FlyEM-HB:326253554) 10 VFB_jrchk3rl PI1_c (FlyEM-HB:5813026416) adult superior medial protocerebrum neuron 454 adult neurosecretory cell of pars intercerebralis None None None None
19 VFB_jrchk543 SIFa(PDM34) (FlyEM-HB:5813062866) 13 VFB_jrchk544 SIFa(PDM34) (FlyEM-HB:1137590785) adult SIFamide cell of pars intercerebralis adult SIFamide cell of pars intercerebralis None None None None
20 VFB_jrchk64p SMP001_R (FlyEM-HB:5813056887) 20 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 001 adult neurosecretory cell of pars intercerebralis None None None None
21 VFB_jrchk731 SMP484_R (FlyEM-HB:329918685) 16 VFB_jrchk3rd PI1_b (FlyEM-HB:5813057164) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
22 VFB_jrchk79v SMP598(SCB063)_R (FlyEM-HB:547978595) 19 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 598 adult neurosecretory cell of pars intercerebralis None None None None
23 VFB_jrchk72y SMP484_R (FlyEM-HB:298254380) 12 VFB_jrchk3re PI1_b (FlyEM-HB:5813047717) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
24 VFB_jrchk72y SMP484_R (FlyEM-HB:298254380) 17 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
25 VFB_jrchk6h6 SMP169_R (FlyEM-HB:327246931) 11 VFB_jrchk3rc PI1_b (FlyEM-HB:514530654) adult superior medial protocerebrum neuron 169 adult neurosecretory cell of pars intercerebralis None None None None
26 VFB_jrchk542 SIFa(PDM34) (FlyEM-HB:1418618235) 14 VFB_jrchk543 SIFa(PDM34) (FlyEM-HB:5813062866) adult SIFamide cell of pars intercerebralis adult SIFamide cell of pars intercerebralis None None None None
27 VFB_jrchjsj3 AstA1_L (FlyEM-HB:362473525) 16 VFB_jrchk3rc PI1_b (FlyEM-HB:514530654) adult neuron|allatostatin A neuron adult neurosecretory cell of pars intercerebralis None None None None
28 VFB_jrchk731 SMP484_R (FlyEM-HB:329918685) 18 VFB_jrchk3ri PI1_b (FlyEM-HB:359027729) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
29 VFB_jrchk72y SMP484_R (FlyEM-HB:298254380) 13 VFB_jrchk3ri PI1_b (FlyEM-HB:359027729) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
30 VFB_jrchk6my SMP261_R (FlyEM-HB:390024952) 11 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 261 adult neurosecretory cell of pars intercerebralis None None None None
31 VFB_jrchk6ph SMP298_R (FlyEM-HB:727285326) 15 VFB_jrchk3rj PI1_b (FlyEM-HB:392445880) adult superior medial protocerebrum neuron 298 adult neurosecretory cell of pars intercerebralis None None None None
32 VFB_jrchk79v SMP598(SCB063)_R (FlyEM-HB:547978595) 11 VFB_jrchk3rl PI1_c (FlyEM-HB:5813026416) adult superior medial protocerebrum neuron 598 adult neurosecretory cell of pars intercerebralis None None None None
33 VFB_jrchk6mt SMP259_R (FlyEM-HB:328265182) 11 VFB_jrchk3rj PI1_b (FlyEM-HB:392445880) adult superior medial protocerebrum neuron 259 adult neurosecretory cell of pars intercerebralis None None None None
34 VFB_jrchk64p SMP001_R (FlyEM-HB:5813056887) 11 VFB_jrchk3rf PI1_b (FlyEM-HB:5813019567) adult superior medial protocerebrum neuron 001 adult neurosecretory cell of pars intercerebralis None None None None
35 VFB_jrchk6mw SMP261_R (FlyEM-HB:358290727) 13 VFB_jrchk3ri PI1_b (FlyEM-HB:359027729) adult superior medial protocerebrum neuron 261 adult neurosecretory cell of pars intercerebralis None None None None
36 VFB_jrchjti7 DSKMP3_R (FlyEM-HB:328559607) 11 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult Drosulfakinin neuron adult neurosecretory cell of pars intercerebralis None None None None
37 VFB_jrchjti0 DPM_R (FlyEM-HB:5813105172) 10 VFB_jrchk541 SIFa(PDM34) (FlyEM-HB:699031185) mushroom body dorsal paired medial cell adult SIFamide cell of pars intercerebralis None None None None
38 VFB_jrchk731 SMP484_R (FlyEM-HB:329918685) 14 VFB_jrchk3rj PI1_b (FlyEM-HB:392445880) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
39 VFB_jrchk6pq SMP302_R (FlyEM-HB:481410841) 11 VFB_jrchk3re PI1_b (FlyEM-HB:5813047717) adult superior medial protocerebrum neuron 302 adult neurosecretory cell of pars intercerebralis None None None None
40 VFB_jrchk72y SMP484_R (FlyEM-HB:298254380) 10 VFB_jrchk3rh PI1_b (FlyEM-HB:5813014245) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
41 VFB_jrchk731 SMP484_R (FlyEM-HB:329918685) 13 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
42 VFB_jrchk79v SMP598(SCB063)_R (FlyEM-HB:547978595) 12 VFB_jrchk3rh PI1_b (FlyEM-HB:5813014245) adult superior medial protocerebrum neuron 598 adult neurosecretory cell of pars intercerebralis None None None None
43 VFB_jrchk6ph SMP298_R (FlyEM-HB:727285326) 10 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 298 adult neurosecretory cell of pars intercerebralis None None None None
44 VFB_jrchk542 SIFa(PDM34) (FlyEM-HB:1418618235) 12 VFB_jrchk541 SIFa(PDM34) (FlyEM-HB:699031185) adult SIFamide cell of pars intercerebralis adult SIFamide cell of pars intercerebralis None None None None
45 VFB_jrchk79v SMP598(SCB063)_R (FlyEM-HB:547978595) 15 VFB_jrchk3rj PI1_b (FlyEM-HB:392445880) adult superior medial protocerebrum neuron 598 adult neurosecretory cell of pars intercerebralis None None None None
46 VFB_jrchk79v SMP598(SCB063)_R (FlyEM-HB:547978595) 47 VFB_jrchk3rw PI3 (FlyEM-HB:859339195) adult superior medial protocerebrum neuron 598 adult neurosecretory cell of pars intercerebralis None None None None
47 VFB_jrchk541 SIFa(PDM34) (FlyEM-HB:699031185) 16 VFB_jrchk542 SIFa(PDM34) (FlyEM-HB:1418618235) adult SIFamide cell of pars intercerebralis adult SIFamide cell of pars intercerebralis None None None None
48 VFB_jrchk79v SMP598(SCB063)_R (FlyEM-HB:547978595) 10 VFB_jrchk3rf PI1_b (FlyEM-HB:5813019567) adult superior medial protocerebrum neuron 598 adult neurosecretory cell of pars intercerebralis None None None None
49 VFB_jrchk6mt SMP259_R (FlyEM-HB:328265182) 10 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 259 adult neurosecretory cell of pars intercerebralis None None None None
50 VFB_jrchk6p7 SMP296_R (FlyEM-HB:727280915) 20 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 296 adult neurosecretory cell of pars intercerebralis None None None None
51 VFB_jrchk544 SIFa(PDM34) (FlyEM-HB:1137590785) 11 VFB_jrchk543 SIFa(PDM34) (FlyEM-HB:5813062866) adult SIFamide cell of pars intercerebralis adult SIFamide cell of pars intercerebralis None None None None
52 VFB_jrchk6ph SMP298_R (FlyEM-HB:727285326) 12 VFB_jrchk3ri PI1_b (FlyEM-HB:359027729) adult superior medial protocerebrum neuron 298 adult neurosecretory cell of pars intercerebralis None None None None
53 VFB_jrchjtei DL5_adPN_R (FlyEM-HB:693483018) 11 VFB_jrchk541 SIFa(PDM34) (FlyEM-HB:699031185) adult antennal lobe projection neuron DL5 adPN adult SIFamide cell of pars intercerebralis None None None None
54 VFB_jrchk734 SMP486_a_R (FlyEM-HB:297580512) 12 VFB_jrchk3rg PI1_b (FlyEM-HB:5813025545) adult superior medial protocerebrum neuron 486 adult neurosecretory cell of pars intercerebralis None None None None
55 VFB_jrchk543 SIFa(PDM34) (FlyEM-HB:5813062866) 12 VFB_jrchk542 SIFa(PDM34) (FlyEM-HB:1418618235) adult SIFamide cell of pars intercerebralis adult SIFamide cell of pars intercerebralis None None None None
56 VFB_jrchk6p7 SMP296_R (FlyEM-HB:727280915) 16 VFB_jrchk3rh PI1_b (FlyEM-HB:5813014245) adult superior medial protocerebrum neuron 296 adult neurosecretory cell of pars intercerebralis None None None None
57 VFB_jrchk72x SMP484_R (FlyEM-HB:299293552) 10 VFB_jrchk3r4 PI1_a (FlyEM-HB:330388864) adult superior medial protocerebrum neuron 484 adult neurosecretory cell of pars intercerebralis None None None None
[ ]:
# Get connections between visual projection neurons and descending neurons
ds_vpn = vc.get_connected_neurons_by_type(upstream_type='visual projection neuron',
                                 downstream_type='adult neuron',
                                 weight=10).sort_values('weight', ascending=False)


Index(['upstream_neuron_id', 'upstream_neuron_name', 'weight',
       'downstream_neuron_id', 'downstream_neuron_name', 'upstream_class',
       'downstream_class', 'up_data_source', 'up_accession', 'down_source',
       'down_accession'],
      dtype='object')
[ ]:
ds_vpn[['upstream_class', 'upstream_neuron_name', 'weight', 'downstream_neuron_name', 'downstream_class']]
upstream_class upstream_neuron_name weight downstream_neuron_name downstream_class
5217 lobula tangential neuron Lt1 LT1_R (FlyEM-HB:1189230639) 958 PVLP106_R (FlyEM-HB:447228814) adult posterior ventrolateral protocerebrum ne...
13116 lobula tangential neuron LT39_R (FlyEM-HB:5813061218) 793 mALC2_L (FlyEM-HB:2124762952) adult neuron
17011 lobula tangential neuron Lt1 LT1_R (FlyEM-HB:1189912812) 600 AVLP535_R (FlyEM-HB:5813033371) adult anterior ventrolateral protocerebrum neu...
3895 lobula tangential neuron LT51(aSP29a)_R (FlyEM-HB:1282348408) 319 DNb01_R (FlyEM-HB:1566597156) descending neuron of the anterior ventral brai...
17108 lobula tangential neuron LT86_R (FlyEM-HB:1285849916) 295 mALD2_L (FlyEM-HB:701923413) adult neuron
... ... ... ... ... ...
15568 lobula columnar neuron LC12 LC12 (FlyEM-HB:1754028266) 10 PVLP078_R (FlyEM-HB:1691630995) adult posterior ventrolateral protocerebrum ne...
12381 lobula columnar neuron LC22 LC22_R (FlyEM-HB:1750712639) 10 PLP009_R (FlyEM-HB:1750419433) adult posterior lateral protocerebrum neuron 009
17519 medulla columnar neuron MC66 (FlyEM-HB:5812993478) 10 PS221_R (FlyEM-HB:1436667764) adult posterior slope neuron 221
9483 lobula columnar neuron LC12 LC12 (FlyEM-HB:1785417481) 10 PVLP077_R (FlyEM-HB:1692299350) adult posterior ventrolateral protocerebrum ne...
16929 lobula columnar neuron LC17 LC17 (FlyEM-HB:1751262627) 10 PVLP135_R (FlyEM-HB:1535082316) adult posterior ventrolateral protocerebrum ne...

19472 rows × 5 columns

[ ]:
# Get connections between visual projection neurons and descending neurons
vpn2ds = vc.get_connected_neurons_by_type(upstream_type='visual projection neuron',
                                 downstream_type='adult descending neuron',
                                 weight=10).sort_values('weight', ascending=False)
[ ]:
print('descending neuron of the posterior brain DNp44' in vpn2ds['downstream_class'])

False
[ ]:
vpn2ds[['upstream_class', 'upstream_neuron_name', 'weight', 'downstream_neuron_name', 'downstream_class']]
upstream_class upstream_neuron_name weight downstream_neuron_name downstream_class
233 lobula tangential neuron LT51(aSP29a)_R (FlyEM-HB:1282348408) 319 DNb01_R (FlyEM-HB:1566597156) descending neuron of the anterior ventral brai...
815 lobula tangential neuron LT51_R (FlyEM-HB:1444351896) 221 DNa03_R (FlyEM-HB:1139909038) descending neuron of the anterior dorsal brain...
610 lobula tangential neuron LT51(aSP29a)_R (FlyEM-HB:1282348408) 169 DNp18_R (FlyEM-HB:5813068840) descending neuron of the posterior brain DNp18
49 lobula tangential neuron LT51_R (FlyEM-HB:1597493900) 141 DNa03_R (FlyEM-HB:1139909038) descending neuron of the anterior dorsal brain...
154 lobula tangential neuron LT51(aSP29a)_R (FlyEM-HB:1261229600) 104 DNb01_R (FlyEM-HB:1566597156) descending neuron of the anterior ventral brai...
... ... ... ... ... ...
920 lobula complex columnar neuron LLPC2b (FlyEM-HB:5813024821) 10 DNb05_R (FlyEM-HB:1406966879) descending neuron of the anterior ventral brai...
556 lobula complex columnar neuron LPLC2 LPLC2_R (FlyEM-HB:1782369340) 10 DNp04_R (FlyEM-HB:1405231475) descending neuron of the posterior brain DNp04
562 lobula complex columnar neuron LPLC2 LPLC2_R (FlyEM-HB:1815826155) 10 DNp04_R (FlyEM-HB:1405231475) descending neuron of the posterior brain DNp04
580 medulla columnar neuron MC66 (FlyEM-HB:1498414361) 10 DNp16_R (FlyEM-HB:1436703256) descending neuron of the posterior brain DNp16
188 lobula complex columnar neuron LPLC1 LPLC1 (FlyEM-HB:1782714902) 10 DNp11_R (FlyEM-HB:1281324958) descending neuron of the posterior brain DNp11

1085 rows × 5 columns

Get neurons downstream/downstream of a specific neuron

Starting from an individual neuron, in this case an individual neuron from hemibrain, find all neurons upstream or downstream, restricting to edges >= some specified wieght (synaptic connections) and optionally limiting the output by neuron type/class.

[ ]:
# Starting point - let's take one of the individual descending neurons from
# the previous exploratory queries and look for other inputs

vc.get_neurons_upstream_of('DNp04_R - 1405231475', weight = 20)
query_neuron_id query_neuron_name weight target_neuron_id target_neuron_name
0 VFB_jrchk4u3 PVLP100_R - 1375845363 44 VFB_jrchjtg7 DNp04_R - 1405231475
1 VFB_jrchjy8u LC4 - 1158864995 50 VFB_jrchjtg7 DNp04_R - 1405231475
2 VFB_jrchjy9f LC4 - 5813055129 46 VFB_jrchjtg7 DNp04_R - 1405231475
3 VFB_jrchjyal LC4 - 1907571222 78 VFB_jrchjtg7 DNp04_R - 1405231475
4 VFB_jrchjy9t LC4 - 2215161310 86 VFB_jrchjtg7 DNp04_R - 1405231475
... ... ... ... ... ...
82 VFB_jrchjyak LC4 - 1907933561 82 VFB_jrchjtg7 DNp04_R - 1405231475
83 VFB_jrchjy9d LC4 - 1627117134 46 VFB_jrchjtg7 DNp04_R - 1405231475
84 VFB_jrchjya7 LC4 - 1876471221 58 VFB_jrchjtg7 DNp04_R - 1405231475
85 VFB_jrchk4tm PVLP094_R - 1503733177 26 VFB_jrchjtg7 DNp04_R - 1405231475
86 VFB_jrchjya0 LC4 - 5812998136 92 VFB_jrchjtg7 DNp04_R - 1405231475

87 rows × 5 columns

Let’s try a similar query from one of the LC4 neurons to see what other descending neuron types are downstream of it.

[ ]:
vc.get_neurons_downstream_of('LC4 - 1249932198', classification="'adult descending neuron'", weight = 20)
Running query: FBbt:00047511
Query URL: http://owl.virtualflybrain.org/kbs/vfb/instances?object=FBbt%3A00047511&prefixes=%7B%22FBbt%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FFBbt_%22%2C+%22RO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FRO_%22%2C+%22BFO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_%22%7D&direct=False
Query results: 139
query_neuron_id query_neuron_name weight target_neuron_id target_neuron_name
0 VFB_jrchjy8y LC4 - 1249932198 78 VFB_jrchjtg7 DNp04_R - 1405231475
1 VFB_jrchjy8y LC4 - 1249932198 30 VFB_jrchjup1 Giant Fiber_R - 2307027729
2 VFB_jrchjy8y LC4 - 1249932198 65 VFB_jrchjtgf DNp11_R - 1281324958

More sophisticated connectomics queries require direct queries of connectomics DB APIs

CATMAID connectivity queries

Broadly speaking, using pymaid to query CATMAID servers lets you fetch connectivity data as either lists of up- and downstream partners or as whole adjacency matrices.

These examples use the VFB FAFB server.

[ ]:
# Using VFB to get neurons by type
DA1 = vc.get_instances("'adult antennal lobe projection neuron DA1'", summary=True)
DA1_tab = pd.DataFrame.from_records(DA1)
len(DA1_tab)
DA1_tab
Running query: FBbt:00048096
Query URL: http://owl.virtualflybrain.org/kbs/vfb/instances?object=FBbt%3A00048096&prefixes=%7B%22FBbt%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FFBbt_%22%2C+%22RO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FRO_%22%2C+%22BFO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_%22%7D&direct=False
Query results: 31
label symbol id tags parents_label parents_id data_source accession templates dataset license
0 Uniglomerular mALT DA1 lPN#L3 (FAFB:2345089) VFB_0010122p Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 2345089 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
1 ALv1_P02(DA1)_0_2018U VFB_00102763 Entity|GABAergic|Adult|Anatomy|has_image|Cell|... adult antennal lobe projection neuron DA1 vPN FBbt_00067372 Yu2013 https://creativecommons.org/licenses/by-nc-sa/...
2 Uniglomerular mALT DA1 lPN#R3 (FAFB:61221) VFB_00101204 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 61221 adult brain template JFRC2|JRC2018Unisex Zheng2018 https://creativecommons.org/licenses/by-sa/4.0...
3 Uniglomerular mALT DA1 lPN#L1 (FAFB:4207871) VFB_0010126e Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 4207871 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
4 ALv1_P02(DA1)_0_2018U VFB_00103943 Entity|GABAergic|Adult|Anatomy|has_image|Cell|... adult antennal lobe projection neuron DA1 vPN FBbt_00067372 Yu2013 https://creativecommons.org/licenses/by-nc-sa/...
5 Uniglomerular mALT DA1 lPN#R1 (FAFB:57323) VFB_00101201 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 57323 JRC2018Unisex|adult brain template JFRC2 Zheng2018 https://creativecommons.org/licenses/by-sa/4.0...
6 DA1_lPN_R - 1734350908 VFB_jrchjtdb Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 neuprint_JRC_Hemibrain_1point1 1734350908 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
7 Uniglomerular mALT DA1 lPN#R5 (FAFB:2863104) VFB_0010124e Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 2863104 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
8 Uniglomerular mALT DA1 lPN#R7 (FAFB:57353) VFB_00101202 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 57353 JRC2018Unisex|adult brain template JFRC2 Zheng2018 https://creativecommons.org/licenses/by-sa/4.0...
9 ALv1_P02(DA1)_0_2018U VFB_00102297 Entity|GABAergic|Adult|Anatomy|has_image|Cell|... adult antennal lobe projection neuron DA1 vPN FBbt_00067372 JRC2018Unisex Lee2020 https://creativecommons.org/licenses/by/4.0/le...
10 ALv1_P02(DA1)_0_2018U VFB_00104629 Entity|GABAergic|Adult|Anatomy|has_image|Cell|... adult antennal lobe projection neuron DA1 vPN FBbt_00067372 JRC2018Unisex Yu2013 https://creativecommons.org/licenses/by-nc-sa/...
11 ALv1_P02(DA1)_0_2018U VFB_00102294 Entity|GABAergic|Adult|Anatomy|has_image|Cell|... adult antennal lobe projection neuron DA1 vPN FBbt_00067372 Yu2013 https://creativecommons.org/licenses/by-nc-sa/...
12 Uniglomerular mlALT DA1 vPN#R1 (FAFB:1811442) VFB_0010121x Entity|GABAergic|Adult|Anatomy|has_image|Cell|... adult antennal lobe projection neuron DA1 vPN FBbt_00067372 catmaid_fafb 1811442 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
13 Uniglomerular mlALT DA1 vPN#L1 (FAFB:2334841) VFB_0010122m Entity|GABAergic|Adult|Anatomy|has_image|Cell|... adult antennal lobe projection neuron DA1 vPN FBbt_00067372 catmaid_fafb 2334841 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
14 Uniglomerular mALT DA1 lPN#L5 (FAFB:2380564) VFB_0010122z Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 2380564 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
15 DA1_lPN_R - 754538881 VFB_jrchjtdg Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 neuprint_JRC_Hemibrain_1point1 754538881 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
16 Uniglomerular mALT DA1 lPN#R6 (FAFB:27295) VFB_00101199 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 27295 JRC2018Unisex|adult brain template JFRC2 Zheng2018 https://creativecommons.org/licenses/by-sa/4.0...
17 Uniglomerular mALT DA1 lPN#R8 (FAFB:57381) VFB_00101203 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 57381 adult brain template JFRC2|JRC2018Unisex Zheng2018 https://creativecommons.org/licenses/by-sa/4.0...
18 DA1_lPN_R - 1765040289 VFB_jrchjtdc Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 neuprint_JRC_Hemibrain_1point1 1765040289 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
19 Uniglomerular mALT DA1 lPN#R2 (FAFB:57311) VFB_00101200 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 57311 adult brain template JFRC2|JRC2018Unisex Zheng2018 https://creativecommons.org/licenses/by-sa/4.0...
20 DA1_lPN_R - 5813039315 VFB_jrchjtdd Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 neuprint_JRC_Hemibrain_1point1 5813039315 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
21 Uniglomerular mALT DA1 lPN#L6 (FAFB:2381753) VFB_0010123b Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 2381753 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
22 DA1_lPN_R - 754534424 VFB_jrchjtde Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 neuprint_JRC_Hemibrain_1point1 754534424 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
23 DA1_lPN_R - 1734350788 VFB_jrchjtdf Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 neuprint_JRC_Hemibrain_1point1 1734350788 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
24 ALv1_P02(DA1)_0_2018U VFB_00104624 Entity|GABAergic|Adult|Anatomy|has_image|Cell|... adult antennal lobe projection neuron DA1 vPN FBbt_00067372 Yu2013 https://creativecommons.org/licenses/by-nc-sa/...
25 Uniglomerular mALT DA1 lPN#L2 (FAFB:2319457) VFB_0010122k Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 2319457 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
26 Uniglomerular mALT DA1 lPN#R4 (FAFB:755022) VFB_00101205 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 755022 adult brain template JFRC2|JRC2018Unisex Zheng2018 https://creativecommons.org/licenses/by-sa/4.0...
27 Uniglomerular mALT DA1 lPN#L7 (FAFB:3239781) VFB_0010124l Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 3239781 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
28 Uniglomerular mALT DA1 lPN#L4 (FAFB:2379517) VFB_0010122y Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 catmaid_fafb 2379517 JRC2018Unisex BatesSchlegel2020 https://creativecommons.org/licenses/by-sa/4.0...
29 DA1_vPN_R - 733316908 VFB_jrchjtdh Entity|GABAergic|Adult|Anatomy|has_image|Cell|... adult antennal lobe projection neuron DA1 vPN FBbt_00067372 neuprint_JRC_Hemibrain_1point1 733316908 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
30 DA1_lPN_R - 722817260 VFB_jrchjtda Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DA1 lPN FBbt_00067363 neuprint_JRC_Hemibrain_1point1 722817260 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
[ ]:
# Map neurons to CATMAID Skeleton IDs (skids)

da1_skids = vc.neo_query_wrapper.vfb_id_2_xrefs(DA1_tab['id'], db='catmaid_fafb', reverse_return=True)
da1_skids
{'2863104': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010124e'}],
 '57353': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_00101202'}],
 '2381753': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010123b'}],
 '1811442': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010121x'}],
 '57323': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_00101201'}],
 '57311': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_00101200'}],
 '2345089': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010122p'}],
 '27295': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_00101199'}],
 '2379517': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010122y'}],
 '2380564': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010122z'}],
 '755022': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_00101205'}],
 '61221': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_00101204'}],
 '57381': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_00101203'}],
 '3239781': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010124l'}],
 '4207871': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010126e'}],
 '2334841': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010122m'}],
 '2319457': [{'db': 'catmaid_fafb', 'vfb_id': 'VFB_0010122k'}]}
[ ]:
# Map neurons to CATMAID Skeleton IDs (skids)

da1_skids = vc.neo_query_wrapper.vfb_id_2_xrefs(DA1_tab['id'], db='catmaid_fafb', reverse_return=True)
da1_skids_int = list(map(int, da1_skids))
da1_skids_int
[2863104,
 57353,
 2381753,
 1811442,
 57323,
 57311,
 2345089,
 27295,
 2379517,
 2380564,
 755022,
 61221,
 57381,
 3239781,
 4207871,
 2334841,
 2319457]

Generate a connectivity table for neurons downstream of DA1 neurons

[ ]:
da1 = pymaid.get_neurons(da1_skids_int)
da1_ds = pymaid.get_partners(da1_skids_int,
                             threshold=3,  # anything with >= 3 synapses
                             directions=['outgoing']  # downstream partners only
                            )

# Result is a pandas DataFrame
da1_ds.head()
INFO  : Fetching connectivity table for 17 neurons (pymaid)
INFO  : Done. Found 0 pre-, 270 postsynaptic and 0 gap junction-connected neurons (pymaid)
neuron_name skeleton_id num_nodes relation 2863104 57353 2381753 1811442 57323 57311 ... 2379517 2380564 755022 61221 57381 3239781 4207871 2334841 2319457 total
0 Uniglomerular mlALT DA1 vPN mlALTed Milk 18114... 1811442 11769 downstream 30 3 0 0 20 21 ... 0 0 32 26 4 0 0 0 0 151.0
1 Uniglomerular mlALT DA1 vPN mlALTed Milk 23348... 2334841 6362 downstream 0 0 32 0 0 0 ... 28 0 0 0 0 26 17 0 22 139.0
2 LHAV4a4#1 1911125 FML PS RJVR 1911124 6969 downstream 23 6 0 0 15 19 ... 0 0 19 13 9 0 0 0 0 109.0
3 LHAV2a3#1 1870231 RJVR AJES PS 1870230 14820 downstream 5 23 0 1 7 5 ... 0 0 19 7 28 0 0 0 0 105.0
4 LHAV4c1#1 488056 downstream DA1 GSXEJ 488055 12137 downstream 15 3 0 0 11 17 ... 0 0 15 15 0 0 0 0 0 92.0

5 rows × 22 columns

[ ]:
# Get an adjacency matrix between all Bates, Schlegel et al. neurons
bates = pymaid.find_neurons(annotations='Paper: Bates and Schlegel et al 2020')
adj = pymaid.adjacency_matrix(bates)
adj.head()
INFO  : Found 583 neurons matching the search parameters (pymaid)
targets 2863104 57349 57353 16 57361 15738898 57365 4182038 3813399 11524119 ... 57323 4624362 1853423 2842610 57333 4624374 3080183 57337 4624378 57341
sources
2863104 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 2.0 0.0 12.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
57349 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
57353 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 5.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
16 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 1.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
57361 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

5 rows × 583 columns

[ ]:
import seaborn as sns

ax = sns.clustermap(adj, vmax=10, cmap='Greys')
/shared-libs/python3.7/py/lib/python3.7/site-packages/seaborn/matrix.py:649: UserWarning:

Clustering large matrix with scipy. Installing `fastcluster` may give better performance.

../_images/tutorials_connectomics_25_1.png
[ ]:
# Axo-axonic connections between two different types of DA1 PNs
cn = pymaid.get_connectors_between(2863104, 1811442)
cn.head()
connector_id connector_loc node1_id source_neuron confidence1 creator1 node1_loc node2_id target_neuron confidence2 creator2 node2_loc
0 6736296 [359448.44, 159319.03, 150560.0] 3163408 2863104 5 NaN [359487.3, 159145.66, 150600.0] 6736298 1811442 5 NaN [359611.9, 159541.48, 150560.0]
1 6795172 [356041.88, 149555.53, 147920.0] 6795195 2863104 5 NaN [354724.44, 149284.1, 147920.0] 6795153 1811442 5 NaN [356366.16, 149854.86, 147920.0]
2 6795291 [355189.5, 150232.48, 148240.0] 6795293 2863104 5 NaN [354595.62, 149464.8, 148240.0] 6795214 1811442 5 NaN [355472.28, 150294.75, 148160.0]
3 6795747 [355030.4, 154047.86, 145800.0] 6795749 2863104 5 NaN [355045.38, 154180.1, 145800.0] 6795745 1811442 5 NaN [355024.44, 153945.73, 145760.0]
4 6797452 [353221.4, 148570.9, 147320.0] 6797456 2863104 5 NaN [354213.9, 148397.44, 147320.0] 6797437 1811442 5 NaN [353447.6, 148704.88, 147560.0]
[ ]:
import numpy as np

points = np.vstack(cn.connector_loc)

navis.plot3d([da1.idx[[1811442, 57353]],  # plot the two neurons
              points],  # plot the points of synaptic contacts as scatter
              scatter_kws=dict(name="synaptic contacts")
              )
[ ]:
import os
# 'Auth Token' from https://neuprint.janelia.org/account
SECRET_CODE = os.getenv("NEUPRINTAUTHTOKEN")

# Connect to neuprint server
import neuprint as neu

client = neu.Client('https://neuprint.janelia.org', dataset='hemibrain:v1.1', token=SECRET_CODE)
[ ]:
neu_da1 = neu.fetch_skeletons(neu.NeuronCriteria(type='DA1_lPN.*', regex=True))
neu_da1
<class 'navis.core.neuronlist.NeuronList'> containing 7 neurons (1.3MiB)
type name id n_nodes n_connectors n_branches n_leafs cable_length soma units
0 navis.TreeNeuron DA1_lPN_R 722817260 4336 3132 635 658 274910.568784 NaN 8 nanometer
1 navis.TreeNeuron DA1_lPN_R 754538881 4890 2943 626 642 291434.992623 860.0 8 nanometer
... ... ... ... ... ... ... ... ... ... ...
5 navis.TreeNeuron DA1_lPN_R 1765040289 5380 3099 624 642 324249.403013 2467.0 8 nanometer
6 navis.TreeNeuron DA1_lPN_R 5813039315 4300 2954 625 643 273403.049029 NaN 8 nanometer
[ ]:
split = navis.split_axon_dendrite(neu_da1[0])
split

<class 'navis.core.neuronlist.NeuronList'> containing 4 neurons (185.3KiB)
type name id n_nodes n_connectors n_branches n_leafs cable_length soma units compartment
0 navis.TreeNeuron DA1_lPN_R 722817260 0 0 0 0 0.000000 None 8 nanometer cellbodyfiber
1 navis.TreeNeuron DA1_lPN_R 722817260 3575 2505 566 590 188806.744034 None 8 nanometer dendrite
2 navis.TreeNeuron DA1_lPN_R 722817260 193 14 0 1 30601.319501 None 8 nanometer linker
3 navis.TreeNeuron DA1_lPN_R 722817260 474 612 60 61 48872.448763 None 8 nanometer axon
[ ]:
navis.plot3d(split, connectors=True)
WARNING : Skipping empty neuron: DA1_lPN_R (722817260) (navis)
[ ]:
cn = neu.fetch_synapse_connections(source_criteria=neu.NeuronCriteria(type='DA1_lPN.*', regex=True),
                                   target_criteria=neu.NeuronCriteria(type='DA1_vPN.*', regex=True))
cn.head()
bodyId_pre bodyId_post roi_pre roi_post x_pre y_pre z_pre x_post y_post z_post confidence_pre confidence_post
0 754534424 733316908 LH(R) LH(R) 5015 22921 15043 5033 22941 15044 0.972 0.991824
1 754534424 733316908 AL(R) AL(R) 14588 35361 26453 14582 35377 26444 0.991 0.932866
2 754534424 733316908 LH(R) LH(R) 3826 22574 14689 3842 22576 14683 0.982 0.896622
3 754534424 733316908 LH(R) LH(R) 4924 23750 14333 4927 23768 14324 0.993 0.961103
4 754534424 733316908 LH(R) LH(R) 5017 23642 14531 4997 23622 14518 0.904 0.661779
[ ]:
cn.groupby(['bodyId_pre', 'bodyId_post', 'roi_pre']).size()
bodyId_pre  bodyId_post  roi_pre
722817260   733316908    AL(R)      26
                         LH(R)      28
754534424   733316908    AL(R)      13
                         LH(R)      31
754538881   733316908    AL(R)      33
                         LH(R)       5
1734350788  733316908    AL(R)      21
                         LH(R)      38
1734350908  733316908    AL(R)      24
                         LH(R)      37
1765040289  733316908    AL(R)      27
                         LH(R)       2
5813039315  733316908    AL(R)      12
                         LH(R)      33
dtype: int64

neuprint connectivity queries

To programmatically interface with neuprint, we will use neuprint-python (link). It requires an API token which you can get via the website and is bound to the Google account that you use to log into neuprint. For this workshop we provide such a token as environment variable but you will need to start using your own token after the workshop is over.

These examples use the hemibrain v1.1 dataset.

neuprint-python

First we have to initialize the connection.

[ ]:
import neuprint as neu
client = neu.Client('https://neuprint.janelia.org',
                    dataset='hemibrain:v1.1',
                    token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InZmYndvcmtzaG9wLm5ldXJvZmx5MjAyMEBnbWFpbC5jb20iLCJsZXZlbCI6Im5vYXV0aCIsImltYWdlLXVybCI6Imh0dHBzOi8vbGg2Lmdvb2dsZXVzZXJjb250ZW50LmNvbS8tWXFDN21NRXd3TlEvQUFBQUFBQUFBQUkvQUFBQUFBQUFBQUEvQU1adXVjbU5zaXhXZDRhM0VyTTQ0ODBMa2IzNDdvUlpfUS9zOTYtYy9waG90by5qcGc_c3o9NTA_c3o9NTAiLCJleHAiOjE3OTQwOTE4ODd9.ceg4mrj2o-aOhK0NHNGmBacg8R34PBPoLBwhCo4uOCQ')

Most functions in neuprint-python accept neu.NeuronCriteria which is effectively a filter for body IDs, types, cellbody fibers (~lineages), etc:

[ ]:
help(neu.NeuronCriteria)
Help on class NeuronCriteria in module neuprint.neuroncriteria:

class NeuronCriteria(builtins.object)
 |  NeuronCriteria(matchvar='n', *, bodyId=None, instance=None, type=None, regex=False, cellBodyFiber=None, status=None, cropped=None, min_pre=0, min_post=0, rois=None, inputRois=None, outputRois=None, min_roi_inputs=1, min_roi_outputs=1, label=None, roi_req='all', client=None)
 |
 |  Specifies which fields to filter by when searching for a Neuron (or Segment).
 |  This class does not send queries itself, but you use it to specify search
 |  criteria for various query functions.
 |
 |  Note:
 |      For simple queries involving only particular bodyId(s) or type(s)/instance(s),
 |      you can usually just pass the ``bodyId`` or ``type`` to the query function,
 |      without constructing a full ``NeuronCriteria``.
 |
 |      .. code-block:: python
 |
 |          from neuprint import fetch_neurons, NeuronCriteria as NC
 |
 |          # Equivalent
 |          neuron_df, conn_df = fetch_neurons(NC(bodyId=329566174))
 |          neuron_df, conn_df = fetch_neurons(329566174)
 |
 |          # Equivalent
 |          # (Criteria is satisfied if either type or instance matches.)
 |          neuron_df, conn_df = fetch_neurons(NC(type="OA-VPM3", instance="OA-VPM3"))
 |          neuron_df, conn_df = fetch_neurons("OA-VPM3")
 |
 |  Methods defined here:
 |
 |  __eq__(self, value)
 |      Implement comparison between criteria.
 |      Note: 'matchvar' is not considered during the comparison.
 |
 |  __init__(self, matchvar='n', *, bodyId=None, instance=None, type=None, regex=False, cellBodyFiber=None, status=None, cropped=None, min_pre=0, min_post=0, rois=None, inputRois=None, outputRois=None, min_roi_inputs=1, min_roi_outputs=1, label=None, roi_req='all', client=None)
 |      Except for ``matchvar``, all parameters must be passed as keyword arguments.
 |
 |      .. note::
 |
 |          **Options for specifying ROI criteria**
 |
 |          The ``rois`` argument merely matches neurons that intersect the given ROIs at all
 |          (without distinguishing between inputs and outputs).
 |
 |          The ``inputRois`` and ``outputRois`` arguments allow you to put requirements
 |          on whether or not neurons have inputs or outputs in the listed ROIs.
 |          It results a more expensive query, but its more powerful.
 |          It also enables you to require a minimum number of connections in the given
 |          ``inputRois`` or ``outputRois`` using the ``min_roi_inputs`` and ``min_roi_outputs``
 |          criteria.
 |
 |          In either case, use use ``roi_req`` to specify whether a neuron must match just
 |          one (``any``) of the listed ROIs, or ``all`` of them.
 |
 |      Args:
 |          matchvar (str):
 |              An arbitrary cypher variable name to use when this
 |              ``NeuronCriteria`` is used to construct cypher queries.
 |              To help catch errors (such as accidentally passing a ``type`` or
 |              ``instance`` name in the wrong argument position), we require that
 |              ``matchvar`` begin with a lowercase letter.
 |
 |          bodyId (int or list of ints):
 |              List of bodyId values.
 |
 |          instance (str or list of str):
 |              If ``regex=True``, then the instance will be matched as a regular expression.
 |              Otherwise, only exact matches are found. To search for neurons with no instance
 |              at all, use ``instance=[None]``. If both ``type`` and ``instance`` criteria are
 |              supplied, any neuron that matches EITHER criteria will match the overall criteria.
 |
 |          type (str or list of str):
 |              If ``regex=True``, then the type will be matched as a regular expression.
 |              Otherwise, only exact matches are found. To search for neurons with no type
 |              at all, use ``type=[None]``. If both ``type`` and ``instance`` criteria are
 |              supplied, any neuron that matches EITHER criteria will match the overall criteria.
 |
 |          regex (bool):
 |              If ``True``, the ``instance`` and ``type`` arguments will be interpreted as
 |              regular expressions, rather than exact match strings.
 |
 |          cellBodyFiber (str or list of str):
 |              Matches for the neuron ``cellBodyFiber`` field.  To search for neurons
 |              with no CBF at all, use ``cellBodyFiber=[None]``.
 |
 |          status (str or list of str):
 |              Matches for the neuron ``status`` field.  To search for neurons with no status
 |              at all, use ``status=[None]``.
 |
 |          cropped (bool):
 |              If given, restrict results to neurons that are cropped or not.
 |
 |          min_pre (int):
 |              Exclude neurons that don't have at least this many t-bars (outputs) overall,
 |              regardless of how many t-bars exist in any particular ROI.
 |
 |          min_post (int):
 |              Exclude neurons that don't have at least this many PSDs (inputs) overall,
 |              regardless of how many PSDs exist in any particular ROI.
 |
 |          rois (str or list of str):
 |              ROIs that merely intersect the neuron, without specifying whether
 |              they're intersected by input or output synapses.
 |              If not provided, will be auto-set from ``inputRois`` and ``outputRois``.
 |
 |          inputRois (str or list of str):
 |              Only Neurons which have inputs in EVERY one of the given ROIs will be matched.
 |              ``regex`` does not apply to this parameter.
 |
 |          outputRois (str or list of str):
 |              Only Neurons which have outputs in EVERY one of the given ROIs will be matched.
 |              ``regex`` does not apply to this parameter.
 |
 |          min_roi_inputs (int):
 |              How many input (post) synapses a neuron must have in each ROI to satisfy the
 |              ``inputRois`` criteria.  Can only be used if you provided ``inputRois``.
 |
 |          min_roi_outputs (int):
 |              How many output (pre) synapses a neuron must have in each ROI to satisfy the
 |              ``outputRois`` criteria.   Can only be used if you provided ``outputRois``.
 |
 |          roi_req (Either ``'any'`` or ``'all'``):
 |              Whether a neuron must intersect all of the listed input/output ROIs, or any of the listed input/output ROIs.
 |              When using 'any', each neuron must still match at least one input AND at least one output ROI.
 |
 |          label (Either ``'Neuron'`` or ``'Segment'``):
 |              Which node label to match with.
 |              (In neuprint, all ``Neuron`` nodes are also ``Segment`` nodes.)
 |              By default, ``'Neuron'`` is used, unless you provided a non-empty ``bodyId`` list.
 |              In that case, ``'Segment'`` is the default. (It's assumed you're really interested
 |              in the bodies you explicitly listed, whether or not they have the ``'Neuron'`` label.)
 |
 |          client (:py:class:`neuprint.client.Client`):
 |              Used to validate ROI names.
 |              If not provided, the global default ``Client`` will be used.
 |
 |  __repr__(self)
 |      Return repr(self).
 |
 |  all_conditions(self, *vars, prefix=0, comments=True)
 |
 |  basic_conditions(self, prefix=0, comments=True)
 |      Construct a WHERE clause based on the basic conditions
 |      in this criteria (i.e. everything except for the "directed ROI" conditions.)
 |
 |  basic_exprs(self)
 |      Return the list of expressions that correspond
 |      to the members in this NeuronCriteria object.
 |      They're intended be combined (via 'AND') in
 |      the WHERE clause of a cypher query.
 |
 |  bodyId_expr(self)
 |
 |  cbf_expr(self)
 |
 |  cropped_expr(self)
 |
 |  directed_rois_condition(self, *vars, prefix=0, comments=True)
 |      Construct the ```WITH...WHERE``` statements that apply the "directed ROI"
 |      conditions specified by this criteria's ``inputRois`` and ``outputRois``
 |      members.
 |
 |      These conditions are expensive to evaluate, so it's usually a good
 |      idea to position them LAST in your cypher query, once the result set
 |      has already been narrowed down by eariler filters.
 |
 |  global_vars(self)
 |
 |  global_with(self, *vars, prefix=0)
 |
 |  instance_expr(self)
 |
 |  post_expr(self)
 |
 |  pre_expr(self)
 |
 |  rois_expr(self)
 |
 |  status_expr(self)
 |
 |  type_expr(self)
 |
 |  typeinst_expr(self)
 |      Unlike all other fields, type and instance OR'd together.
 |      Either match satisfies the criteria.
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  combined_conditions(neuron_conditions, vars=[], prefix=0, comments=True) from builtins.type
 |      Combine the conditions from multiple NeuronCriteria into a single string,
 |      putting the "cheap" conditions first and the "expensive" conditions last.
 |      (That is, basic conditions first and the directed ROI conditions last.)
 |
 |  combined_global_with(neuron_conditions, vars=[], prefix=0) from builtins.type
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables (if defined)
 |
 |  __weakref__
 |      list of weak references to the object (if defined)
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  MAX_LITERAL_LENGTH = 3
 |
 |  __hash__ = None

Fetching neurons

Let’s say we want to find all antennnal lobe projection neurons (PNs). Their type nomenclature adheres to {glomerulus}_{lineage}PN (e.g. DA1_lPN)for uniglomerular PNs and a M_{lineage}PN{tract}{type} (e.g. M_vPNml50 = “multiglomerular ventral lineage PN mediolateral tract type 50) for multiglomerular PNs.

To get them all, we need to use regex patterns (see this cheatsheet):

[ ]:
# Define the filter criteria
nc = neu.NeuronCriteria(type='.*?_.*?PN.*?', regex=True)

# Get general info for these neurons
pns, roi_info = neu.fetch_neurons(nc)

print(f'{pns.shape[0]} PNs found.')

pns.head()
337 PNs found.
bodyId instance type pre post size status cropped statusLabel cellBodyFiber somaRadius somaLocation inputRois outputRois roiInfo
0 294792184 M_vPNml53_R M_vPNml53 92 344 420662445 Traced False Roughly traced AVM04 336.5 [18923, 34319, 35424] [AL(R), AL-D(R), AL-DA2(R), AL-DA4m(R), AL-DC1... [AL(R), AL-DC1(R), LH(R), PLP(R), SIP(R), SLP(... {'SNP(R)': {'pre': 70, 'post': 155, 'downstrea...
1 329599710 M_lvPNm32_R M_lvPNm32 247 285 343478957 Traced False Roughly traced AVM06 NaN None [AL(R), AL-DC4(R), AL-DL2v(R), AL-DM1(R), AL-D... [AL(R), AL-DL2v(R), AL-DM1(R), AL-DM4(R), AL-D... {'SNP(R)': {'pre': 180, 'post': 93, 'downstrea...
2 417199910 M_lvPNm36_R M_lvPNm36 162 347 387058559 Traced False Roughly traced AVM06 351.5 [13823, 33925, 34176] [AL(R), AL-DL5(R), AL-DM4(R), AL-DP1m(R), AL-V... [AL(R), AL-DL5(R), AL-DM4(R), AL-VP1d(R), AL-V... {'SNP(R)': {'pre': 156, 'post': 95, 'downstrea...
3 480927537 M_vPNml70_R M_vPNml70 82 276 240153322 Traced False Roughly traced AVM04 NaN None [AL(R), AL-DA2(R), AL-DA4l(R), AL-DA4m(R), AL-... [LH(R), SLP(R), SNP(R)] {'SNP(R)': {'pre': 15, 'post': 18, 'downstream...
4 481268653 M_vPNml89_R M_vPNml89 146 58 265085609 Traced False Roughly traced AVM04 NaN None [AL(R), AL-VC3l(R), AL-VC4(R), AL-VP1m(R), LH(... [LH(R), SLP(R), SNP(R)] {'SNP(R)': {'pre': 10, 'post': 2, 'downstream'...
[ ]:
# Check that the regex did not have any accidental by-catch
pns['type'].unique()
array(['M_vPNml53', 'M_lvPNm32', 'M_lvPNm36', 'M_vPNml70', 'M_vPNml89',
       'VP1l+_lvPN', 'M_vPNml69', 'DM1_lPN', 'DM4_vPN', 'M_vPNml79',
       'VP4+_vPN', 'DA4l_adPN', 'M_vPNml87', 'DM4_adPN', 'M_vPNml83',
       'VA5_lPN', 'DA4m_adPN', 'M_lvPNm24', 'M_vPNml85', 'VP1l+VP3_ilPN',
       'M_vPNml77', 'M_vPNml84', 'VC1_lPN', 'M_lvPNm39', 'M_vPNml50',
       'DM2_lPN', 'VC5_lvPN', 'M_vPNml88', 'M_vPNml58', 'VP4_vPN',
       'DP1m_vPN', 'DP1m_adPN', 'DM5_lPN', 'VC5_adPN', 'M_vPNml80',
       'M_lvPNm25', 'VC3m_lvPN', 'VP3+_vPN', 'VP1m+_lvPN', 'DA3_adPN',
       'V_l2PN', 'M_vPNml56', 'VC3l_adPN', 'VM7v_adPN', 'DL5_adPN',
       'VM4_adPN', 'VM2_adPN', 'M_lvPNm40', 'DC4_vPN', 'V_ilPN',
       'M_vPNml74', 'Z_lvPNm1', 'DA1_lPN', 'DP1l_adPN', 'VM4_lvPN',
       'M_vPNml71', 'DP1l_vPN', 'M_lvPNm41', 'M_spPN5t10', 'DA1_vPN',
       'VC4_adPN', 'DM3_adPN', 'M_lvPNm45', 'VL1_vPN', 'M_lvPNm44',
       'M_vPNml78', 'M_vPNml67', 'M_adPNm5', 'M_smPNm1', 'DM6_adPN',
       'DL2d_adPN', 'M_adPNm6', 'M_adPNm8', 'M_lvPNm43', 'Z_vPNml1',
       'M_vPNml59', 'DA2_lPN', 'M_lPNm11A', 'M_vPNml52', 'DL2d_vPN',
       'VL2p_vPN', 'VA1d_adPN', 'M_lPNm11B', 'M_lvPNm48', 'M_lPNm11C',
       'M_lvPNm42', 'VA1v_vPN', 'M_vPNml68', 'M_vPNml55', 'M_vPNml62',
       'VL2a_vPN', 'M_vPNml60', 'M_vPNml65', 'VM5d_adPN', 'M_l2PNm16',
       'M_vPNml61', 'M_vPNml57', 'M_vPNml64', 'M_lv2PN9t49',
       'VP2+VC5_l2PN', 'M_spPN4t9', 'M_vPNml66', 'M_vPNml75', 'M_vPNml63',
       'M_vPNml72', 'M_lvPNm38', 'D_adPN', 'M_vPNml76', 'M_vPNml54',
       'DM3_vPN', 'M_vPNml86', 'DL3_lPN', 'VA4_lPN', 'VP1d_il2PN',
       'DC1_adPN', 'M_l2PN3t18', 'M_lvPNm35', 'DL4_adPN', 'M_lvPNm28',
       'M_lvPNm27', 'M_ilPNm90', 'M_l2PNl20', 'M_lvPNm29', 'VA7l_adPN',
       'M_lPNm13', 'M_l2PNl21', 'DL1_adPN', 'M_imPNl92', 'M_vPNml73',
       'M_ilPN8t91', 'M_l2PNm14', 'VP1d+VP4_l2PN1', 'M_lvPNm26',
       'DL2v_adPN', 'VP3+VP1l_ivPN', 'M_lvPNm33', 'VA1v_adPN',
       'VP3+_l2PN', 'M_l2PN10t19', 'VP4+VL1_l2PN', 'M_l2PNl22',
       'M_l2PNm15', 'M_lPNm11D', 'MZ_lv2PN', 'DC2_adPN', 'M_lvPNm46',
       'VC2_lPN', 'VM1_lPN', 'VM3_adPN', 'VM7d_adPN', 'M_lvPNm47',
       'M_lPNm12', 'DC3_adPN', 'VP2+_adPN', 'VP1m+VP2_lvPN2',
       'VP1m+VP2_lvPN1', 'VA6_adPN', 'VA7m_lPN', 'M_adPNm7', 'M_adPNm4',
       'VA1d_vPN', 'VA3_adPN', 'VL1_ilPN', 'M_l2PNl23', 'M_lvPNm31',
       'VP1m+VP5_ilPN', 'VL2p_adPN', 'MZ_lvPN', 'VP2_adPN', 'VA2_adPN',
       'VM5v_adPN', 'VP5+VP2_l2PN', 'VP5+VP3_l2PN', 'VP5+_l2PN',
       'M_vPNml51', 'M_smPN6t2', 'M_lvPNm37', 'M_vPNml82', 'M_adPNm3',
       'VP1m_l2PN', 'DC4_adPN', 'VP5+Z_adPN', 'VL2a_adPN', 'VP2_l2PN',
       'M_lvPNm34', 'VP2+Z_lvPN', 'M_lvPNm30', 'M_l2PNm17', 'M_vPNml81',
       'VP1d+VP4_l2PN2'], dtype=object)

Find neuron types with VFB instead (this allows curated neuron classes to be used):

[ ]:
#This will get all ALPNs from ALL datasets on VFB
ALPNs = vc.get_instances("'adult antennal lobe projection neuron'", summary=True)
ALPNs = pd.DataFrame.from_records(ALPNs)
#Select only rows from Hemibrain1.1 dataset
ALPNs=ALPNs[ALPNs['data_source'].str.match('neuprint_JRC_Hemibrain_1point1')]
ALPNs
Running query: FBbt:00067123
Query URL: http://owl.virtualflybrain.org/kbs/vfb/instances?object=FBbt%3A00067123&prefixes=%7B%22FBbt%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FFBbt_%22%2C+%22RO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FRO_%22%2C+%22BFO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_%22%7D&direct=False
Query results: 1469
label symbol id tags parents_label parents_id data_source accession templates dataset license
0 M_vPNml53_R - 294792184 VFB_jrchk0y5 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult multiglomerular antennal lobe projection... FBbt_00007414 neuprint_JRC_Hemibrain_1point1 294792184 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
4 DC2_adPN_R - 1828206773 VFB_jrchjtdt Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron DC2 adPN FBbt_00067354 neuprint_JRC_Hemibrain_1point1 1828206773 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
8 VM4_lvPN_R - 1850024931 VFB_jrchk7ib Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron VM4 lvPN FBbt_00049775 neuprint_JRC_Hemibrain_1point1 1850024931 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
18 M_vPNml81_R - 5813090752 VFB_jrchk0zj Entity|has_image|Adult|Anatomy|has_neuron_conn... adult multiglomerular antennal lobe projection... FBbt_00007414 neuprint_JRC_Hemibrain_1point1 5813090752 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
21 M_lvPNm48_R - 1975187554 VFB_jrchk0xt Entity|has_image|Adult|Anatomy|has_neuron_conn... adult multiglomerular antennal lobe projection... FBbt_00049779 neuprint_JRC_Hemibrain_1point1 1975187554 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
... ... ... ... ... ... ... ... ... ... ... ...
1451 Z_vPNml1(noAL+SEZ)_R - 729608317 VFB_jrchk7zr Entity|has_image|Adult|Anatomy|has_neuron_conn... adult antennal lobe projection neuron FBbt_00067123 neuprint_JRC_Hemibrain_1point1 729608317 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
1456 M_vPNml63_R - 1857143769 VFB_jrchk0yl Entity|has_image|Adult|Anatomy|has_neuron_conn... adult multiglomerular antennal lobe projection... FBbt_00007414 neuprint_JRC_Hemibrain_1point1 1857143769 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
1461 M_vPNml66_R - 5813071409 VFB_jrchk0yr Entity|has_image|Adult|Anatomy|has_neuron_conn... adult multiglomerular antennal lobe projection... FBbt_00007414 neuprint_JRC_Hemibrain_1point1 5813071409 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
1465 M_lPNm11A_R - 5813044177 VFB_jrchk0w9 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult multiglomerular antennal lobe projection... FBbt_00049778 neuprint_JRC_Hemibrain_1point1 5813044177 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
1468 M_l2PNm14_R - 1723506321 VFB_jrchk0w4 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult multiglomerular antennal lobe projection... FBbt_00049910 neuprint_JRC_Hemibrain_1point1 1723506321 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...

339 rows × 11 columns

Fetching synaptic partners

Looks good! Next: What’s downstream of those PNs?

[ ]:
ds = neu.fetch_simple_connections(upstream_criteria=list(map(int, ALPNs['accession'])))
#using hemibrain regex
#ds = neu.fetch_simple_connections(upstream_criteria=neu.NeuronCriteria(bodyId=pns.bodyId.values))
ds
bodyId_pre bodyId_post weight type_pre type_post instance_pre instance_post conn_roiInfo
0 635062078 1671292719 390 DP1m_adPN lLN2T_c DP1m_adPN_R lLN2T_c(Tortuous)_R {'AL(R)': {'pre': 390, 'post': 390}, 'AL-DP1m(...
1 635062078 1704347707 326 DP1m_adPN lLN2T_c DP1m_adPN_R lLN2T_c(Tortuous)_R {'AL(R)': {'pre': 324, 'post': 324}, 'AL-DP1m(...
2 542634818 1704347707 322 DM1_lPN lLN2T_c DM1_lPN_R lLN2T_c(Tortuous)_R {'AL(R)': {'pre': 322, 'post': 322}, 'AL-DM1(R...
3 635062078 1640922516 320 DP1m_adPN lLN2T_e DP1m_adPN_R lLN2T_e(Tortuous)_R {'AL(R)': {'pre': 317, 'post': 316}, 'AL-DP1m(...
4 724816115 1670916819 318 DP1l_adPN lLN2P_a DP1l_adPN_R lLN2P_a(Patchy)_R {'AL(R)': {'pre': 318, 'post': 318}, 'AL-DP1l(...
... ... ... ... ... ... ... ... ...
101862 5901222910 5813086037 1 DM2_lPN None DM2_lPN_R None {'LH(R)': {'pre': 1, 'post': 1}}
101863 5901222910 5813095915 1 DM2_lPN KCg-m DM2_lPN_R KCg-m_R {'MB(R)': {'pre': 1, 'post': 1}, 'CA(R)': {'pr...
101864 5901222910 5813129316 1 DM2_lPN LHAV6a1_b DM2_lPN_R LHAV6a1_b_R {'LH(R)': {'pre': 1, 'post': 1}}
101865 5901222910 5901193783 1 DM2_lPN LHAV4g4_a DM2_lPN_R LHAV4g4_a_R {'LH(R)': {'pre': 1, 'post': 1}}
101866 5901222910 5901203780 1 DM2_lPN LHAV4g11 DM2_lPN_R LHAV4g11_R {'LH(R)': {'pre': 1, 'post': 1}}

101867 rows × 8 columns

Each row is now a connections from a single up- to a single downstream neuron. The “weight” is the number of synapses between the pre- and the postsynaptic neuron. Let’s simplify by grouping by type:

[ ]:
by_type = ds.groupby(['type_pre', 'type_post'], as_index=False).weight.sum()
by_type.sort_values('weight', ascending=False, inplace=True)
by_type.reset_index(drop=True, inplace=True)
by_type
type_pre type_post weight
0 DC3_adPN KCg-m 3670
1 VM5d_adPN KCg-m 3219
2 DC1_adPN KCg-m 3215
3 VL2a_adPN KCg-m 3096
4 DA1_lPN KCg-m 3078
... ... ... ...
40631 M_vPNml50 WEDPN4 1
40632 M_vPNml50 WEDPN12 1
40633 M_vPNml50 V_ilPN 1
40634 M_vPNml50 VP4+VL1_l2PN 1
40635 Z_vPNml1 mALD2 1

40636 rows × 3 columns

The strongest connections are between PNs and Kenyon Cells (KCs). That’s not much of a surprise since there are thousands of KCs. For the sake of the argument let’s say we want to know where these connections occur:

[ ]:
#First find KCs in VFB
KCs = pd.DataFrame.from_records(vc.get_instances("'adult Kenyon cell'", summary=True))
#Select only rows from Hemibrain1.1 dataset
KCs=KCs[KCs['data_source'].str.match('neuprint_JRC_Hemibrain_1point1')]
KCs
Running query: FBbt:00049825
Query URL: http://owl.virtualflybrain.org/kbs/vfb/instances?object=FBbt%3A00049825&prefixes=%7B%22FBbt%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FFBbt_%22%2C+%22RO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FRO_%22%2C+%22BFO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_%22%7D&direct=False
Query results: 5107
label symbol id tags parents_label parents_id data_source accession templates dataset license
0 KCg-m_R - 692810011 VFB_jrchjw74 Entity|has_image|Adult|Anatomy|has_neuron_conn... gamma main Kenyon cell FBbt_00111061 neuprint_JRC_Hemibrain_1point1 692810011 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
2 KCg-m_R - 477909679 VFB_jrchjw36 Entity|has_image|Adult|Anatomy|has_neuron_conn... gamma main Kenyon cell FBbt_00111061 neuprint_JRC_Hemibrain_1point1 477909679 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
5 KCab-m_R - 5812980222 VFB_jrchjvqk Entity|has_image|Adult|Anatomy|has_neuron_conn... alpha/beta Kenyon cell FBbt_00100248 neuprint_JRC_Hemibrain_1point1 5812980222 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
6 KCg-m_R - 5812982832 VFB_jrchjw83 Entity|has_image|Adult|Anatomy|has_neuron_conn... gamma main Kenyon cell FBbt_00111061 neuprint_JRC_Hemibrain_1point1 5812982832 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
7 KCab-m_R - 5812980806 VFB_jrchjvr2 Entity|has_image|Adult|Anatomy|has_neuron_conn... alpha/beta Kenyon cell FBbt_00100248 neuprint_JRC_Hemibrain_1point1 5812980806 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
... ... ... ... ... ... ... ... ... ... ... ...
5093 KCg-m_R - 664184060 VFB_jrchjwck Entity|has_image|Adult|Anatomy|has_neuron_conn... gamma main Kenyon cell FBbt_00111061 neuprint_JRC_Hemibrain_1point1 664184060 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
5096 KCg-m_R - 5812982620 VFB_jrchjwdd Entity|has_image|Adult|Anatomy|has_neuron_conn... gamma main Kenyon cell FBbt_00111061 neuprint_JRC_Hemibrain_1point1 5812982620 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
5100 KCg-m_R - 661430179 VFB_jrchjwdb Entity|has_image|Adult|Anatomy|has_neuron_conn... gamma main Kenyon cell FBbt_00111061 neuprint_JRC_Hemibrain_1point1 661430179 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
5101 KCg-m_R - 5812982436 VFB_jrchjwcz Entity|has_image|Adult|Anatomy|has_neuron_conn... gamma main Kenyon cell FBbt_00111061 neuprint_JRC_Hemibrain_1point1 5812982436 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
5102 KCg-m_R - 663834152 VFB_jrchjwa9 Entity|has_image|Adult|Anatomy|has_neuron_conn... gamma main Kenyon cell FBbt_00111061 neuprint_JRC_Hemibrain_1point1 663834152 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...

1927 rows × 11 columns

[ ]:
adj, roi_info2 = neu.fetch_adjacencies(sources=list(map(int, ALPNs['accession'])), targets=list(map(int, KCs['accession'])))
roi_info2.head()
bodyId_pre bodyId_post roi weight
0 542634818 301314208 CA(R) 6
1 542634818 331999156 CA(R) 1
2 542634818 332344592 CA(R) 2
3 542634818 332344908 CA(R) 9
4 542634818 332353106 CA(R) 13
[ ]:
# Group by region of interest (ROI)
by_roi = roi_info2.groupby('roi').weight.sum()
by_roi.head()
roi
CA(R)         181274
NotPrimary      2764
PLP(R)            11
SCL(R)           509
SLP(R)          2026
Name: weight, dtype: int64
[ ]:
ax = by_roi.plot.bar()
ax.set_xlabel('')
ax.set_ylabel('PN to KC synapses')
Text(0, 0.5, 'PN to KC synapses')
../_images/tutorials_connectomics_53_1.png

Querying paths

Let’s say we want to find out how to go from a PN (second order olfactory neurons) all the way to a descending neuron (presumably leading to motor neurons in the VNC).

[ ]:
#First find DNs in VFB
DNs = pd.DataFrame.from_records(vc.get_instances("'adult descending neuron'", summary=True))
#Select only rows from Hemibrain1.1 dataset
DNs=DNs[DNs['data_source'].str.match('neuprint_JRC_Hemibrain_1point1')]
DNs
Running query: FBbt:00047511
Query URL: http://owl.virtualflybrain.org/kbs/vfb/instances?object=FBbt%3A00047511&prefixes=%7B%22FBbt%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FFBbt_%22%2C+%22RO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FRO_%22%2C+%22BFO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_%22%7D&direct=False
Query results: 139
label symbol id tags parents_label parents_id data_source accession templates dataset license
2 DNp27_R - 1072063538 VFB_jrchjthm Entity|has_image|Adult|Anatomy|has_neuron_conn... descending neuron of the posterior brain DNp27 FBbt_00047660 neuprint_JRC_Hemibrain_1point1 1072063538 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
3 DNp16/17_R - 1655626125 VFB_jrchjth0 Entity|has_image|Adult|Anatomy|has_neuron_conn... descending neuron of the posterior brain FBbt_00047517 neuprint_JRC_Hemibrain_1point1 1655626125 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
7 DNb04_R - 1037393225 VFB_jrchjtfx Entity|has_image|Adult|Anatomy|has_neuron_conn... descending neuron of the anterior ventral brai... FBbt_00047585 neuprint_JRC_Hemibrain_1point1 1037393225 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
9 DNp32_R - 5813050455 VFB_jrchjthr Entity|has_image|Adult|Anatomy|has_neuron_conn... descending neuron of the posterior brain DNp32 FBbt_00047665 neuprint_JRC_Hemibrain_1point1 5813050455 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
11 NPFP1_R - 1043117106 VFB_jrchk103 Entity|has_image|Adult|Anatomy|has_neuron_conn... adult NPF P1 neuron FBbt_00048120 neuprint_JRC_Hemibrain_1point1 1043117106 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
... ... ... ... ... ... ... ... ... ... ... ...
133 DNp17_R - 1498383456 VFB_jrchjth4 Entity|has_image|Adult|Anatomy|has_neuron_conn... descending neuron of the posterior brain DNp17 FBbt_00047650 neuprint_JRC_Hemibrain_1point1 1498383456 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
134 DNg30_R - 571346836 VFB_jrchjtg4 Entity|has_image|Adult|Anatomy|has_neuron_conn... descending neuron of the gnathal ganglion DNg30 FBbt_00047622 neuprint_JRC_Hemibrain_1point1 571346836 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
135 DNp27_L - 5813020347 VFB_jrchjthn Entity|has_image|Adult|Anatomy|has_neuron_conn... descending neuron of the posterior brain DNp27 FBbt_00047660 neuprint_JRC_Hemibrain_1point1 5813020347 JRC_FlyEM_Hemibrain|JRC2018Unisex Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
137 MDN(PDM13)_L - 5813021079 VFB_jrchk0vf Entity|has_image|Adult|Anatomy|has_neuron_conn... adult moonwalker descending neuron FBbt_00111308 neuprint_JRC_Hemibrain_1point1 5813021079 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...
138 Giant Fiber_R - 2307027729 VFB_jrchjup1 Entity|has_image|Adult|Anatomy|has_neuron_conn... giant fiber neuron FBbt_00004020 neuprint_JRC_Hemibrain_1point1 2307027729 JRC2018Unisex|JRC_FlyEM_Hemibrain Xu2020NeuronsV1point1 https://creativecommons.org/licenses/by/4.0/le...

101 rows × 11 columns

[ ]:
# First fetch the DNs
dns, _ = neu.fetch_neurons(list(map(int, DNs['accession'])))
#with regex
#dns, _ = neu.fetch_neurons(neu.NeuronCriteria(type='(.*DN[^1]{0,}.*|Giant Fiber)', regex=True))
dns
bodyId instance type pre post size status cropped statusLabel cellBodyFiber somaRadius somaLocation inputRois outputRois roiInfo
0 451689001 DNp25_R DNp25 165 803 948309595 Traced False Roughly traced PDM05 361.0 [22185, 13374, 16352] [ATL(R), CA(R), FLA(R), INP, LH(R), MB(+ACA)(R... [ATL(R), CA(R), INP, MB(+ACA)(R), MB(R), SLP(R... {'SNP(R)': {'pre': 158, 'post': 703, 'downstre...
1 512851433 DNp10(PDM27)_L DNp10 25 2487 3010901036 Traced False Roughly traced None 483.5 [27334, 21053, 7640] [ATL(L), GC, GOR(L), IB, ICL(L), INP, SCL(L), ... [ATL(L), GC, GOR(L), ICL(L), INP, SCL(L), SMP(... {'SNP(L)': {'pre': 7, 'post': 512, 'downstream...
2 519949044 oviDNb_R oviDNb 7 1089 1618057638 Traced False Roughly traced PDM15 396.0 [19291, 15307, 11696] [AVLP(R), CA(R), CRE(-ROB,-RUB)(R), CRE(-RUB)(... [CRE(-RUB)(L), CRE(L), INP, SIP(R), SMP(L), SM... {'SNP(R)': {'pre': 2, 'post': 656, 'downstream...
3 542751938 DNp44_R DNp44 182 634 1674610618 Traced False Roughly traced PVM09 321.0 [18875, 11698, 13136] [AL(R), AL-VL1(R), AL-VL2p(R), AL-VP1d(R), AL-... [AL(R), AL-DP1m(R), AL-VL1(R), AL-VL2p(R), AL-... {'SNP(R)': {'pre': 21, 'post': 277, 'downstrea...
4 550655668 oviDNa_R oviDNa 36 1111 1887226051 Traced False Roughly traced PDM15 301.0 [19199, 15756, 13456] [AOTU(R), CRE(-ROB,-RUB)(R), CRE(R), EPA(R), I... [CRE(-ROB,-RUB)(R), CRE(R), INP, SCL(R), SIP(R... {'SNP(R)': {'pre': 14, 'post': 772, 'downstrea...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
96 5813068915 NPFP1(PDM12)_L NPFP1 123 108 4221447995 Traced False Roughly traced None 539.5 [28242, 20366, 6808] [ATL(L), AVLP(R), CAN(R), EPA(R), GOR(R), IB, ... [AVLP(R), CAN(R), EPA(R), GOR(R), IB, ICL(L), ... {'INP': {'pre': 34, 'post': 47, 'downstream': ...
97 5813077405 DNd01_L DNd01 21 731 738596888 Traced False Roughly traced None 342.0 [25173, 33207, 14176] [SMP(L), SMP(R), SNP(L), SNP(R)] [SMP(L), SMP(R), SNP(L), SNP(R)] {'SNP(L)': {'pre': 13, 'post': 675, 'downstrea...
98 5813078134 DNp15_R DNp15 21 2310 1288564222 Traced False Roughly traced None NaN None [CAN(R), GNG, IPS(R), PENP, SPS(R), VLNP(R), V... [GNG, IPS(R), VMNP] {'VMNP': {'pre': 7, 'post': 860, 'downstream':...
99 5813095193 DNp16_R DNp16 70 683 292910198 Traced False Roughly traced PVM02 276.0 [25941, 10730, 20000] [CAN(R), GNG, IB, INP, IPS(R), PENP, SPS(R), V... [CAN(R), GNG, IPS(R), PENP, SPS(R), VMNP] {'INP': {'post': 34, 'upstream': 34}, 'IB': {'...
100 5813108230 DNp16/17_R DNp16/17 5 177 304268206 Traced False Roughly traced PVM02 321.5 [23677, 10111, 18544] [GNG, IB, INP, IPS(R), SPS(R), VMNP] [IPS(R), SPS(R), VMNP] {'INP': {'post': 2, 'upstream': 2}, 'IB': {'po...

101 rows × 15 columns

Neuprint lets you query paths from a single source to a single target. For multi-source or -target queries, your best bet is to download the entire graph and run the queries locally using networkx or igraph.

[ ]:
# Find all paths from A PN to A DNs
paths = neu.fetch_shortest_paths(upstream_bodyId=list(map(int, ALPNs['accession']))[0],
                                 downstream_bodyId=list(map(int, DNs['accession']))[0],
                                 min_weight=10)
paths
path bodyId type weight
0 0 294792184 M_vPNml53 0
1 0 5813057148 SLP387 16
2 0 511349908 SMP183 19
3 0 545501062 SMP464 10
4 0 739256609 CL029 25
... ... ... ... ...
343 57 5813057148 SLP387 16
344 57 357515217 SLP365 12
345 57 479607277 CL102 10
346 57 449250041 CL026 22
347 57 1072063538 DNp27 22

348 rows × 4 columns

So it looks like there are three separate 7-hop paths to go from M_vPNml53 to DN1a. Let’s visualize the neurons involved!

Fetching meshes & skeletons

You can fetch skeletons as SWCs directly via neuprint-python. For visualization however it’s easiest to load neuron morphologies via navis. For that navis wraps neuprint-python and adds some convenience functions (see also the tutorial):

[ ]:
# Import the wrapped neuprint-python
# -> this exposes ALL base functions plus a couple navis-specific extras
import navis
import navis.interfaces.neuprint as neu

#client = neu.Client('https://neuprint.janelia.org', dataset='hemibrain:v1.1')

# Fetch neurons in the first path
nl = neu.fetch_skeletons(paths.loc[(paths.path == 0), 'bodyId'])
nl

<class 'navis.core.neuronlist.NeuronList'> containing 6 neurons (3.1MiB)
type name id n_nodes n_connectors n_branches n_leafs cable_length soma units
0 navis.TreeNeuron M_vPNml53_R 294792184 3670 436 180 190 1.877807e+05 3649 8 nanometer
1 navis.TreeNeuron SMP464_R 545501062 4507 454 183 193 1.888869e+05 4 8 nanometer
... ... ... ... ... ... ... ... ... ... ...
4 navis.TreeNeuron DNp27_R 1072063538 47115 9298 1750 1888 2.720497e+06 25808 8 nanometer
5 navis.TreeNeuron CL029_R 739256609 31953 7932 2660 2709 1.275071e+06 6033 8 nanometer
[ ]:
# Let's also get some ROI meshes
al = neu.fetch_roi('AL(R)')
lh = neu.fetch_roi('LH(R)')
ca = neu.fetch_roi('CA(R)')
[ ]:
# Plot
navis.plot3d([nl, lh, al, ca], width=1100)

Plotting graphs

There are various ways of plotting static graphs. In theory Jupyter notebooks lend themselves to interactive graphs too but unfortunately DeepNote does not yet support the required libraries (e.g. ipywidgets). That being said: if you want to run this locally or on Google colab, check out ipycytoscape.

There are numerous options to do this but we will use networkx to plot a static graph:

[ ]:
import networkx as nx
import numpy as np

# Initialize the graph
G = nx.DiGraph()

# Generate edges from the paths
edges = []
for p in paths.path.unique():
    this_path = paths.loc[(paths.path == p)]
    this_edges = list(zip(this_path.values[:-1], this_path.values[1:]))

    for i in range(this_path.shape[0] - 1):
        edges.append([this_path.bodyId.values[i], this_path.bodyId.values[i + 1], this_path.weight.values[i + 1]])

# Add the edges
G.add_weighted_edges_from(edges)

# Add some names to the nodes
nx.set_node_attributes(G, paths.set_index('bodyId')['type'].to_dict(), name='name')
[ ]:
import matplotlib.pyplot as plt

# Draw using a simple force-directed layout
pos = nx.kamada_kawai_layout(G)

# We could draw everything in one step but this way we have more control over the plot
fig, ax = plt.subplots(figsize=(10, 10))

# Draw nodes
nx.draw_networkx_nodes(G, pos=pos, ax=ax)

# Draw edges
weights = np.array([e[2]['weight'] for e in G.edges(data=True)])
nx.draw_networkx_edges(G, pos=pos, width=(weights / 12).tolist())

# Add node labels
nx.draw_networkx_labels(G, pos=pos, labels=dict(G.nodes('name')), font_size=14)

# Turn axes of
ax.set_axis_off()
../_images/tutorials_connectomics_65_0.png

In general, I recommend exporting your graph to e.g. graphml and importing it into e.g. cytoscape if you want to explore an interactive network graph.

[ ]:
nx.write_gml(G, "my_graph.gml")