Connectomics

[172]:
# Install all used libraries
!pip install -r ../../../requirements.txt --quiet
!pip install ../../../ --quiet

[173]:
# Import libs and initialise API objects
from vfb_connect import vfb
import pandas as pd

import pymaid
import navis

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

# Connect to VFB's 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}')

INFO  : Global CATMAID instance set. Caching is ON. (pymaid)
Server is running CATMAID version 2020.02.15-102-gce1dee4

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.

[174]:
vfb.get_terms_by_xref(['Trh-F-500041'], db='FlyCircuit')
[174]:
label symbol id tags description parents_label parents_id data_source accession xrefs templates dataset license
0 Trh-F-500041 VFB_00014110 [Entity, Adult, Anatomy, Cell, Expression_patt... OutAge: Adult 5~15 days [adult neuron, expression pattern fragment] [FBbt_00047095, VFBext_0000004] [FlyCircuit] [Trh-F-500041] [FlyCircuit:Trh-F-500041] [JRC2018Unisex, adult brain template JFRC2] [Chiang2010] []
[175]:
neurons_in_DA3 = vfb.get_instances("'neuron' that 'overlaps' some 'antennal lobe glomerulus DA3'")
neurons_in_DA3
[175]:
label symbol id tags data_source accession parents_label parents_id xrefs templates dataset license
0 v2LN35_R (FlyEM-HB:1733056086) v2LN35_R VFB_jrchk8ew [Entity, Adult, Anatomy, Cell, Cholinergic, In... [neuprint_JRC_Hemibrain_1point1] [1733056086] [cholinergic local interneuron of the adult an... [FBbt_00007403, FBbt_20003766] [neuronbridge:1733056086, neuprint_JRC_Hemibra... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
1 lLN2T_a(Tortuous)_R (FlyEM-HB:5813032595) lLN2T_a(Tortuous)_R VFB_jrchk8bd [Entity, Adult, Anatomy, Cell, Individual, Ner... [neuprint_JRC_Hemibrain_1point1] [5813032595] [adult serotonergic neuron, adult serotonergic... [FBbt_00049526, FBbt_00049526, FBbt_00049526, ... [neuronbridge:5813032595, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
2 lLN2T_d(Tortuous)_R (FlyEM-HB:1667251683) lLN2T_d(Tortuous)_R VFB_jrchk8bp [Entity, Adult, Anatomy, Cell, Individual, Ner... [neuprint_JRC_Hemibrain_1point1] [1667251683] [adult serotonergic neuron, adult serotonergic... [FBbt_00049526, FBbt_00049526, FBbt_00049526, ... [neuronbridge:1667251683, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
3 lLN2P_b(Patchy)_R (FlyEM-HB:1946178096) lLN2P_b(Patchy)_R VFB_jrchk8au [Entity, Adult, Anatomy, Cell, Individual, Ner... [neuprint_JRC_Hemibrain_1point1] [1946178096] [adult local interneuron of the lateral ALl1 n... [FBbt_00007394, FBbt_00007394, FBbt_00007394, ... [neuprint_JRC_Hemibrain_1point1:1946178096, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
4 lLN2T_a(Tortuous)_R (FlyEM-HB:1762354941) lLN2T_a(Tortuous)_R VFB_jrchk8bg [Entity, Adult, Anatomy, Cell, Individual, Ner... [neuprint_JRC_Hemibrain_1point1] [1762354941] [adult serotonergic neuron, adult serotonergic... [FBbt_00049526, FBbt_00049526, FBbt_00049526, ... [neuprint_JRC_Hemibrain_1point1:1762354941, ne... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
... ... ... ... ... ... ... ... ... ... ... ... ...
153 ORN_DA3 (FlyEM-HB:1735059070) ORN_DA3 VFB_jrchk18q [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [1735059070] [adult olfactory receptor neuron Or23a] [FBbt_00067033] [neuronbridge:1735059070, neuprint_JRC_Hemibra... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
154 OA-VUMa2_R (FlyEM-HB:1670265016) OA-VUMa2_R VFB_jrchk10i [Entity, Adult, Anatomy, Cell, Individual, Ner... [neuprint_JRC_Hemibrain_1point1] [1670265016] [octopaminergic VUMa2 neuron] [FBbt_00110157] [neuronbridge:1670265016, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
155 ORN_DA3 (FlyEM-HB:1735399997) ORN_DA3 VFB_jrchk18o [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [1735399997] [adult olfactory receptor neuron Or23a] [FBbt_00067033] [neuronbridge:1735399997, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
156 ORN_VA1v (FlyEM-HB:2075398249) ORN_VA1v VFB_jrchk22d [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [2075398249] [adult olfactory receptor neuron Or47b] [FBbt_00067056] [neuronbridge:2075398249, neuprint_JRC_Hemibra... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
157 ORN_DA1_R (FlyEM-HB:1672315788) ORN_DA1_R VFB_jrchk13i [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [1672315788] [adult olfactory receptor neuron Or67d] [FBbt_00067031] [neuronbridge:1672315788, neuprint_JRC_Hemibra... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...

158 rows × 12 columns

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

vfb.get_connected_neurons_by_type(upstream_type='GABAergic neuron',
                                 downstream_type='adult descending neuron',
                                 weight=10).sort_values('weight', ascending=False, ignore_index=True)
[176]:
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_jrchk79q SMP594(SCB017)_R (FlyEM-HB:976934253) 492 VFB_jrchk70f SMP454_R (FlyEM-HB:326253554) adult superior medial protocerebrum neuron 594 adult superior medial protocerebrum neuron 454 None None None None
1 VFB_jrchk79q SMP594(SCB017)_R (FlyEM-HB:976934253) 393 VFB_jrchjsri CL138_R (FlyEM-HB:707190304) adult superior medial protocerebrum neuron 594 adult clamp neuron 138 None None None None
2 VFB_jrchjrof AVLP080_R (FlyEM-HB:5813027276) 373 VFB_jrchk4wd PVLP136_R (FlyEM-HB:5813057178) adult anterior ventrolateral protocerebrum neu... adult posterior ventrolateral protocerebrum ne... None None None None
3 VFB_jrchjrek AOTU019(ADM10)_L (FlyEM-HB:1605518663) 362 VFB_jrchk47t PS017_R (FlyEM-HB:5813069484) adult anterior optic tubercle neuron 019 adult posterior slope neuron 017 None None None None
4 VFB_jrchjrob AVLP076_R (FlyEM-HB:1135441187) 349 VFB_jrchk4wd PVLP136_R (FlyEM-HB:5813057178) adult anterior ventrolateral protocerebrum neu... adult posterior ventrolateral protocerebrum ne... None None None None
... ... ... ... ... ... ... ... ... ... ... ...
1354 VFB_jrchk79p SMP593(SCB014)_R (FlyEM-HB:549282467) 10 VFB_jrchk4a1 PS066(AVM08)_L (FlyEM-HB:1284675398) adult superior medial protocerebrum neuron 593 adult posterior slope neuron 066 None None None None
1355 VFB_jrchjrgi AOTU053_R (FlyEM-HB:5813097142) 10 VFB_jrchk4a1 PS066(AVM08)_L (FlyEM-HB:1284675398) adult anterior optic tubercle neuron 053 adult posterior slope neuron 066 None None None None
1356 VFB_jrchjrej AOTU019_R (FlyEM-HB:799868224) 10 VFB_jrchk0ve MDN_R (FlyEM-HB:698016469) adult anterior optic tubercle neuron 019 adult moonwalker descending neuron None None None None
1357 VFB_jrchjuut IB060(PVL21)_L (FlyEM-HB:760806798) 10 VFB_jrchk7f7 VES029(AVM14)_L (FlyEM-HB:1099800130) adult inferior bridge neuron 060 adult vest neuron 029 None None None None
1358 VFB_jrchk4yr SAD013_R (FlyEM-HB:5813024035) 10 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475) adult saddle neuron 013 descending neuron of the posterior brain DNp04 None None None None

1359 rows × 11 columns

[177]:
# Get connections between pacemaker neurons
clock_neuron_connectome = vfb.get_connected_neurons_by_type(upstream_type='pacemaker neuron',
                                 downstream_type='pacemaker neuron',
                                 weight=10).sort_values('weight', ascending=False)
clock_neuron_connectome
[177]:
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
12 VFB_jrchjtex DN1a_R (FlyEM-HB:264083994) 79 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) DN1a neuron adult cholinergic neuron|LNd neuron None None None None
15 VFB_jrchjtey DN1a_R (FlyEM-HB:5813022274) 75 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) DN1a neuron adult cholinergic neuron|LNd neuron None None None None
25 VFB_jrchjtey DN1a_R (FlyEM-HB:5813022274) 63 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) DN1a neuron adult cholinergic neuron|adult s-LNv neuron None None None None
28 VFB_jrchjtex DN1a_R (FlyEM-HB:264083994) 55 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) DN1a neuron adult cholinergic neuron|adult s-LNv neuron None None None None
30 VFB_jrchk089 LPN_R (FlyEM-HB:480029788) 43 VFB_jrchk08a LPN_R (FlyEM-HB:450034902) adult LP neuron|adult dopaminergic neuron adult LP neuron None None None None
16 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) 40 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) adult cholinergic neuron|adult s-LNv neuron adult cholinergic neuron|LNd neuron None None None None
24 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) 37 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) adult cholinergic neuron|LNd neuron adult cholinergic neuron|adult s-LNv neuron None None None None
19 VFB_jrchjtf0 DN1pA_R (FlyEM-HB:324846570) 37 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) ventro-contralateral-projecting DN1p neuron|ad... adult cholinergic neuron|LNd neuron None None None None
18 VFB_jrchjtf2 DN1pA_R (FlyEM-HB:387944118) 34 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) adult glutamatergic neuron|ventro-contralatera... adult cholinergic neuron|LNd neuron None None None None
26 VFB_jrchjtf1 DN1pA_R (FlyEM-HB:325529237) 33 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) adult glutamatergic neuron|ventro-contralatera... adult cholinergic neuron|adult s-LNv neuron None None None None
13 VFB_jrchjtf1 DN1pA_R (FlyEM-HB:325529237) 30 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) adult glutamatergic neuron|ventro-contralatera... adult cholinergic neuron|LNd neuron None None None None
31 VFB_jrchk08a LPN_R (FlyEM-HB:450034902) 30 VFB_jrchk089 LPN_R (FlyEM-HB:480029788) adult LP neuron adult LP neuron|adult dopaminergic neuron None None None None
11 VFB_jrchjtf3 DN1pA_R (FlyEM-HB:387166379) 30 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) ventro-contralateral-projecting DN1p neuron|ad... adult cholinergic neuron|LNd neuron None None None None
20 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) 29 VFB_jrchjzxw LNd_R (FlyEM-HB:5813056917) adult cholinergic neuron|LNd neuron adult cholinergic neuron|LNd neuron None None None None
8 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) 25 VFB_jrchjzxx LNd_R (FlyEM-HB:5813021192) adult cholinergic neuron|adult s-LNv neuron LNd neuron None None None None
29 VFB_jrchjtf3 DN1pA_R (FlyEM-HB:387166379) 25 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) ventro-contralateral-projecting DN1p neuron|ad... adult cholinergic neuron|adult s-LNv neuron None None None None
27 VFB_jrchjtez DN1pA_R (FlyEM-HB:5813010153) 25 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) adult glutamatergic neuron|ventro-contralatera... adult cholinergic neuron|adult s-LNv neuron None None None None
22 VFB_jrchjtf0 DN1pA_R (FlyEM-HB:324846570) 25 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) ventro-contralateral-projecting DN1p neuron|ad... adult cholinergic neuron|adult s-LNv neuron None None None None
23 VFB_jrchjtf2 DN1pA_R (FlyEM-HB:387944118) 22 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) adult glutamatergic neuron|ventro-contralatera... adult cholinergic neuron|adult s-LNv neuron None None None None
9 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) 21 VFB_jrchjzxx LNd_R (FlyEM-HB:5813021192) adult cholinergic neuron|LNd neuron LNd neuron None None None None
21 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) 17 VFB_jrchjzxw LNd_R (FlyEM-HB:5813056917) adult cholinergic neuron|adult s-LNv neuron adult cholinergic neuron|LNd neuron None None None None
14 VFB_jrchjtez DN1pA_R (FlyEM-HB:5813010153) 15 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) adult glutamatergic neuron|ventro-contralatera... adult cholinergic neuron|LNd neuron None None None None
6 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) 14 VFB_jrchjtf3 DN1pA_R (FlyEM-HB:387166379) adult cholinergic neuron|adult s-LNv neuron ventro-contralateral-projecting DN1p neuron|ad... None None None None
4 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) 14 VFB_jrchjtf1 DN1pA_R (FlyEM-HB:325529237) adult cholinergic neuron|LNd neuron adult glutamatergic neuron|ventro-contralatera... None None None None
7 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) 13 VFB_jrchjtf3 DN1pA_R (FlyEM-HB:387166379) adult cholinergic neuron|LNd neuron ventro-contralateral-projecting DN1p neuron|ad... None None None None
10 VFB_jrchjtf0 DN1pA_R (FlyEM-HB:324846570) 13 VFB_jrchjzxx LNd_R (FlyEM-HB:5813021192) ventro-contralateral-projecting DN1p neuron|ad... LNd neuron None None None None
3 VFB_jrchk8e0 5th s-LNv (FlyEM-HB:511051477) 12 VFB_jrchjtf1 DN1pA_R (FlyEM-HB:325529237) adult cholinergic neuron|adult s-LNv neuron adult glutamatergic neuron|ventro-contralatera... None None None None
17 VFB_jrchjtf5 DN1pB_R (FlyEM-HB:5813071319) 11 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) anterior-projecting DN1p neuron|adult glutamat... adult cholinergic neuron|LNd neuron None None None None
0 VFB_jrchjtey DN1a_R (FlyEM-HB:5813022274) 11 VFB_jrchjtex DN1a_R (FlyEM-HB:264083994) DN1a neuron DN1a neuron None None None None
1 VFB_jrchjtex DN1a_R (FlyEM-HB:264083994) 10 VFB_jrchjtey DN1a_R (FlyEM-HB:5813022274) DN1a neuron DN1a neuron None None None None
5 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) 10 VFB_jrchjtez DN1pA_R (FlyEM-HB:5813010153) adult cholinergic neuron|LNd neuron adult glutamatergic neuron|ventro-contralatera... None None None None
2 VFB_jrchjzxy LNd_R (FlyEM-HB:5813069648) 10 VFB_jrchjtf2 DN1pA_R (FlyEM-HB:387944118) adult cholinergic neuron|LNd neuron adult glutamatergic neuron|ventro-contralatera... None None None None
[178]:
# Get connections between visual projectsion neurons and descending neurons
visPN2DC = vfb.get_connected_neurons_by_type(upstream_type='visual projection neuron',
                                 downstream_type='adult descending neuron',
                                 weight=10).sort_values('weight', ascending=False)
visPN2DC
[178]:
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
1701 VFB_jrchk09j LT51(aSP29a)_R (FlyEM-HB:1282348408) 319 VFB_jrchjtfr DNb01_R (FlyEM-HB:1566597156) adult glutamatergic neuron|lobula tangential n... descending neuron of the anterior ventral brai... None None None None
53 VFB_jrchk7g6 VES044_R (FlyEM-HB:5812979017) 262 VFB_jrchk7eb VES009_R (FlyEM-HB:1140923511) adult vest neuron 044 adult vest neuron 009 None None None None
1332 VFB_jrchk09h LT51_R (FlyEM-HB:5813069020) 238 VFB_jrchk7e7 VES006_R (FlyEM-HB:642728308) lobula tangential neuron LT51|adult glutamater... adult vest neuron 006 None None None None
1668 VFB_jrchk0bu LT86_R (FlyEM-HB:1285849916) 228 VFB_jrchk7g4 VES042_R (FlyEM-HB:1875284107) lobula tangential neuron|adult cholinergic neuron adult vest neuron 042 None None None None
11 VFB_jrchk09c LT51_R (FlyEM-HB:1444351896) 221 VFB_jrchjtfg DNa03_R (FlyEM-HB:1139909038) adult glutamatergic neuron|lobula tangential n... descending neuron of the anterior dorsal brain... None None None None
... ... ... ... ... ... ... ... ... ... ... ...
1026 VFB_jrchjzoi LLPC2a (FlyEM-HB:5813039328) 10 VFB_jrchjtfo DNa10_R (FlyEM-HB:707116522) lobula-lobula plate columnar neuron LLPC descending neuron of the posterior brain DNp10 None None None None
1020 VFB_jrchjwwh LC10 (FlyEM-HB:5813016041) 10 VFB_jrchjtfo DNa10_R (FlyEM-HB:707116522) adult cholinergic neuron|lobula columnar neuro... descending neuron of the posterior brain DNp10 None None None None
1019 VFB_jrchjzul LLPC3 (FlyEM-HB:1777956777) 10 VFB_jrchjtfo DNa10_R (FlyEM-HB:707116522) lobula-lobula plate columnar neuron LLPC descending neuron of the posterior brain DNp10 None None None None
1014 VFB_jrchjy7z LC35_R (FlyEM-HB:1502364155) 10 VFB_jrchjtge DNp10_R (FlyEM-HB:5813026936) lobula columnar neuron|adult cholinergic neuron descending neuron of the posterior brain DNp10 None None None None
1706 VFB_jrchjuts IB043_R (FlyEM-HB:883514695) 10 VFB_jrchjtfr DNb01_R (FlyEM-HB:1566597156) adult inferior bridge neuron 043 descending neuron of the anterior ventral brai... None None None None

1707 rows × 11 columns

[179]:
visPN2DC['upstream_class'].value_counts(normalize=True).plot(kind = 'bar') # Excercise - sum up weights for each type.  Note - some types here subsume others
[179]:
<Axes: xlabel='upstream_class'>
../_images/tutorials_connectomics_9_1.png

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.

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

upstream_of_DNp04 = vfb.get_neurons_upstream_of('DNp04_R (FlyEM-HB:1405231475)', weight = 20)
upstream_of_DNp04
[180]:
query_neuron_id query_neuron_name weight target_neuron_id target_neuron_name
0 VFB_jrchjy98 LC4 (FlyEM-HB:1749258134) 56 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)
1 VFB_jrchk4qn PVLP046_R (FlyEM-HB:1600666632) 48 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)
2 VFB_jrchjy9t LC4 (FlyEM-HB:2215161310) 86 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)
3 VFB_jrchjya4 LC4 (FlyEM-HB:1877930505) 76 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)
4 VFB_jrchk4u3 PVLP100_R (FlyEM-HB:1375845363) 44 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)
... ... ... ... ... ...
82 VFB_jrchjya3 LC4 (FlyEM-HB:1907519001) 75 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)
83 VFB_jrchjy9i LC4 (FlyEM-HB:5813069053) 48 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)
84 VFB_jrchjyaa LC4 (FlyEM-HB:1906159299) 82 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)
85 VFB_jrchjy95 LC4 (FlyEM-HB:1471601440) 41 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)
86 VFB_jrchjy9d LC4 (FlyEM-HB:1627117134) 46 VFB_jrchjtg7 DNp04_R (FlyEM-HB:1405231475)

