Using the cect Python API¶
This notebook outlines the use of the Python package cect, the C. elegans Connectome Toolbox. Source of this file on GitHub
1) Install the cect package using pip¶
If the package has not already been installed, use pip to install it.
In [5]:
Copied!
!pip install -q cect # use this line to install the latest version of cect from PyPI if you haven't already
!pip install -q cect # use this line to install the latest version of cect from PyPI if you haven't already
2) Open an existing Connectome Dataset (White et al. 1986)¶
In [6]:
Copied!
from cect.readers.White_whole import get_instance
white_connectome_dataset = get_instance()
print(white_connectome_dataset.summary())
from cect.readers.White_whole import get_instance
white_connectome_dataset = get_instance()
print(white_connectome_dataset.summary())
cect >>> Opened White et al file: /Users/padraig/git/ConnectomeToolbox/cect/readers/../data/aconnectome_white_1986_whole.csv cect >>> Preexisting connection (1885 conns already) w: 6.000000 at (279,279) - new one: Connection from M4 to M4 (6 times, type: GapJunction, neurotransmitter: Generic_GJ)... cect >>> Connection is the same as existing, no change. cect >>> Preexisting connection (1895 conns already) w: 4.000000 at (280,280) - new one: Connection from M5 to M5 (4 times, type: GapJunction, neurotransmitter: Generic_GJ)... cect >>> Connection is the same as existing, no change. cect >>> Preexisting connection (2432 conns already) w: 1.000000 at (99,99) - new one: Connection from RIBL to RIBL (1 times, type: GapJunction, neurotransmitter: Generic_GJ)... cect >>> Connection is the same as existing, no change. cect >>> Preexisting connection (2472 conns already) w: 1.000000 at (95,95) - new one: Connection from RIBR to RIBR (1 times, type: GapJunction, neurotransmitter: Generic_GJ)... cect >>> Connection is the same as existing, no change. cect >>> Preexisting connection (2541 conns already) w: 1.000000 at (119,119) - new one: Connection from RID to RID (1 times, type: GapJunction, neurotransmitter: Generic_GJ)... cect >>> Connection is the same as existing, no change. cect >>> Preexisting connection (3250 conns already) w: 1.000000 at (189,189) - new one: Connection from VA8 to VA8 (1 times, type: GapJunction, neurotransmitter: Generic_GJ)... cect >>> Connection is the same as existing, no change. Nodes present (309): ['ADAL', 'ADAR', 'ADEL', 'ADER', 'ADFL', 'ADFR', 'ADLL', 'ADLR', 'AFDL', 'AFDR', 'AIAL', 'AIAR', 'AIBL', 'AIBR', 'AIML', 'AIMR', 'AINL', 'AINR', 'AIYL', 'AIYR', 'AIZL', 'AIZR', 'ALA', 'ALML', 'ALMR', 'ALNL', 'ALNR', 'AQR', 'AS1', 'AS10', 'AS11', 'AS2', 'AS3', 'AS4', 'AS5', 'AS6', 'AS7', 'AS8', 'AS9', 'ASEL', 'ASER', 'ASGL', 'ASGR', 'ASHL', 'ASHR', 'ASIL', 'ASIR', 'ASJL', 'ASJR', 'ASKL', 'ASKR', 'AUAL', 'AUAR', 'AVAL', 'AVAR', 'AVBL', 'AVBR', 'AVDL', 'AVDR', 'AVEL', 'AVER', 'AVFL', 'AVFR', 'AVG', 'AVHL', 'AVHR', 'AVJL', 'AVJR', 'AVKL', 'AVKR', 'AVL', 'AVM', 'AWAL', 'AWAR', 'AWBL', 'AWBR', 'AWCL', 'AWCR', 'BAGL', 'BAGR', 'BDUL', 'BDUR', 'BWM', 'CEPDL', 'CEPDR', 'CEPVL', 'CEPVR', 'DA1', 'DA2', 'DA3', 'DA4', 'DA5', 'DA6', 'DA7', 'DA8', 'DA9', 'DB1', 'DB2', 'DB3', 'DB4', 'DB5', 'DB6', 'DB7', 'DD1', 'DD2', 'DD3', 'DD4', 'DD5', 'DD6', 'DVA', 'DVB', 'DVC', 'FLPL', 'FLPR', 'GLRDL', 'GLRDR', 'GLRL', 'GLRR', 'GLRVL', 'GLRVR', 'HSNL', 'HSNR', 'I1L', 'I1R', 'I2L', 'I2R', 'I3', 'I4', 'I5', 'I6', 'IL1DL', 'IL1DR', 'IL1L', 'IL1R', 'IL1VL', 'IL1VR', 'IL2DL', 'IL2DR', 'IL2L', 'IL2R', 'IL2VL', 'IL2VR', 'LUAL', 'LUAR', 'M1', 'M2L', 'M2R', 'M3L', 'M3R', 'M4', 'M5', 'MCL', 'MCR', 'MI', 'NSML', 'NSMR', 'OLLL', 'OLLR', 'OLQDL', 'OLQDR', 'OLQVL', 'OLQVR', 'PDA', 'PDB', 'PDEL', 'PDER', 'PHAL', 'PHAR', 'PHBL', 'PHBR', 'PHCL', 'PHCR', 'PLML', 'PLMR', 'PLNL', 'PLNR', 'PQR', 'PVCL', 'PVCR', 'PVDL', 'PVDR', 'PVM', 'PVNL', 'PVNR', 'PVPL', 'PVPR', 'PVQL', 'PVQR', 'PVR', 'PVT', 'PVWL', 'PVWR', 'RIAL', 'RIAR', 'RIBL', 'RIBR', 'RICL', 'RICR', 'RID', 'RIFL', 'RIFR', 'RIGL', 'RIGR', 'RIH', 'RIML', 'RIMR', 'RIPL', 'RIPR', 'RIR', 'RIS', 'RIVL', 'RIVR', 'RMDDL', 'RMDDR', 'RMDL', 'RMDR', 'RMDVL', 'RMDVR', 'RMED', 'RMEL', 'RMER', 'RMEV', 'RMFL', 'RMFR', 'RMGL', 'RMGR', 'RMHL', 'RMHR', 'SAADL', 'SAADR', 'SAAVL', 'SAAVR', 'SABD', 'SABVL', 'SABVR', 'SDQL', 'SDQR', 'SIADL', 'SIADR', 'SIAVL', 'SIAVR', 'SIBDL', 'SIBDR', 'SIBVL', 'SIBVR', 'SMBDL', 'SMBDR', 'SMBVL', 'SMBVR', 'SMDDL', 'SMDDR', 'SMDVL', 'SMDVR', 'URADL', 'URADR', 'URAVL', 'URAVR', 'URBL', 'URBR', 'URXL', 'URXR', 'URYDL', 'URYDR', 'URYVL', 'URYVR', 'VA1', 'VA10', 'VA11', 'VA12', 'VA2', 'VA3', 'VA4', 'VA5', 'VA6', 'VA7', 'VA8', 'VA9', 'VB1', 'VB10', 'VB11', 'VB2', 'VB3', 'VB4', 'VB5', 'VB6', 'VB7', 'VB8', 'VB9', 'VC1', 'VC2', 'VC3', 'VC4', 'VC5', 'VC6', 'VD1', 'VD10', 'VD11', 'VD12', 'VD13', 'VD2', 'VD3', 'VD4', 'VD5', 'VD6', 'VD7', 'VD8', 'VD9', 'pm1', 'pm4_UNSPECIFIED'] - Connection type - Generic_GJ: (309, 309), 1144 non-zero entries, sum of entries = 1928 [[0. 1. 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. 0. 0.] [0. 0. 0. ... 0. 0. 0.]] - Connection type - Generic_CS: (309, 309), 2386 non-zero entries, sum of entries = 7943 [[0. 1. 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.] [0. 0. 0. ... 0. 0. 0.]]
In [7]:
Copied!
from cect.ConnectomeView import NEURONS_VIEW as view
white_neurons = white_connectome_dataset.get_connectome_view(view)
synclass = "Chemical"
fig, _ = white_neurons.to_plotly_matrix_fig(synclass, view)
import plotly.io as pio
pio.renderers.default = 'notebook'
fig.show()
from cect.ConnectomeView import NEURONS_VIEW as view
white_neurons = white_connectome_dataset.get_connectome_view(view)
synclass = "Chemical"
fig, _ = white_neurons.to_plotly_matrix_fig(synclass, view)
import plotly.io as pio
pio.renderers.default = 'notebook'
fig.show()
cect >>> Opened the Excel file for Ripoll Sanchez et al: /Users/padraig/git/ConnectomeToolbox/cect/readers/../data/1-s2.0-S0896627323007560-mmc7.xlsx
3.2) Generate a graph of the escape response circuit with this dataset¶
In [8]:
Copied!
from cect.ConnectomeView import ESCAPE_VIEW as view
print(view.description)
white_escape_circuit = white_connectome_dataset.get_connectome_view(view)
fig = white_escape_circuit.to_plotly_graph_fig(synclass, view)
fig.show()
from cect.ConnectomeView import ESCAPE_VIEW as view
print(view.description)
white_escape_circuit = white_connectome_dataset.get_connectome_view(view)
fig = white_escape_circuit.to_plotly_graph_fig(synclass, view)
fig.show()
Escape Response Circuit from [Pirri & Alkema, 2013](https://pmc.ncbi.nlm.nih.gov/articles/PMC3437330/) cect >>> ============== cect >>> Generating: Chemical for Escape Response Circuit, ['Generic_CS', 'Acetylcholine', 'Acetylcholine_Tyramine', 'FMRFamide', 'GABA', 'Glutamate', 'Betaine', 'Serotonin_Acetylcholine', 'Serotonin_Glutamate', 'OtherChemicalNT'] Nodes to show: ['ALM', 'AVA', 'AVB', 'AVD', 'AVM', 'Body Musc', 'Head Musc', 'PLM', 'PVC', 'PVM', 'RIM', 'RMD', 'SMD', 'VA/DA', 'VB/DB'] (15), disconnected: []