VFB_connect Quickstart Guide
[1]:
!pip install -r ../../../requirements.txt --quiet
!pip install ../../../ --quiet
# Import lib and initialise object
from vfb_connect import vfb
Welcome to the Virtual Fly Brain API
See the documentation at: https://virtualflybrain.org/docs/tutorials/apis/
Establishing connections to https://VirtualFlyBrain.org services...
Session Established!
Type vfb. and press tab to see available queries. You can run help against any query e.g. help(vfb.get_TermInfo)
VFB connect API overview
The VFB connect API provides programmatic access to the databases underlying Virtual Fly Brain.
At the core of Virtual Fly Brain is a set of curated terms for Drosophila neuro-anatomy organised into a queryable classification, including terms for brain regions, e.g. nodulus and neurons e.g. MBON01. These terms are used to annotate and classify individual brain regions and neurons in images and connectomics data. For example the term MBON01 is used to classify individual neurons from sources including the CATMAID-FAFB and Neuprint-HemiBrain databases. VFB stores both registered 3D images and connectomics data (where available) for all of these neurons.
A single VfbConnect object wraps connections and canned queries against all open VFB databases. It includes methods for retreiving metadata about anatomy, individual brain regions and neurons including IDs for these that can be used for queries against other databases (e.g. CATMAID & neuprint). It provides methods for downloading images and connectomics data. It provides access to sophisticated queries for anatomical classes and individual neurons accoring to their classification & properties.
Locations for methods under a VfbConnect
object.
Directly under
vfb
are:A set of methods that take lists of IDs as a primary argument and return metadata.
A set of methods for mapping between VFB IDs and external IDs
A set of methods that take the names of classes in VFB e.g. ‘nodulus’ or ‘Kenyon cell’, or simple query expressions using the names of classes and return metadata about the classes.
A set methods for querying connectivity and similarity
Direct access to API queries is provided under the ‘nc’ and ‘oc’ attributes for Neo4J and OWL queries respectively. We will not cover details of how to use these here.
Note: available methods and their documentation are easy to explore in DeepNote. Tab completion and type adhead can be used to help find methods. Float your cursor over a method to see its signature and docstring.
1. vfb
Neo4j query methods overview
1.1 vfb.get_TermInfo
TermInfo queries return the results of a VFB Term Information window as JSON, following the VFB_JSON standard, or a summary that can be provided as a DataFrame or dictonary.
[2]:
# A query for full TermInfo. This probably produces more information than you will need for most purposes.
vfb.get_TermInfo(['FBbt_00003686'], summary=False)[0].keys()
[2]:
dict_keys(['term', 'query', 'version', 'parents', 'relationships', 'related_individuals', 'xrefs', 'anatomy_channel_image', 'pub_syn', 'def_pubs', 'targeting_splits'])
[3]:
# A query for summary info
summary = vfb.get_TermInfo(['FBbt_00003686'], return_dataframe=False)
summary
[3]:
[{'label': 'Kenyon cell',
'symbol': 'KC',
'id': 'FBbt_00003686',
'tags': ['Entity',
'Anatomy',
'Cell',
'Class',
'Nervous_system',
'Neuron',
'has_subClass',
'hasScRNAseq'],
'description': 'Intrinsic neuron of the mushroom body. They have tightly-packed cell bodies, situated in the rind above the calyx of the mushroom body (Ito et al., 1997). Four short fascicles, one per lineage, extend from the cell bodies of the Kenyon cells into the calyx (Ito et al., 1997). These 4 smaller fascicles converge in the calyx where they arborize and form pre- and post-synaptic terminals (Christiansen et al., 2011), with different Kenyon cells receiving input in different calyx regions/accessory calyces (Tanaka et al., 2008). They emerge from the calyx as a thick axon bundle referred to as the peduncle that bifurcates to innervate the dorsal and medial lobes of the mushroom body (Tanaka et al., 2008). Pre-synaptic terminals were identified using two presynaptic markers (Brp and Dsyd-1) and post-synaptic terminals by labelling a subunit of the acetylcholine receptor (Dalpha7) in genetically labelled Kenyon cells (Christiansen et al., 2011).',
'parents_label': ['anterior ectoderm derivative',
'mushroom body intrinsic neuron'],
'parents_id': ['FBbt_00025991', 'FBbt_00007484'],
'data_source': [],
'accession': [],
'xrefs': []}]
[4]:
# The same method can be used to get info about individual neurons
summary = vfb.get_TermInfo(['VFB_jrchjrch'])
summary
[4]:
label | symbol | id | tags | description | parents_label | parents_id | data_source | accession | xrefs | templates | dataset | license | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 5-HTPLP01_R (FlyEM-HB:1324365879) | 5-HTPLP01_R | VFB_jrchjrch | [Entity, Adult, Anatomy, Cell, Glutamatergic, ... | tracing status-Roughly traced, cropped-False | [adult glutamatergic neuron, adult serotonergi... | [FBbt_00058208, FBbt_00110945] | [neuprint_JRC_Hemibrain_1point1] | [1324365879] | [neuronbridge:1324365879, neuprint_JRC_Hemibra... | [JRC2018Unisex, JRC_FlyEM_Hemibrain] | [Xu2020NeuronsV1point1] | [https://creativecommons.org/licenses/by/4.0/l... |
1.2 The vfb
also includes methods for mapping between IDs from different sources.
[5]:
# Some bodyIDs of HemiBrain neurons from the neuprint DataBase:
bodyIDs = [1068958652, 571424748, 1141631198]
vfb.xref_2_vfb_id(map(str, bodyIDs), return_just_ids=False) # Note IDs must be strings
[5]:
{'1068958652': [{'db': 'neuronbridge', 'vfb_id': 'VFB_jrch06r9'},
{'db': 'neuronbridge', 'vfb_id': 'VFB_jrchjwda'},
{'db': 'neuprint_JRC_Hemibrain_1point0point1', 'vfb_id': 'VFB_jrch06r9'},
{'db': 'neuprint_JRC_Hemibrain_1point1', 'vfb_id': 'VFB_jrchjwda'}],
'571424748': [{'db': 'neuronbridge', 'vfb_id': 'VFB_jrch06r6'},
{'db': 'neuronbridge', 'vfb_id': 'VFB_jrchjwct'},
{'db': 'neuprint_JRC_Hemibrain_1point0point1', 'vfb_id': 'VFB_jrch06r6'},
{'db': 'neuprint_JRC_Hemibrain_1point1', 'vfb_id': 'VFB_jrchjwct'}],
'1141631198': [{'db': 'neuronbridge', 'vfb_id': 'VFB_jrch05uz'},
{'db': 'neuronbridge', 'vfb_id': 'VFB_jrchjw8r'},
{'db': 'neuprint_JRC_Hemibrain_1point0point1', 'vfb_id': 'VFB_jrch05uz'},
{'db': 'neuprint_JRC_Hemibrain_1point1', 'vfb_id': 'VFB_jrchjw8r'}]}
[6]:
# xref queries can be constrained by DB. Results can optionally be reversed
vfb.xref_2_vfb_id(map(str, bodyIDs), db = 'neuprint_JRC_Hemibrain_1point1' , reverse_return=True, return_just_ids=False)
[6]:
{'VFB_jrchjwct': [{'acc': '571424748',
'db': 'neuprint_JRC_Hemibrain_1point1'}],
'VFB_jrchjw8r': [{'acc': '1141631198',
'db': 'neuprint_JRC_Hemibrain_1point1'}],
'VFB_jrchjwda': [{'acc': '1068958652',
'db': 'neuprint_JRC_Hemibrain_1point1'}]}
2. vfb
OWL and Neo4j combined methods overview
2.1 Methods that take the names of classes in VFB e.g. ‘nodulus’ or ‘Kenyon cell’, or simple query expressions using the names of classes and return metadata about the classes or individual neurons
[7]:
KC_types = vfb.get_subclasses("Kenyon cell")
KC_types[0:5]
[7]:
label | symbol | id | tags | data_source | accession | parents_label | parents_id | |
---|---|---|---|---|---|---|---|---|
0 | Kenyon cell of main calyx | FBbt_00047926 | [Entity, Adult, Anatomy, Cell, Cholinergic, Cl... | [] | [] | [adult Kenyon cell, adult Kenyon cell, adult K... | [FBbt_00049825, FBbt_00049825, FBbt_00049825, ... | |
1 | alpha/beta core Kenyon cell | KCab-c | FBbt_00110929 | [Entity, Adult, Anatomy, Cell, Cholinergic, Cl... | [] | [] | [alpha/beta surface/core Kenyon cell, alpha/be... | [FBbt_00049838, FBbt_00049838, FBbt_00049838, ... |
2 | gamma main Kenyon cell | KCg-m | FBbt_00111061 | [Entity, Adult, Anatomy, Cell, Cholinergic, Cl... | [] | [] | [Kenyon cell of main calyx, Kenyon cell of mai... | [FBbt_00047926, FBbt_00047926, FBbt_00047926, ... |
3 | alpha/beta inner-core Kenyon cell | FBbt_00049111 | [Entity, Adult, Anatomy, Cell, Cholinergic, Cl... | [] | [] | [alpha/beta core Kenyon cell, alpha/beta core ... | [FBbt_00110929, FBbt_00110929] | |
4 | gamma Kenyon cell | FBbt_00100247 | [Entity, Anatomy, Cell, Class, Nervous_system,... | [] | [] | [Kenyon cell, Kenyon cell, Kenyon cell, Kenyon... | [FBbt_00003686, FBbt_00003686, FBbt_00003686, ... |
2.2 Methods for querying connectivity
Please see Connectomics Notebook for examples