Documentation

Mapping

If you have a single neuron, how can you find other neurons of the same or similar type within or between data sources?

27 Dec 2021

Superseded by the workshop

This page is kept for reference from the 2021 Hacking the connectome workshop. The current material is Session 2 · Bridging & Identity on the VFB Self-led Learning Sessions — the same ground against live VFB data, worked through in Python, R, an MCP-capable assistant, VFB Chat and the 3D browser.

!pip install vfb-connect --upgrade
# Import libs and initialise API objects
from vfb_connect.cross_server_tools import VfbConnect
import pandas as pd

vc = VfbConnect()

import pymaid
import navis

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

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

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

# Many functions return JSON-compatible nested data structures. This function coverts them to DataFrame.
def summary_2_df(summary, sort=None):
    """Convert summary to DataFrame.  Optionally specify a set of columns to sort as a list of strings"""
    if sort:
        return pd.DataFrame.from_records(summary).sort_values(sort)
    else:
        return pd.DataFrame.from_records(summary)
WARNING: Could not load OpenGL library.
INFO  : Global CATMAID instance set. Caching is ON. (pymaid)
Server is running CATMAID version 2020.02.15-925-gf56795c9c

Mapping

Use case: If I have a single neuron, how can I find other neurons of the same or similar type within or between data sources?

Mapping via common parent type

# lets take some examples from a discovery query on the previous spreadhseet
sayin_tab = pd.DataFrame.from_records(vc.get_instances_by_dataset('Sayin2019', summary=True))
sayin_tab

labelsymbolidtagsparents_labelparents_iddata_sourceaccessiontemplatesdatasetlicense
0OA-VPM3 (FAFB:1329078)VFB_001001drEntity|Octopaminergic|Adult|Anatomy|has_image|...octopaminergic VPM3 neuronFBbt_00110151catmaid_fafb1329078JRC2018UnisexSayin2019https://creativecommons.org/licenses/by-sa/4.0...
1OA-VPM4 (FAFB:1191261)VFB_001001dqEntity|Octopaminergic|Adult|Anatomy|has_image|...octopaminergic VPM4 neuronFBbt_00110152catmaid_fafb1191261JRC2018UnisexSayin2019https://creativecommons.org/licenses/by-sa/4.0...
oct_VPM3 = summary_2_df(vc.get_instances('octopaminergic VPM3 neuron', summary=True))
oct_VPM3

labelsymbolidtagsparents_labelparents_iddata_sourceaccessiontemplatesdatasetlicense
0OA-VPM3(NO2/NO3)_R - 329566174VFB_jrchk10dEntity|Octopaminergic|Adult|Anatomy|has_image|...octopaminergic VPM3 neuronFBbt_00110151neuprint_JRC_Hemibrain_1point1329566174JRC2018Unisex|JRC_FlyEM_HemibrainXu2020NeuronsV1point1https://creativecommons.org/licenses/by/4.0/le...
1OA-VPM3(NO2/NO3)_L - 5813061260VFB_jrchk10eEntity|Octopaminergic|Adult|Anatomy|has_image|...octopaminergic VPM3 neuronFBbt_00110151neuprint_JRC_Hemibrain_1point15813061260JRC_FlyEM_Hemibrain|JRC2018UnisexXu2020NeuronsV1point1https://creativecommons.org/licenses/by/4.0/le...
2OA-VPM3 (FAFB:1329078)VFB_001001drEntity|Octopaminergic|Adult|Anatomy|has_image|...octopaminergic VPM3 neuronFBbt_00110151catmaid_fafb1329078JRC2018UnisexSayin2019https://creativecommons.org/licenses/by-sa/4.0...
oct_VPM3_images = vc.neo_query_wrapper.get_images(oct_VPM3['id'], stomp=True, template='JRC2018Unisex', image_folder = 'oct_VPM3b')
oct_VPM3_images

labelsymbolidtagsparents_labelparents_iddata_sourceaccessiontemplatesdatasetlicensefilename
0OA-VPM3 (FAFB:1329078)VFB_001001drEntity|Octopaminergic|Adult|Anatomy|has_image|...octopaminergic VPM3 neuronFBbt_00110151catmaid_fafb1329078JRC2018UnisexSayin2019https://creativecommons.org/licenses/by-sa/4.0...OA_VPM3__FAFB_1329078_.swc
1OA-VPM3(NO2/NO3)_L - 5813061260VFB_jrchk10eEntity|Octopaminergic|Adult|Anatomy|has_image|...octopaminergic VPM3 neuronFBbt_00110151neuprint_JRC_Hemibrain_1point15813061260JRC_FlyEM_Hemibrain|JRC2018UnisexXu2020NeuronsV1point1https://creativecommons.org/licenses/by/4.0/le...OA_VPM3_NO2_NO3__L___5813061260.swc
2OA-VPM3(NO2/NO3)_R - 329566174VFB_jrchk10dEntity|Octopaminergic|Adult|Anatomy|has_image|...octopaminergic VPM3 neuronFBbt_00110151neuprint_JRC_Hemibrain_1point1329566174JRC2018Unisex|JRC_FlyEM_HemibrainXu2020NeuronsV1point1https://creativecommons.org/licenses/by/4.0/le...OA_VPM3_NO2_NO3__R___329566174.swc
oct_VPM3_images = vc.get_images_by_type('octopaminergic VPM3 neuron', stomp=True, template='JRC2018Unisex', image_folder = 'oct_VPM3')
nl = navis.read_swc('./oct_VPM3')
navis.plot3d(nl)
Running query: FBbt:00110151
Query URL: http://owl.virtualflybrain.org/kbs/vfb/instances?object=FBbt%3A00110151&prefixes=%7B%22FBbt%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FFBbt_%22%2C+%22RO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FRO_%22%2C+%22BFO%22%3A+%22http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_%22%7D&direct=False
Query results: 3