87 rows × 5 columns

[181]:
vfb.get_TermInfo(upstream_of_DNp04['query_neuron_id'])
[181]:
label symbol id tags description parents_label parents_id data_source accession xrefs templates dataset license
0 LPLC2_R (FlyEM-HB:5813034151) LPLC2_R VFB_jrchk063 [Entity, Adult, Anatomy, Cell, Cholinergic, In... tracing status-Roughly traced, cropped-False [lobula plate-lobula columnar neuron LPLC2] [FBbt_00111763] [neuprint_JRC_Hemibrain_1point1] [5813034151] [neuronbridge:5813034151, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
1 LC4 (FlyEM-HB:1625080038) LC4 VFB_jrchjy9e [Entity, Adult, Anatomy, Cell, Cholinergic, Gl... tracing status-Roughly traced, cropped-False [lobula columnar neuron LC4] [FBbt_00003874] [neuprint_JRC_Hemibrain_1point1] [1625080038] [neuprint_JRC_Hemibrain_1point1:1625080038, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
2 LC4 (FlyEM-HB:1782668028) LC4 VFB_jrchjy9o [Entity, Adult, Anatomy, Cell, Cholinergic, Gl... tracing status-Roughly traced, cropped-False [lobula columnar neuron LC4] [FBbt_00003874] [neuprint_JRC_Hemibrain_1point1] [1782668028] [neuronbridge:1782668028, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
3 LC4 (FlyEM-HB:1874035952) LC4 VFB_jrchjy9z [Entity, Adult, Anatomy, Cell, Cholinergic, Gl... tracing status-Roughly traced, cropped-False [lobula columnar neuron LC4] [FBbt_00003874] [neuprint_JRC_Hemibrain_1point1] [1874035952] [neuprint_JRC_Hemibrain_1point1:1874035952, ne... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
4 LC4 (FlyEM-HB:1810956698) LC4 VFB_jrchjy9j [Entity, Adult, Anatomy, Cell, Cholinergic, Gl... tracing status-Roughly traced, cropped-False [lobula columnar neuron LC4] [FBbt_00003874] [neuprint_JRC_Hemibrain_1point1] [1810956698] [neuprint_JRC_Hemibrain_1point1:1810956698, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
... ... ... ... ... ... ... ... ... ... ... ... ... ...
82 SAD017_R (FlyEM-HB:1630678915) SAD017_R VFB_jrchk4z0 [Entity, Adult, Anatomy, Cell, GABAergic, Indi... tracing status-Roughly traced, cropped-False [adult saddle neuron 017] [FBbt_20002226] [neuprint_JRC_Hemibrain_1point1] [1630678915] [neuronbridge:1630678915, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
83 PVLP142_R (FlyEM-HB:1876565477) PVLP142_R VFB_jrchk4wk [Entity, Adult, Anatomy, Cell, Cholinergic, In... tracing status-Roughly traced, cropped-False [adult cholinergic neuron, adult posterior ven... [FBbt_00058205, FBbt_20002200] [neuprint_JRC_Hemibrain_1point1] [1876565477] [neuronbridge:1876565477, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
84 PVLP151(SCB004)_L (FlyEM-HB:1628973439) PVLP151(SCB004)_L VFB_jrchk4x2 [Entity, Adult, Anatomy, Cell, Cholinergic, In... tracing status-Roughly traced, cropped-False [adult posterior ventrolateral protocerebrum n... [FBbt_20002209] [neuprint_JRC_Hemibrain_1point1] [1628973439] [neuronbridge:1628973439, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
85 PVLP100_R (FlyEM-HB:1375845363) PVLP100_R VFB_jrchk4u3 [Entity, Adult, Anatomy, Cell, GABAergic, Indi... tracing status-Roughly traced, cropped-False [adult posterior ventrolateral protocerebrum n... [FBbt_20002158] [neuprint_JRC_Hemibrain_1point1] [1375845363] [neuronbridge:1375845363, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
86 PVLP094_R (FlyEM-HB:1503733177) PVLP094_R VFB_jrchk4tm [Entity, Adult, Anatomy, Cell, GABAergic, Indi... tracing status-Roughly traced, cropped-False [adult posterior ventrolateral protocerebrum n... [FBbt_20002152] [neuprint_JRC_Hemibrain_1point1] [1503733177] [neuprint_JRC_Hemibrain_1point1:1503733177, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...

87 rows × 13 columns

[182]:
vfb.get_TermInfo(upstream_of_DNp04['query_neuron_id'])
[182]:
label symbol id tags description parents_label parents_id data_source accession xrefs templates dataset license
0 LPLC2_R (FlyEM-HB:5813034151) LPLC2_R VFB_jrchk063 [Entity, Adult, Anatomy, Cell, Cholinergic, In... tracing status-Roughly traced, cropped-False [lobula plate-lobula columnar neuron LPLC2] [FBbt_00111763] [neuprint_JRC_Hemibrain_1point1] [5813034151] [neuronbridge:5813034151, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
1 LC4 (FlyEM-HB:1625080038) LC4 VFB_jrchjy9e [Entity, Adult, Anatomy, Cell, Cholinergic, Gl... tracing status-Roughly traced, cropped-False [lobula columnar neuron LC4] [FBbt_00003874] [neuprint_JRC_Hemibrain_1point1] [1625080038] [neuprint_JRC_Hemibrain_1point1:1625080038, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
2 LC4 (FlyEM-HB:1782668028) LC4 VFB_jrchjy9o [Entity, Adult, Anatomy, Cell, Cholinergic, Gl... tracing status-Roughly traced, cropped-False [lobula columnar neuron LC4] [FBbt_00003874] [neuprint_JRC_Hemibrain_1point1] [1782668028] [neuronbridge:1782668028, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
3 LC4 (FlyEM-HB:1874035952) LC4 VFB_jrchjy9z [Entity, Adult, Anatomy, Cell, Cholinergic, Gl... tracing status-Roughly traced, cropped-False [lobula columnar neuron LC4] [FBbt_00003874] [neuprint_JRC_Hemibrain_1point1] [1874035952] [neuprint_JRC_Hemibrain_1point1:1874035952, ne... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
4 LC4 (FlyEM-HB:1810956698) LC4 VFB_jrchjy9j [Entity, Adult, Anatomy, Cell, Cholinergic, Gl... tracing status-Roughly traced, cropped-False [lobula columnar neuron LC4] [FBbt_00003874] [neuprint_JRC_Hemibrain_1point1] [1810956698] [neuprint_JRC_Hemibrain_1point1:1810956698, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
... ... ... ... ... ... ... ... ... ... ... ... ... ...
82 SAD017_R (FlyEM-HB:1630678915) SAD017_R VFB_jrchk4z0 [Entity, Adult, Anatomy, Cell, GABAergic, Indi... tracing status-Roughly traced, cropped-False [adult saddle neuron 017] [FBbt_20002226] [neuprint_JRC_Hemibrain_1point1] [1630678915] [neuronbridge:1630678915, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
83 PVLP142_R (FlyEM-HB:1876565477) PVLP142_R VFB_jrchk4wk [Entity, Adult, Anatomy, Cell, Cholinergic, In... tracing status-Roughly traced, cropped-False [adult cholinergic neuron, adult posterior ven... [FBbt_00058205, FBbt_20002200] [neuprint_JRC_Hemibrain_1point1] [1876565477] [neuronbridge:1876565477, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
84 PVLP151(SCB004)_L (FlyEM-HB:1628973439) PVLP151(SCB004)_L VFB_jrchk4x2 [Entity, Adult, Anatomy, Cell, Cholinergic, In... tracing status-Roughly traced, cropped-False [adult posterior ventrolateral protocerebrum n... [FBbt_20002209] [neuprint_JRC_Hemibrain_1point1] [1628973439] [neuronbridge:1628973439, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
85 PVLP100_R (FlyEM-HB:1375845363) PVLP100_R VFB_jrchk4u3 [Entity, Adult, Anatomy, Cell, GABAergic, Indi... tracing status-Roughly traced, cropped-False [adult posterior ventrolateral protocerebrum n... [FBbt_20002158] [neuprint_JRC_Hemibrain_1point1] [1375845363] [neuronbridge:1375845363, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
86 PVLP094_R (FlyEM-HB:1503733177) PVLP094_R VFB_jrchk4tm [Entity, Adult, Anatomy, Cell, GABAergic, Indi... tracing status-Roughly traced, cropped-False [adult posterior ventrolateral protocerebrum n... [FBbt_20002152] [neuprint_JRC_Hemibrain_1point1] [1503733177] [neuprint_JRC_Hemibrain_1point1:1503733177, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...

87 rows × 13 columns

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

[183]:
vfb.get_neurons_downstream_of('LC4 (FlyEM-HB:1249932198)', classification="'adult descending neuron'", weight = 10)
[183]:

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.

[184]:
# Using VFB to get neurons by type
DA1 = vfb.get_instances("'adult antennal lobe projection neuron DA1'")
len(DA1)
DA1
[184]:
label symbol id tags data_source accession parents_label parents_id xrefs templates dataset license
0 VGlut-F-200574 VFB_00006638 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [VGlut-F-200574] [medial antennal lobe tract projection neuron,... [FBbt_00067350, FBbt_00067350, FBbt_00067350, ... [FlyCircuit:VGlut-F-200574] [JRC2018Unisex, adult brain template JFRC2] [Chiang2010] []
1 fru-F-400149 VFB_00006344 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [fru-F-400149] [medial antennal lobe tract projection neuron,... [FBbt_00067350, FBbt_00067350, FBbt_00067350, ... [FlyCircuit:fru-F-400149] [JRC2018Unisex, adult brain template JFRC2] [Chiang2010] []
2 Gad1-F-200064 VFB_00011249 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [Gad1-F-200064] [antennal lobe projection neuron of ALl1 linea... [FBbt_00067362, FBbt_00067362, FBbt_00067362, ... [FlyCircuit:Gad1-F-200064] [adult brain template JFRC2, JRC2018Unisex] [Chiang2010] []
3 Gad1-F-200010 VFB_00012622 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [Gad1-F-200010] [adult antennal lobe projection neuron DA1, ad... [FBbt_00048096, FBbt_00048096, FBbt_00048096, ... [FlyCircuit:Gad1-F-200010] [adult brain template JFRC2, JRC2018Unisex] [Chiang2010] []
4 npf-M-300006 VFB_00001755 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [npf-M-300006] [medial antennal lobe tract projection neuron,... [FBbt_00067350, FBbt_00067350, FBbt_00067350, ... [FlyCircuit:npf-M-300006] [JRC2018Unisex, adult brain template JFRC2] [Chiang2010] []
5 VGlut-F-700040 VFB_00013061 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [VGlut-F-700040] [adult antennal lobe projection neuron DA1, ad... [FBbt_00048096, FBbt_00048096, FBbt_00048096, ... [FlyCircuit:VGlut-F-700040] [adult brain template JFRC2, JRC2018Unisex] [Chiang2010] []
6 VGlut-F-000280 VFB_00010758 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [VGlut-F-000280] [adult antennal lobe projection neuron DA1, ad... [FBbt_00048096, FBbt_00048096, FBbt_00048096, ... [FlyCircuit:VGlut-F-000280] [adult brain template JFRC2, JRC2018Unisex] [Chiang2010] []
7 VGlut-F-600450 VFB_00010984 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [VGlut-F-600450] [adult ALl1 lineage neuron, adult ALl1 lineage... [FBbt_00050025, FBbt_00050025, FBbt_00050025, ... [FlyCircuit:VGlut-F-600450] [adult brain template JFRC2, JRC2018Unisex] [Chiang2010] []
8 VGlut-F-800317 VFB_00005913 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [VGlut-F-800317] [antennal lobe projection neuron of ALl1 linea... [FBbt_00067362, FBbt_00067362, FBbt_00067362, ... [FlyCircuit:VGlut-F-800317] [adult brain template JFRC2, JRC2018Unisex] [Chiang2010] []
9 Cha-F-500006 VFB_00010085 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [Cha-F-500006] [adult ALl1 lineage neuron, adult ALl1 lineage... [FBbt_00050025, FBbt_00050025, FBbt_00050025, ... [FlyCircuit:Cha-F-500006] [adult brain template JFRC2, JRC2018Unisex] [Chiang2010] []
10 VGlut-F-600326 VFB_00012155 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [VGlut-F-600326] [medial antennal lobe tract projection neuron,... [FBbt_00067350, FBbt_00067350, FBbt_00067350, ... [FlyCircuit:VGlut-F-600326] [JRC2018Unisex, adult brain template JFRC2] [Chiang2010] []
11 VGlut-F-000655 VFB_00006552 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [VGlut-F-000655] [adult antennal lobe projection neuron DA1, ad... [FBbt_00048096, FBbt_00048096, FBbt_00048096, ... [FlyCircuit:VGlut-F-000655] [adult brain template JFRC2, JRC2018Unisex] [Chiang2010] []
12 VGlut-F-700188 VFB_00010912 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [VGlut-F-700188] [antennal lobe projection neuron of ALl1 linea... [FBbt_00067362, FBbt_00067362, FBbt_00067362, ... [FlyCircuit:VGlut-F-700188] [JRC2018Unisex, adult brain template JFRC2] [Chiang2010] []
13 fru-M-200319 VFB_00000323 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [fru-M-200319] [antennal lobe projection neuron of ALl1 linea... [FBbt_00067362, FBbt_00067362, FBbt_00067362, ... [FlyCircuit:fru-M-200319] [JRC2018Unisex, adult brain template JFRC2] [Chiang2010] []
14 VGlut-F-800329 VFB_00005957 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [VGlut-F-800329] [antennal lobe projection neuron of ALl1 linea... [FBbt_00067362, FBbt_00067362, FBbt_00067362, ... [FlyCircuit:VGlut-F-800329] [JRC2018Unisex, adult brain template JFRC2] [Chiang2010] []
15 Cha-F-300252 VFB_00005625 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [Cha-F-300252] [adult ALl1 lineage neuron, adult ALl1 lineage... [FBbt_00050025, FBbt_00050025, FBbt_00050025, ... [FlyCircuit:Cha-F-300252] [adult brain template JFRC2, JRC2018Unisex] [Chiang2010] []
16 Uniglomerular mlALT DA1 vPN#R1 (FAFB:1811442) VFB_0010121x [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [1811442] [adult antennal lobe projection neuron DA1 vPN] [FBbt_00067372] [catmaid_fafb:1811442] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
17 DA1_lPN_R (FlyEM-HB:1734350908) DA1_lPN_R VFB_jrchjtdb [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [1734350908] [adult antennal lobe projection neuron DA1 lPN... [FBbt_00067363, FBbt_00110423] [neuprint_JRC_Hemibrain_1point1:1734350908, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
18 Uniglomerular mALT DA1 lPN#L6 (FAFB:2381753) VFB_0010123b [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [2381753] [adult antennal lobe projection neuron DA1 lPN... [FBbt_00067363, FBbt_00110423] [catmaid_fafb:2381753] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
19 Uniglomerular mALT DA1 lPN#L3 (FAFB:2345089) VFB_0010122p [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [2345089] [adult fruitless aDT-e (female) neuron, adult ... [FBbt_00110423, FBbt_00067363] [catmaid_fafb:2345089] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
20 Uniglomerular mALT DA1 lPN#R7 (FAFB:57353) VFB_00101202 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [57353] [adult antennal lobe projection neuron DA1 lPN] [FBbt_00067363] [catmaid_fafb:57353] [JRC2018Unisex] [Zheng2018] [https://creativecommons.org/licenses/by-sa/4....
21 DA1_lPN_R (FlyEM-HB:754534424) DA1_lPN_R VFB_jrchjtde [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [754534424] [adult antennal lobe projection neuron DA1 lPN... [FBbt_00067363, FBbt_00110423] [neuronbridge:754534424, neuprint_JRC_Hemibrai... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
22 Multiglomerular mALT lvPN#L2 (FAFB:7710838) VFB_00102dw8 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [7710838] [adult antennal lobe projection neuron DA1 lvPN] [FBbt_20003824] [catmaid_fafb:7710838] [JRC2018Unisex] [TaiszGalili2022] [https://creativecommons.org/licenses/by-sa/4....
23 DA1_vPN_R (FlyEM-HB:733316908) DA1_vPN_R VFB_jrchjtdh [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [733316908] [adult antennal lobe projection neuron DA1 vPN] [FBbt_00067372] [neuronbridge:733316908, neuprint_JRC_Hemibrai... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
24 Gad1-F-400088 VFB_00009611 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [FlyCircuit] [Gad1-F-400088] [expression pattern fragment, adult antennal l... [VFBext_0000004, FBbt_00067372] [FlyCircuit:Gad1-F-400088] [JRC2018Unisex, adult brain template JFRC2] [Chiang2010] []
25 Uniglomerular mlALT DA1 vPN#L1 (FAFB:2334841) VFB_0010122m [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [2334841] [adult antennal lobe projection neuron DA1 vPN] [FBbt_00067372] [catmaid_fafb:2334841] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
26 M_lvPNm45_R (FlyEM-HB:792023887) M_lvPNm45_R VFB_jrchk0xm [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [792023887] [adult antennal lobe projection neuron DA1 lvPN] [FBbt_20003824] [neuronbridge:792023887, neuprint_JRC_Hemibrai... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
27 Uniglomerular mALT DA1 lPN#R1 (FAFB:57323) VFB_00101201 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [57323] [adult antennal lobe projection neuron DA1 lPN] [FBbt_00067363] [catmaid_fafb:57323] [JRC2018Unisex] [Zheng2018] [https://creativecommons.org/licenses/by-sa/4....
28 DA1_lPN_R (FlyEM-HB:1765040289) DA1_lPN_R VFB_jrchjtdc [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [1765040289] [adult antennal lobe projection neuron DA1 lPN... [FBbt_00067363, FBbt_00110423] [neuronbridge:1765040289, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
29 Uniglomerular mALT DA1 lPN#L2 (FAFB:2319457) VFB_0010122k [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [2319457] [adult antennal lobe projection neuron DA1 lPN... [FBbt_00067363, FBbt_00110423] [catmaid_fafb:2319457] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
30 Uniglomerular mALT DA1 lPN#L7 (FAFB:3239781) VFB_0010124l [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [3239781] [adult fruitless aDT-e (female) neuron, adult ... [FBbt_00110423, FBbt_00067363] [catmaid_fafb:3239781] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
31 Uniglomerular mALT DA1 lPN#L5 (FAFB:2380564) VFB_0010122z [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [2380564] [adult antennal lobe projection neuron DA1 lPN... [FBbt_00067363, FBbt_00110423] [catmaid_fafb:2380564] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
32 DA1_lPN_R (FlyEM-HB:722817260) DA1_lPN_R VFB_jrchjtda [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [722817260] [adult antennal lobe projection neuron DA1 lPN... [FBbt_00067363, FBbt_00110423] [neuprint_JRC_Hemibrain_1point1:722817260, neu... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
33 Uniglomerular mALT DA1 lPN#R3 (FAFB:61221) VFB_00101204 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [61221] [adult antennal lobe projection neuron DA1 lPN] [FBbt_00067363] [catmaid_fafb:61221] [JRC2018Unisex] [Zheng2018] [https://creativecommons.org/licenses/by-sa/4....
34 M_lvPNm45_R (FlyEM-HB:757591093) M_lvPNm45_R VFB_jrchk0xl [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [757591093] [adult antennal lobe projection neuron DA1 lvPN] [FBbt_20003824] [neuprint_JRC_Hemibrain_1point1:757591093, neu... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
35 DA1_lPN_R (FlyEM-HB:1734350788) DA1_lPN_R VFB_jrchjtdf [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [1734350788] [adult fruitless aDT-e (female) neuron, adult ... [FBbt_00110423, FBbt_00067363] [neuprint_JRC_Hemibrain_1point1:1734350788, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
36 Uniglomerular mALT DA1 lPN#R2 (FAFB:57311) VFB_00101200 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [57311] [adult antennal lobe projection neuron DA1 lPN] [FBbt_00067363] [catmaid_fafb:57311] [JRC2018Unisex] [Zheng2018] [https://creativecommons.org/licenses/by-sa/4....
37 DA1_lPN_R (FlyEM-HB:754538881) DA1_lPN_R VFB_jrchjtdg [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [754538881] [adult fruitless aDT-e (female) neuron, adult ... [FBbt_00110423, FBbt_00067363] [neuronbridge:754538881, neuprint_JRC_Hemibrai... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
38 M_lvPNm45_R (FlyEM-HB:757258507) M_lvPNm45_R VFB_jrchk0xk [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [757258507] [adult antennal lobe projection neuron DA1 lvPN] [FBbt_20003824] [neuprint_JRC_Hemibrain_1point1:757258507, neu... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
39 Multiglomerular mALT lvPN#L1 (FAFB:4520197) VFB_00102dvy [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [4520197] [adult antennal lobe projection neuron DA1 lvPN] [FBbt_20003824] [catmaid_fafb:4520197] [JRC2018Unisex] [TaiszGalili2022] [https://creativecommons.org/licenses/by-sa/4....
40 Multiglomerular mALT lvPN#R46 (FAFB:57179) VFB_001011zb [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [57179] [adult antennal lobe projection neuron DA1 lvPN] [FBbt_20003824] [catmaid_fafb:57179] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
41 Multiglomerular mALT lvPN#R44 (FAFB:57158) VFB_001011z9 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [57158] [adult antennal lobe projection neuron DA1 lvPN] [FBbt_20003824] [catmaid_fafb:57158] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
42 Multiglomerular mALT lvPN#L3 (FAFB:4520615) VFB_00102dvz [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [4520615] [adult antennal lobe projection neuron DA1 lvPN] [FBbt_20003824] [catmaid_fafb:4520615] [JRC2018Unisex] [TaiszGalili2022] [https://creativecommons.org/licenses/by-sa/4....
43 Uniglomerular mALT DA1 lPN#L1 (FAFB:4207871) VFB_0010126e [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [4207871] [adult fruitless aDT-e (female) neuron, adult ... [FBbt_00110423, FBbt_00067363] [catmaid_fafb:4207871] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
44 DA1_lPN_R (FlyEM-HB:5813039315) DA1_lPN_R VFB_jrchjtdd [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [neuprint_JRC_Hemibrain_1point1] [5813039315] [adult fruitless aDT-e (female) neuron, adult ... [FBbt_00110423, FBbt_00067363] [neuronbridge:5813039315, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
45 Multiglomerular mALT lvPN#R45 (FAFB:57035) VFB_001011z3 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [57035] [adult antennal lobe projection neuron DA1 lvPN] [FBbt_20003824] [catmaid_fafb:57035] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
46 Uniglomerular mALT DA1 lPN#R4 (FAFB:755022) VFB_00101205 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [755022] [adult antennal lobe projection neuron DA1 lPN] [FBbt_00067363] [catmaid_fafb:755022] [JRC2018Unisex] [Zheng2018] [https://creativecommons.org/licenses/by-sa/4....
47 Uniglomerular mALT DA1 lPN#R5 (FAFB:2863104) VFB_0010124e [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [2863104] [adult antennal lobe projection neuron DA1 lPN... [FBbt_00067363, FBbt_00110423] [catmaid_fafb:2863104] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
48 Uniglomerular mALT DA1 lPN#L4 (FAFB:2379517) VFB_0010122y [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [2379517] [adult antennal lobe projection neuron DA1 lPN... [FBbt_00067363, FBbt_00110423] [catmaid_fafb:2379517] [JRC2018Unisex] [BatesSchlegel2020] [https://creativecommons.org/licenses/by-sa/4....
49 Uniglomerular mALT DA1 lPN#R6 (FAFB:27295) VFB_00101199 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [27295] [adult antennal lobe projection neuron DA1 lPN] [FBbt_00067363] [catmaid_fafb:27295] [JRC2018Unisex] [Zheng2018] [https://creativecommons.org/licenses/by-sa/4....
50 Uniglomerular mALT DA1 lPN#R8 (FAFB:57381) VFB_00101203 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... [catmaid_fafb] [57381] [adult antennal lobe projection neuron DA1 lPN] [FBbt_00067363] [catmaid_fafb:57381] [JRC2018Unisex] [Zheng2018] [https://creativecommons.org/licenses/by-sa/4....
[185]:
# Map neurons to CATMAID Skeleton IDs (skids)

da1_skids = vfb.vfb_id_2_xrefs(DA1['id'], db='catmaid_fafb', reverse_return=True)
da1_skids_int = list(map(int, da1_skids))
da1_skids_int
33mWarning: The following IDs do not match DB &/or id_type constraints: {'VFB_jrchk0xk', 'VFB_001011z3', 'VFB_00102dw8', 'VFB_00101204', 'VFB_001011zb', 'VFB_0010122p', 'VFB_jrchjtda', 'VFB_00101201', 'VFB_00101203', 'VFB_0010122m', 'VFB_jrchjtdh', 'VFB_00011249', 'VFB_jrchjtde', 'VFB_00010984', 'VFB_0010126e', 'VFB_00001755', 'VFB_00006344', 'VFB_jrchjtdb', 'VFB_00000323', 'VFB_jrchjtdd', 'VFB_00013061', 'VFB_00009611', 'VFB_00005957', 'VFB_0010123b', 'VFB_jrchjtdc', 'VFB_00101202', 'VFB_0010124l', 'VFB_0010122y', 'VFB_00006638', 'VFB_jrchk0xl', 'VFB_00101200', 'VFB_00012155', 'VFB_00101199', 'VFB_0010121x', 'VFB_00012622', 'VFB_00102dvz', 'VFB_00005625', 'VFB_0010122k', 'VFB_00101205', 'VFB_00102dvy', 'VFB_00005913', 'VFB_jrchjtdf', 'VFB_0010124e', 'VFB_00010085', 'VFB_00010758', 'VFB_jrchjtdg', 'VFB_00006552', 'VFB_001011z9', 'VFB_0010122z', 'VFB_jrchk0xm', 'VFB_00010912'}
[185]:
[2381753,
 7710838,
 4520197,
 57179,
 2379517,
 3239781,
 57158,
 57035,
 2345089,
 57311,
 27295,
 2380564,
 2319457,
 4520615,
 57323,
 2334841,
 755022,
 1811442,
 61221,
 57353,
 4207871,
 57381,
 2863104]

Generate a connectivity table for neurons downstream of DA1 neurons

[186]:
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 23 neurons (pymaid)
INFO  : Done. Found 0 pre-, 301 postsynaptic and 0 gap junction-connected neurons (pymaid)
[186]:
neuron_name skeleton_id num_nodes relation 2381753 7710838 4520197 57179 2379517 3239781 ... 57323 2334841 755022 1811442 61221 57353 4207871 57381 2863104 total
0 Uniglomerular mlALT DA1 vPN mlALTed Milk 18114... 1811442 11769 downstream 0 0 0 0 0 0 ... 20 0 32 0 26 3 0 4 30 152
1 Uniglomerular mlALT DA1 vPN mlALTed Milk 23348... 2334841 6362 downstream 32 0 0 0 28 26 ... 0 0 0 0 0 0 17 0 0 139
2 LHAV4c1#1 488056 downstream DA1 GSXEJ 488055 12137 downstream 0 0 0 13 0 0 ... 11 0 15 0 15 3 0 0 15 111
3 LHAV4a4#1 1911125 FML PS RJVR 1911124 6969 downstream 0 0 0 0 0 0 ... 15 0 19 0 13 6 0 9 23 109
4 LHAV2a3#1 1870231 RJVR AJES PS 1870230 14820 downstream 0 0 0 0 0 0 ... 7 0 19 1 7 23 0 28 5 105

5 rows × 28 columns

[187]:
# 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 584 neurons matching the search parameters (pymaid)
[187]:
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 × 584 columns

[188]:
import seaborn as sns

ax = sns.clustermap(adj, vmax=10, cmap='Greys')
# ax = sns.heatmap(adj, vmax=10, cmap='Greys')

/Users/robbiecourt/GIT/VFB_connect/.conda/lib/python3.10/site-packages/seaborn/matrix.py:560: UserWarning:

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

/Users/robbiecourt/GIT/VFB_connect/.conda/lib/python3.10/site-packages/seaborn/matrix.py:560: UserWarning:

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

../_images/tutorials_connectomics_23_1.png
[189]:
# Axo-axonic connections between two different types of DA1 PNs
cn = pymaid.get_connectors_between(2863104, 1811442)
cn.head()
[189]:
connector_id connector_loc node1_id source_neuron confidence1 creator1 node1_loc node2_id target_neuron confidence2 creator2 node2_loc
0 17870563 [363219.0, 169182.0, 153920.0] 6903652 2863104 5 NaN [362894.0, 169511.0, 153920.0] 6546760 1811442 5 NaN [363421.0, 168741.0, 153920.0]
1 6795747 [355030.0, 154048.0, 145800.0] 6795749 2863104 5 NaN [355045.0, 154180.0, 145800.0] 6795745 1811442 5 NaN [355024.0, 153946.0, 145760.0]
2 6826199 [358042.0, 160788.0, 147600.0] 6826200 2863104 5 NaN [355948.0, 160126.0, 147600.0] 6826198 1811442 5 NaN [358194.0, 160883.0, 147600.0]
3 6835037 [354306.0, 154100.0, 152320.0] 6835043 2863104 5 NaN [354088.0, 153842.0, 152320.0] 6835033 1811442 5 NaN [354400.0, 154346.0, 152360.0]
4 7032350 [355192.0, 167586.0, 158320.0] 7032356 2863104 5 NaN [354814.0, 167861.0, 158320.0] 17870268 1811442 5 NaN [356626.0, 167779.0, 158200.0]
[190]:
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")
              )

Data type cannot be displayed: application/vnd.plotly.v1+json

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.

[191]:
!pip install neuprint-python --quiet

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:

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

class NeuronCriteria(builtins.object)
 |  NeuronCriteria(matchvar='n', *, bodyId=None, type=None, instance=None, regex='guess', status=None, statusLabel=None, rois=None, inputRois=None, outputRois=None, roi_req='all', min_roi_inputs=1, min_roi_outputs=1, group=None, serial=None, cropped=None, birthtime=None, cellBodyFiber=None, class_=None, entryNerve=None, exitNerve=None, hemilineage=None, longTract=None, modality=None, origin=None, predictedNt=None, serialMotif=None, somaNeuromere=None, somaSide=None, subclass=None, synonyms=None, systematicType=None, target=None, label=None, min_pre=0, min_post=0, somaLocation=None, tosomaLocation=None, rootLocation=None, soma=None, client=None)
 |
 |  Neuron selection criteria.
 |
 |  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, type=None, instance=None, regex='guess', status=None, statusLabel=None, rois=None, inputRois=None, outputRois=None, roi_req='all', min_roi_inputs=1, min_roi_outputs=1, group=None, serial=None, cropped=None, birthtime=None, cellBodyFiber=None, class_=None, entryNerve=None, exitNerve=None, hemilineage=None, longTract=None, modality=None, origin=None, predictedNt=None, serialMotif=None, somaNeuromere=None, somaSide=None, subclass=None, synonyms=None, systematicType=None, target=None, label=None, min_pre=0, min_post=0, somaLocation=None, tosomaLocation=None, rootLocation=None, soma=None, client=None)
 |      All criteria must be passed as keyword arguments.
 |
 |      .. note::
 |          Only ``bodyId``, ``type``, ``instance``, and ROI-related criteria are
 |          applicable to all datasets.  The applicability of all other criteria depends
 |          on the dataset being accessed (e.g. hemibrain,  manc, etc.).
 |
 |      .. 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 produces a more expensive query, but it's more selective.
 |          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.
 |
 |      .. note::
 |
 |          **Matching against missing values (NULL)**
 |
 |          To search for neurons which are missing given property entirely,
 |          you can use a list containing ``None``, or the special value ``neuprint.IsNull``.
 |          For example, to find neurons with no `type`, use ``type=[None]`` or ``type=IsNull``.
 |
 |          **Matching against any value (NOT NULL)**
 |
 |          To search for any non-null value, you can use ``neuprint.NotNull``. For
 |          example, to find neurons that have a type (no matter what the
 |          type is), use ``type=NotNull``.
 |
 |      Args:
 |          matchvar (str):
 |              An arbitrary cypher variable name to use when this
 |              ``NeuronCriteria`` is used to construct cypher queries.
 |              Must begin with a lowercase letter.
 |
 |          bodyId (int or list of ints):
 |              List of bodyId values.
 |
 |          type (str or list of str):
 |              Cell type.  Matches depend on the the ``regex`` argument.
 |              If both ``type`` and ``instance`` criteria are supplied, any neuron that
 |              matches EITHER criteria will match the overall criteria.
 |
 |          instance (str or list of str):
 |              Cell instance (specific cell name).  Matches depend on the the ``regex`` argument.
 |              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.
 |              If ``False``, only exact matches will be found.
 |              By default, the matching method will be automatically chosen by inspecting the
 |              ``type`` and ``instance`` strings.  If they contain regex-like characters,
 |              then we assume you intend regex matching. (You can see which method was chosen by
 |              checking the ``regex`` field after the ``NeuronCriteria`` is constructed.)
 |
 |          status (str or list of str):
 |              Indicates the status of the neuron's reconstruction quality.
 |              Typically, named/annotated neurons have ``Traced`` status,
 |              the best quality.
 |          statusLabel (str or list of str):
 |             ``statusLabel`` is typically more fine-grained than ``status``,
 |             and mostly of interest during the construction of the connectome,
 |             not for end-users.  The possible values of ``statusLabel`` do not
 |             correspond one-to-one to those of ``status``.
 |
 |          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.
 |
 |          group (int or list of int)
 |              In some datasets, the ``group`` ID is used to associate neurons morphological type,
 |              including left-right homologues. Neurons with the same group ID have matching morphology.
 |
 |          serial (int or list of int)
 |              Similar to ``group``, but used for associating neurons across segmental neuropils in the nerve cord.
 |              Neurons with the same ``serial`` ID are analogous to one another, but in different leg segments.
 |
 |          cropped (bool):
 |              If given, restrict results to neurons that are cropped or not.
 |
 |          birthtime (str or list of str):
 |          cellBodyFiber (str or list of str):
 |          class\_ (str or list of str):
 |              Matches for the neuron ``class`` field.
 |          entryNerve (str or list of str):
 |          exitNerve (str or list of str):
 |          hemilineage (str or list of str):
 |          longTract (str or list of str):
 |          modality (str or list of str):
 |          origin (str or list of str):
 |          predictedNt (str or list of str):
 |          serialMotif (str or list of str):
 |          somaNeuromere (str or list of str):
 |          somaSide  (str or list of str):
 |              Valid choices are 'RHS', 'LHS', 'Midline'
 |          subclass (str or list of str):
 |          synonyms (str or list of str):
 |          systematicType (str or list of str):
 |          target (str or list of str):
 |
 |          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.)
 |
 |          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.
 |
 |          somaLocation:
 |              The ``somaLocation`` property of ``:Neuron`` objects contains
 |              the ``[X,Y,Z]`` coordinate (in voxels) of the cell body.
 |              ``NeuronCriteria`` does not allow you to match a specific coordinate,
 |              but you may set this argument to ``NotNull` (or ```IsNull``) to
 |              search for cells with (or without) a recorded cell body.
 |
 |          tosomaLocation:
 |              Neurons which could not be successfully attached to their cell body do not have
 |              a recorded ``somaLocation``.  Instead, they have an annotaiton on the cell body
 |              fiber, on the severed end extending out toward the cell body.
 |              Like ``somaLocation``, you can't match a specific coordinate using ``NeuronCriteria``,
 |              but you can use ``NotNull``/``IsNull``.
 |
 |          rootLocation:
 |              Some (but not all) Neurons which have no soma in the tissue sample are tagged with
 |              a ``rootLocation``, indicating where they enter/exit the sample.
 |              Like ``somaLocation``, you can't match a specific coordinate using ``NeuronCriteria``,
 |              but you can use ``NotNull``/``IsNull``.
 |
 |          soma (Either ``True``, ``False``, or ``None``)
 |              DEPRECATED.  Use ``somaLocation=NotNull`` or ``somaLocation=IsNull``.
 |
 |          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.
 |
 |  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)
 |
 |  rois_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
 |
 |  __slotnames__ = []

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):

[193]:
# 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.
[193]:
bodyId instance type pre post downstream upstream size status cropped statusLabel cellBodyFiber somaRadius somaLocation roiInfo notes inputRois outputRois
0 294792184 M_vPNml53_R M_vPNml53 92 344 730 344 420662445 Traced False Roughly traced AVM04 336.5 [18923, 34319, 35424] {'SNP(R)': {'pre': 70, 'post': 155, 'downstrea... None [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(...
1 329599710 M_lvPNm32_R M_lvPNm32 247 285 2052 285 343478957 Traced False Roughly traced AVM06 NaN None {'SNP(R)': {'pre': 180, 'post': 93, 'downstrea... 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...
2 417199910 M_lvPNm36_R M_lvPNm36 162 347 1590 347 387058559 Traced False Roughly traced AVM06 351.5 [13823, 33925, 34176] {'SNP(R)': {'pre': 156, 'post': 95, 'downstrea... None [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...
3 480927537 M_vPNml70_R M_vPNml70 82 276 692 276 240153322 Traced False Roughly traced AVM04 NaN None {'SNP(R)': {'pre': 15, 'post': 18, 'downstream... None [AL(R), AL-DA2(R), AL-DA4l(R), AL-DA4m(R), AL-... [LH(R), SLP(R), SNP(R)]
4 481268653 M_vPNml89_R M_vPNml89 146 58 1614 58 265085609 Traced False Roughly traced AVM04 NaN None {'SNP(R)': {'pre': 10, 'post': 2, 'downstream'... None [AL(R), AL-VC3l(R), AL-VC4(R), AL-VP1m(R), LH(... [LH(R), SLP(R), SNP(R)]
[194]:
# Check that the regex did not have any accidental by-catch
pns['type'].unique()
[194]:
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)

We can find the same neuron types using VFB instead. This allows curated neuron classes to be used and doesn’t depend on knowing naming conventions and using potentially error prone regex pattern matching.

[195]:
#This will get all ALPNs from ALL datasets on VFB
ALPNs = vfb.get_instances("'adult antennal lobe projection neuron'")
# Explode the lists in the 'data_source' column into separate rows as each image can potentialy have multiple data sources. NNote this can be done for any column with lists
exploded_ALPNs = ALPNs.explode('data_source')
#Select only rows from Hemibrain1.1 dataset
ALPNs=exploded_ALPNs[exploded_ALPNs['data_source'] == 'neuprint_JRC_Hemibrain_1point1']
ALPNs
[195]:
label symbol id tags data_source accession parents_label parents_id xrefs templates dataset license
4 MZ_lv2PN_R (FlyEM-HB:1825440160) MZ_lv2PN_R VFB_jrchk0vg [Entity, Adult, Anatomy, Cell, Chemosensory_sy... neuprint_JRC_Hemibrain_1point1 [1825440160] [adult GABAergic neuron, adult GABAergic neuro... [FBbt_00058207, FBbt_00058207, FBbt_00058207, ... [neuprint_JRC_Hemibrain_1point1:1825440160, ne... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
9 VP1d+VP4_l2PN2(lALT)_R (FlyEM-HB:5901222731) VP1d+VP4_l2PN2(lALT)_R VFB_jrchk7io [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [5901222731] [adult cholinergic neuron, adult cholinergic n... [FBbt_00058205, FBbt_00058205, FBbt_00058205, ... [neuprint_JRC_Hemibrain_1point1:5901222731, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
12 M_vPNml76_R (FlyEM-HB:1570685132) M_vPNml76_R VFB_jrchk0zb [Entity, Adult, Anatomy, Cell, GABAergic, Indi... neuprint_JRC_Hemibrain_1point1 [1570685132] [adult GABAergic neuron, adult GABAergic neuro... [FBbt_00058207, FBbt_00058207, FBbt_00058207, ... [neuprint_JRC_Hemibrain_1point1:1570685132, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
13 M_l2PNm17_R (FlyEM-HB:5813083723) M_l2PNm17_R VFB_jrchk0w8 [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [5813083723] [adult cholinergic neuron, adult cholinergic n... [FBbt_00058205, FBbt_00058205, FBbt_00058205, ... [neuronbridge:5813083723, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
28 M_imPNl92_R (FlyEM-HB:1701299822) M_imPNl92_R VFB_jrchk0vv [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [1701299822] [adult cholinergic neuron, adult cholinergic n... [FBbt_00058205, FBbt_00058205, FBbt_00058205, ... [neuprint_JRC_Hemibrain_1point1:1701299822, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
... ... ... ... ... ... ... ... ... ... ... ... ...
1649 M_lvPNm40_R (FlyEM-HB:1732313117) M_lvPNm40_R VFB_jrchk0xb [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [1732313117] [adult multiglomerular antennal lobe projectio... [FBbt_20003819] [neuronbridge:1732313117, neuprint_JRC_Hemibra... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
1651 DL2d_adPN_R (FlyEM-HB:1793351401) DL2d_adPN_R VFB_jrchjte8 [Entity, Adult, Anatomy, Cell, Chemosensory_sy... neuprint_JRC_Hemibrain_1point1 [1793351401] [adult antennal lobe projection neuron DL2d adPN] [FBbt_00100389] [neuronbridge:1793351401, neuprint_JRC_Hemibra... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
1653 MZ_lvPN(multiAL+SEZ)_R (FlyEM-HB:1974846717) MZ_lvPN(multiAL+SEZ)_R VFB_jrchk0vh [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [1974846717] [adult antennal lobe projection neuron VP2+SEZ... [FBbt_00049744] [neuprint_JRC_Hemibrain_1point1:1974846717, ne... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
1654 M_lvPNm41_R (FlyEM-HB:1795410644) M_lvPNm41_R VFB_jrchk0xd [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [1795410644] [adult multiglomerular antennal lobe projectio... [FBbt_20003820] [neuronbridge:1795410644, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
1660 M_lPNm11D_R (FlyEM-HB:1887163927) M_lPNm11D_R VFB_jrchk0wf [Entity, Adult, Anatomy, Cell, Chemosensory_sy... neuprint_JRC_Hemibrain_1point1 [1887163927] [adult antennal lobe projection neuron VP1d++ ... [FBbt_00049753] [neuronbridge:1887163927, neuprint_JRC_Hemibra... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...

339 rows × 12 columns

Fetching synaptic partners

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

[196]:
exploded_ALPNs = ALPNs.explode('accession')
ds = neu.fetch_simple_connections(upstream_criteria=list(map(int, exploded_ALPNs['accession'])))
#using hemibrain regex
#ds = neu.fetch_simple_connections(upstream_criteria=neu.NeuronCriteria(bodyId=pns.bodyId.values))
ds
[196]:
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:

[197]:
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
[197]:
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:

[198]:
#First find KCs in VFB
KCs = vfb.get_instances("'adult Kenyon cell'")
#Select only rows from Hemibrain1.1 dataset
exploded_KCs = KCs.explode('data_source')
KCs=exploded_KCs[exploded_KCs['data_source'] == 'neuprint_JRC_Hemibrain_1point1']
KCs
[198]:
label symbol id tags data_source accession parents_label parents_id xrefs templates dataset license
0 KCab-m_R (FlyEM-HB:363384138) KCab-m_R VFB_jrchjvjo [Entity, Adult, Anatomy, Cell, Cholinergic, Do... neuprint_JRC_Hemibrain_1point1 [363384138] [adult dopaminergic neuron, adult dopaminergic... [FBbt_00058206, FBbt_00058206, FBbt_00058206, ... [neuprint_JRC_Hemibrain_1point1:363384138, neu... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
1 KCab-m_R (FlyEM-HB:363725201) KCab-m_R VFB_jrchjvl1 [Entity, Adult, Anatomy, Cell, Cholinergic, Do... neuprint_JRC_Hemibrain_1point1 [363725201] [adult dopaminergic neuron, adult dopaminergic... [FBbt_00058206, FBbt_00058206, FBbt_00058206, ... [neuronbridge:363725201, neuprint_JRC_Hemibrai... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
2 KCa\'b\'-ap2_R (FlyEM-HB:5813020052) KCa\'b\'-ap2_R VFB_jrchjv3x [Entity, Adult, Anatomy, Cell, Cholinergic, Do... neuprint_JRC_Hemibrain_1point1 [5813020052] [mushroom body dopaminergic neuron, mushroom b... [FBbt_00048138, FBbt_00048138, FBbt_00048138, ... [neuronbridge:5813020052, neuprint_JRC_Hemibra... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
4 KCa\'b\'-m_R (FlyEM-HB:5812982397) KCa\'b\'-m_R VFB_jrchjva1 [Entity, Adult, Anatomy, Cell, Cholinergic, Do... neuprint_JRC_Hemibrain_1point1 [5812982397] [adult dopaminergic neuron, adult dopaminergic... [FBbt_00058206, FBbt_00058206, FBbt_00058206, ... [neuronbridge:5812982397, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
7 KCg-m_R (FlyEM-HB:5812982168) KCg-m_R VFB_jrchjw51 [Entity, Adult, Anatomy, Cell, Cholinergic, Do... neuprint_JRC_Hemibrain_1point1 [5812982168] [adult dopaminergic neuron, adult dopaminergic... [FBbt_00058206, FBbt_00058206, FBbt_00058206, ... [neuprint_JRC_Hemibrain_1point1:5812982168, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
... ... ... ... ... ... ... ... ... ... ... ... ...
5092 KCg-m_R (FlyEM-HB:5812980386) KCg-m_R VFB_jrchjwa4 [Entity, Adult, Anatomy, Cell, Cholinergic, Do... neuprint_JRC_Hemibrain_1point1 [5812980386] [mushroom body dopaminergic neuron, mushroom b... [FBbt_00048138, FBbt_00048138, FBbt_00048138, ... [neuronbridge:5812980386, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
5093 KCg-m_R (FlyEM-HB:5813020089) KCg-m_R VFB_jrchjwcm [Entity, Adult, Anatomy, Cell, Cholinergic, Do... neuprint_JRC_Hemibrain_1point1 [5813020089] [mushroom body dopaminergic neuron, mushroom b... [FBbt_00048138, FBbt_00048138, FBbt_00048138, ... [neuprint_JRC_Hemibrain_1point1:5813020089, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
5094 KCg-m_R (FlyEM-HB:1141636389) KCg-m_R VFB_jrchjwcf [Entity, Adult, Anatomy, Cell, Cholinergic, Do... neuprint_JRC_Hemibrain_1point1 [1141636389] [mushroom body dopaminergic neuron, mushroom b... [FBbt_00048138, FBbt_00048138, FBbt_00048138, ... [neuprint_JRC_Hemibrain_1point1:1141636389, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
5097 KCg-m_R (FlyEM-HB:5812982436) KCg-m_R VFB_jrchjwcz [Entity, Adult, Anatomy, Cell, Cholinergic, Do... neuprint_JRC_Hemibrain_1point1 [5812982436] [adult dopaminergic neuron, adult dopaminergic... [FBbt_00058206, FBbt_00058206, FBbt_00058206, ... [neuronbridge:5812982436, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
5114 KCg-m_R (FlyEM-HB:602809029) KCg-m_R VFB_jrchjwe0 [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [602809029] [gamma main Kenyon cell] [FBbt_00111061] [neuronbridge:602809029, neuprint_JRC_Hemibrai... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...

1927 rows × 12 columns

[199]:
# Fixes for conda environment to ensure full jupyterlab compatibility
import subprocess

# Check if conda is available
try:
    subprocess.run(["conda", "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    conda_available = True
except subprocess.CalledProcessError:
    conda_available = False

# Only run these commands if conda is available
if conda_available:
    try:
        # Update conda base environment
        subprocess.run(["conda", "update", "-n", "base", "-c", "defaults", "conda", "-y"], check=True)
        # Install jupyterlab_widgets
        subprocess.run(["conda", "install", "-n", "base", "-c", "conda-forge", "jupyterlab_widgets", "-y"], check=True)
        # Install ipywidgets
        subprocess.run(["conda", "install", "-n", "base", "-c", "conda-forge", "ipywidgets", "-y"], check=True)
        print("Conda packages updated successfully.")
    except subprocess.CalledProcessError as e:
        print(f"An error occurred while running a conda command: {e}")
else:
    print("Conda is not available in this environment.")

Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working...

The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - defaults/osx-64::conda==23.1.0=py310hecd8cb5_0
done


==> WARNING: A newer version of conda exists. <==
  current version: 23.1.0
  latest version: 24.7.1

Please update conda by running

    $ conda update -n base -c defaults conda

Or to minimize the number of packages updated during conda update use

     conda install conda=24.7.1



## Package Plan ##

  environment location: /usr/local/Caskroom/miniconda/base

  added / updated specs:
    - conda


The following NEW packages will be INSTALLED:

  brotli-python      pkgs/main/osx-64::brotli-python-1.0.9-py310hcec6c5f_8
  libcxx             pkgs/main/osx-64::libcxx-14.0.6-h9765a3e_0
  lz4-c              pkgs/main/osx-64::lz4-c-1.9.4-hcec6c5f_1
  pip                pkgs/main/osx-64::pip-24.2-py310hecd8cb5_0
  pluggy             pkgs/main/osx-64::pluggy-1.0.0-py310hecd8cb5_1
  zstd               pkgs/main/osx-64::zstd-1.5.5-hc035e20_2

The following packages will be UPDATED:

  bzip2                                    1.0.8-h1de35cc_0 --> 1.0.8-h6c40b1e_6
  cffi                               1.15.1-py310h6c40b1e_3 --> 1.16.0-py310h6c40b1e_1
  charset-normalizer                     2.0.4-pyhd3eb1b0_0 --> 3.3.2-pyhd3eb1b0_0
  conda-package-han~                  2.0.2-py310hecd8cb5_0 --> 2.3.0-py310hecd8cb5_0
  conda-package-str~                  0.7.0-py310hecd8cb5_0 --> 0.10.0-py310hecd8cb5_0
  cryptography                       38.0.4-py310hf6deb26_0 --> 42.0.5-py310h30e54ef_1
  idna                                  3.4-py310hecd8cb5_0 --> 3.7-py310hecd8cb5_0
  libffi                                   3.4.2-hecd8cb5_6 --> 3.4.4-hecd8cb5_1
  openssl            conda-forge::openssl-1.1.1w-h8a1eda9_0 --> pkgs/main::openssl-3.0.14-h46256e1_0
  pycosat                             0.6.4-py310hca72f7f_0 --> 0.6.6-py310h6c40b1e_1
  pyopenssl          pkgs/main/noarch::pyopenssl-22.0.0-py~ --> pkgs/main/osx-64::pyopenssl-24.2.1-py310hecd8cb5_0
  python                                  3.10.9-h218abb5_0 --> 3.10.14-h5ee71fb_1
  requests                           2.28.1-py310hecd8cb5_0 --> 2.32.3-py310hecd8cb5_0
  sqlite                                  3.40.1-h880c91c_0 --> 3.45.3-h6c40b1e_0
  tk                                      8.6.12-h5d9f67b_0 --> 8.6.14-h4d00af3_0
  tqdm                               4.64.1-py310hecd8cb5_0 --> 4.66.4-py310h20db666_0
  tzdata                                   2022g-h04d1e81_0 --> 2024a-h04d1e81_0
  urllib3                           1.26.14-py310hecd8cb5_0 --> 2.2.2-py310hecd8cb5_0
  xz                                      5.2.10-h6c40b1e_1 --> 5.4.6-h6c40b1e_1
  zlib                                    1.2.13-h4dc903c_0 --> 1.2.13-h4b97444_1
  zstandard                          0.18.0-py310hca72f7f_0 --> 0.22.0-py310h2d76c9a_0

The following packages will be SUPERSEDED by a higher-priority channel:

  ca-certificates    conda-forge::ca-certificates-2024.7.4~ --> pkgs/main::ca-certificates-2024.7.2-hecd8cb5_0
  certifi            conda-forge/noarch::certifi-2024.7.4-~ --> pkgs/main/osx-64::certifi-2024.7.4-py310hecd8cb5_0



Downloading and Extracting Packages

Preparing transaction: ...working... done
Verifying transaction: ...working... failed

RemoveError: 'pluggy' is a dependency of conda and cannot be removed from
conda's operating environment.

An error occurred while running a conda command: Command '['conda', 'update', '-n', 'base', '-c', 'defaults', 'conda', '-y']' returned non-zero exit status 1.
[200]:
exploded_KCs = KCs.explode('accession')
adj, roi_info2 = neu.fetch_adjacencies(sources=list(map(int, exploded_ALPNs['accession'][:300])), targets=list(map(int, exploded_KCs['accession'][:300])))
roi_info2.head()
[200]:
bodyId_pre bodyId_post roi weight
0 544021095 509700197 CA(R) 25
1 544021095 601047853 CA(R) 16
2 544021095 632069757 CA(R) 29
3 544021095 632397798 CA(R) 21
4 544021095 662103124 CA(R) 9
[201]:
# Group by region of interest (ROI)
by_roi = roi_info2.groupby('roi').weight.sum()
by_roi.head()
[201]:
roi
CA(R)         20279
NotPrimary      276
SCL(R)           74
SLP(R)          392
Name: weight, dtype: int64
[202]:
ax = by_roi.plot.bar()
ax.set_xlabel('')
ax.set_ylabel('PN to KC synapses')
[202]:
Text(0, 0.5, 'PN to KC synapses')
../_images/tutorials_connectomics_46_1.png
[203]:

adj = roi_info2[roi_info2.roi == 'CA(R)'].pivot(columns="bodyId_pre", index="bodyId_post", values="weight").fillna(0)
[204]:
sns.clustermap(adj, cmap='Greys')
/Users/robbiecourt/GIT/VFB_connect/.conda/lib/python3.10/site-packages/seaborn/matrix.py:560: UserWarning:

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

/Users/robbiecourt/GIT/VFB_connect/.conda/lib/python3.10/site-packages/seaborn/matrix.py:560: UserWarning:

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

[204]:
<seaborn.matrix.ClusterGrid at 0x7f8a0bd2df60>
../_images/tutorials_connectomics_48_2.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).

[205]:
#First find DNs in VFB
DNs = vfb.get_instances("'adult descending neuron'")
#Select only rows from Hemibrain1.1 dataset
exploded_DNs = DNs.explode('data_source')
DNs=exploded_DNs[exploded_DNs['data_source'] == ('neuprint_JRC_Hemibrain_1point1')]
DNs
[205]:
label symbol id tags data_source accession parents_label parents_id xrefs templates dataset license
0 DNb03_R (FlyEM-HB:5813022608) DNb03_R VFB_jrchjtfu [Entity, Adult, Anatomy, Cell, Glutamatergic, ... neuprint_JRC_Hemibrain_1point1 [5813022608] [adult glutamatergic neuron, adult glutamaterg... [FBbt_00058208, FBbt_00058208, FBbt_00058208, ... [neuprint_JRC_Hemibrain_1point1:5813022608, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
1 DNp17_R (FlyEM-HB:1815895547) DNp17_R VFB_jrchjth7 [Entity, Adult, Anatomy, Cell, Glutamatergic, ... neuprint_JRC_Hemibrain_1point1 [1815895547] [adult glutamatergic neuron, adult glutamaterg... [FBbt_00058208, FBbt_00058208, FBbt_00058208, ... [neuprint_JRC_Hemibrain_1point1:1815895547, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
2 DNp27_L (FlyEM-HB:5813020347) DNp27_L VFB_jrchjthn [Entity, Adult, Anatomy, Cell, Dopaminergic, I... neuprint_JRC_Hemibrain_1point1 [5813020347] [adult dopaminergic neuron, adult dopaminergic... [FBbt_00058206, FBbt_00058206, FBbt_00058206, ... [neuprint_JRC_Hemibrain_1point1:5813020347, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
3 DNp16/17_R (FlyEM-HB:5813108230) DNp16/17_R VFB_jrchjtgy [Entity, Adult, Anatomy, Cell, Individual, Ner... neuprint_JRC_Hemibrain_1point1 [5813108230] [descending neuron of the posterior brain, des... [FBbt_00047517, FBbt_00047517, FBbt_00047517, ... [neuronbridge:5813108230, neuprint_JRC_Hemibra... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
4 DNp28_R (FlyEM-HB:1158074778) DNp28_R VFB_jrchjtho [Entity, Adult, Anatomy, Cell, Glutamatergic, ... neuprint_JRC_Hemibrain_1point1 [1158074778] [adult glutamatergic neuron, adult glutamaterg... [FBbt_00058208, FBbt_00058208, FBbt_00058208, ... [neuprint_JRC_Hemibrain_1point1:1158074778, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
... ... ... ... ... ... ... ... ... ... ... ... ...
292 CRE101_R (FlyEM-HB:985835016) CRE101_R VFB_jrchjtco [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [985835016] [adult crepine neuron 101] [FBbt_20001170] [neuprint_JRC_Hemibrain_1point1:985835016, neu... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
293 DNp18_R (FlyEM-HB:5813068840) DNp18_R VFB_jrchjthb [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [5813068840] [descending neuron of the posterior brain DNp18] [FBbt_00047651] [neuprint_JRC_Hemibrain_1point1:5813068840, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
294 IB046(PDM28)_L (FlyEM-HB:1068441202) IB046(PDM28)_L VFB_jrchjuu0 [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [1068441202] [adult inferior bridge neuron 046] [FBbt_20001223] [neuprint_JRC_Hemibrain_1point1:1068441202, ne... [JRC_FlyEM_Hemibrain, JRC2018Unisex] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
295 DNp09_R (FlyEM-HB:1228264951) DNp09_R VFB_jrchjtgb [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [1228264951] [descending neuron of the posterior brain DNp09] [FBbt_00047642] [neuronbridge:1228264951, neuprint_JRC_Hemibra... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...
296 PS016_R (FlyEM-HB:1292713151) PS016_R VFB_jrchk47s [Entity, Adult, Anatomy, Cell, Cholinergic, In... neuprint_JRC_Hemibrain_1point1 [1292713151] [adult posterior slope neuron 016] [FBbt_20001771] [neuprint_JRC_Hemibrain_1point1:1292713151, ne... [JRC2018Unisex, JRC_FlyEM_Hemibrain] [Xu2020NeuronsV1point1] [https://creativecommons.org/licenses/by/4.0/l...

249 rows × 12 columns

[206]:
# First fetch the DNs
exploded_DNs = DNs.explode('accession')
dns, _ = neu.fetch_neurons(list(map(int, exploded_DNs['accession'])))
#with regex
#dns, _ = neu.fetch_neurons(neu.NeuronCriteria(type='(.*DN[^1]{0,}.*|Giant Fiber)', regex=True))
dns
[206]:
bodyId instance type pre post downstream upstream size status cropped statusLabel cellBodyFiber somaRadius somaLocation roiInfo notes inputRois outputRois
0 297925719 SMP478_R SMP478 11 514 33 514 887352389 Traced False Roughly traced PDM15 301.0 [18670, 15472, 12256] {'SNP(R)': {'pre': 8, 'post': 411, 'downstream... pMP1 candidates [INP, SCL(R), SIP(R), SLP(R), SMP(L), SMP(R), ... [SIP(R), SMP(R), SNP(R)]
1 298961895 SMP478_R SMP478 8 569 38 569 862856817 Traced False Roughly traced PDM15 301.0 [17329, 15560, 10624] {'SNP(R)': {'pre': 5, 'post': 317, 'downstream... pMP1 candidates [INP, SCL(R), SMP(L), SMP(R), SNP(L), SNP(R)] [SMP(L), SMP(R), SNP(L), SNP(R)]
2 299298593 SMP478(PDM15)_L SMP478 5 289 16 289 613001071 Traced False Roughly traced None NaN None {'SNP(R)': {'pre': 1, 'post': 80, 'downstream'... pMP1 candidates [SMP(L), SMP(R), SNP(L), SNP(R)] [SMP(L), SMP(R), SNP(L), SNP(R)]
3 326253554 SMP454_R SMP454 2613 9756 21869 9756 8166517062 Traced False Roughly traced PDM12 465.5 [22142, 20149, 5600] {'SNP(R)': {'pre': 1374, 'post': 3627, 'downst... None [ATL(R), AVLP(R), CAN(R), CRE(-ROB,-RUB)(R), C... [AOTU(R), AVLP(R), CRE(-ROB,-RUB)(R), CRE(-RUB...
4 327255181 SMP290_R SMP290 147 455 1028 455 816661754 Traced False Roughly traced PDM05 396.0 [23064, 11810, 14912] {'SNP(R)': {'pre': 63, 'post': 390, 'downstrea... pMP5 candidates [FLA(R), PENP, SMP(L), SMP(R), SNP(L), SNP(R),... [FLA(R), PENP, SMP(R), SNP(R), mALT(R)]
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
244 5813078352 PS133_R PS133 9 1041 30 1041 1572727885 Traced False Roughly traced PDM17 351.0 [26154, 14795, 14256] {'INP': {'post': 252, 'upstream': 252}, 'SCL(R... None [CAN(R), EPA(L), EPA(R), GNG, GOR(L), GOR(R), ... [CAN(R), GOR(R), IPS(R), PENP, SPS(L), SPS(R),...
245 5813082237 PS212_R PS212 77 5047 299 5047 2290180209 Traced False Roughly traced PVM02 456.5 [20933, 11422, 19304] {'INP': {'pre': 14, 'post': 613, 'downstream':... None [EPA(R), GNG, GOR(R), IB, ICL(R), INP, IPS(R),... [GNG, IB, ICL(R), INP, IPS(R), PLP(R), SPS(R),...
246 5813095193 DNp16_R DNp16 70 683 429 683 292910198 Traced False Roughly traced PVM02 276.0 [25941, 10730, 20000] {'INP': {'post': 34, 'upstream': 34}, 'IB': {'... None [CAN(R), GNG, IB, INP, IPS(R), PENP, SPS(R), V... [CAN(R), GNG, IPS(R), PENP, SPS(R), VMNP]
247 5813096489 VES081_R VES081 14 1321 71 1321 928031787 Traced False Roughly traced PVM15 451.0 [15106, 10109, 20144] {'VMNP': {'pre': 5, 'post': 1190, 'downstream'... None [AL(R), GNG, IPS(R), LAL(-GA)(R), LAL(R), LX(R... [GNG, VES(R), VMNP]
248 5813108230 DNp16/17_R DNp16/17 5 177 16 177 304268206 Traced False Roughly traced PVM02 321.5 [23677, 10111, 18544] {'INP': {'post': 2, 'upstream': 2}, 'IB': {'po... None [GNG, IB, INP, IPS(R), SPS(R), VMNP] [IPS(R), SPS(R), VMNP]

249 rows × 18 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.

[207]:
# Find all paths from A PN to A DNs
paths = neu.fetch_shortest_paths(upstream_bodyId=list(map(int, exploded_ALPNs['accession']))[0],
                                 downstream_bodyId=list(map(int, exploded_DNs['accession']))[0],
                                 min_weight=10)
paths
[207]:
path bodyId type weight
0 0 1825440160 MZ_lv2PN 0
1 0 1733677514 M_l2PNm16 13
2 0 913754682 LHPV2i2 13
3 0 1374900967 PLP214 13
4 0 1292713484 PS014 30
... ... ... ... ...
233 33 5813078378 None 26
234 33 5813125985 PS018 10
235 33 5813022629 PS013 18
236 33 1963869286 DNb03 16
237 33 5813022608 DNb03 11

238 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):

[208]:
# 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

[208]:
<class 'navis.core.neuronlist.NeuronList'> containing 7 neurons (2.0MiB)
type name id n_nodes n_connectors n_branches n_leafs cable_length soma units
0 navis.TreeNeuron MZ_lv2PN_R 1825440160 18919 None 1757 1785 618498.8125 NaN 8 nanometer
1 navis.TreeNeuron M_l2PNm16_R 1733677514 13841 None 1174 1208 694829.6875 13730.0 8 nanometer
... ... ... ... ... ... ... ... ... ... ...
5 navis.TreeNeuron DNb03_R 1963869286 6965 None 802 811 266966.8750 6799.0 8 nanometer
6 navis.TreeNeuron DNb03_R 5813022608 6116 None 683 702 274112.5625 11.0 8 nanometer
[209]:
# 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)')
[210]:
# Plot
navis.plot3d([nl, lh, al, ca], width=1100)

Data type cannot be displayed: application/vnd.plotly.v1+json

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:

[211]:
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')
[212]:
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_60_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. see nx.write_gml