Skip to content

Commit

Permalink
Updated comparison notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Jan 31, 2024
1 parent f7de589 commit bb91a43
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ arm64
/.ipynb_checkpoints
/c302/.ipynb_checkpoints
.ipynb_checkpoints
/c302/data/~$*.xlsx
8 changes: 5 additions & 3 deletions c302/SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# A simple script to read the values in CElegansNeuronTables.xls.

# This is on of a number of interchangeable "Readers" which can
# This is one of a number of interchangeable "Readers" which can
# be used to get connection data for c302

############################################################
Expand All @@ -20,11 +20,13 @@

from c302 import print_

READER_DESCRIPTION = """Data extracted from CElegansNeuronTables.xls for neuronal connectivity"""

def read_data(include_nonconnected_cells=False, neuron_connect=False):



# reading the NeuronConnect.xls file if neuron_connect = True
# reading the NeuronConnectFormatted.xls file if neuron_connect = True
if neuron_connect:
conns = []
cells = []
Expand Down Expand Up @@ -53,7 +55,7 @@ def read_data(include_nonconnected_cells=False, neuron_connect=False):
filename = "%sCElegansNeuronTables.xls"%spreadsheet_location
rb = open_workbook(filename)

print_("Opened Excel file..: " + filename)
print_("Opened Excel file: " + filename)

known_nonconnected_cells = ['CANL', 'CANR', 'VC6']

Expand Down
124 changes: 76 additions & 48 deletions examples/test/Comparison.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 47,
"id": "481d3c70-313a-4979-8475-d4a0089a8a0b",
"metadata": {
"tags": []
Expand Down Expand Up @@ -43,7 +43,7 @@
"from c302.NeuroMLUtilities import analyse_connections\n",
"\n",
"all_data = {}\n",
"all_data[\"Values\"] =[\"Num Cells\", \"Num muscles\", \"Num conns\", \"#N->Musc\"]\n",
"all_data[\"Values\"] =[\"Num Neurons\", \"Num Muscles\", \"Num N->N conns\", \"Num N with ->M\", \"Num N->M conns\", \"N neurotransmitters\", \"M neurotransmitters\"]\n",
"\n",
"readers = {\"SpreadsheetData\": \"c302.SpreadsheetDataReader\", \n",
" \"UpdSpreadsheetData\": \"c302.UpdatedSpreadsheetDataReader\",\n",
Expand All @@ -57,15 +57,51 @@
" exec(\"from %s import read_data, read_muscle_data\"%reader)\n",
"\n",
" cells, neuron_conns = read_data(include_nonconnected_cells=True)\n",
"\n",
" neuron_nts = {}\n",
" for c in neuron_conns:\n",
" nt = c.synclass\n",
" if len(nt)==0: nt='**MISSING**'\n",
"\n",
" if not nt in neuron_nts:\n",
" neuron_nts[nt] = 0\n",
" \n",
" neuron_nts[nt] +=1\n",
" \n",
" nts_info = ''\n",
" for nts in sorted(neuron_nts.keys()):\n",
" nts_info+='%s (%i)<br/>'%(nts, neuron_nts[nts])\n",
"\n",
" neurons2muscles, muscles, muscle_conns = read_muscle_data()\n",
"\n",
" all_data[name] =[len(cells),len(muscles), len(neuron_conns), len(neurons2muscles)]\n",
" muscle_nts = {}\n",
" for c in muscle_conns:\n",
" nt = c.synclass\n",
" if len(nt)==0: nt='**MISSING**'\n",
"\n",
" if not nt in muscle_nts:\n",
" muscle_nts[nt] = 0\n",
" \n",
" muscle_nts[nt] +=1\n",
" \n",
" m_nts_info = ''\n",
" for nts in sorted(muscle_nts):\n",
" m_nts_info+='%s (%i)<br/>'%(nts, muscle_nts[nts])\n",
"\n",
"\n",
" all_data[name] =[len(cells),\n",
" len(muscles), \n",
" len(neuron_conns), \n",
" len(neurons2muscles), \n",
" len(muscle_conns),\n",
" nts_info,\n",
" m_nts_info]\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 48,
"id": "2308051a-0a24-44db-a481-fc0d0f2af4fb",
"metadata": {
"tags": []
Expand All @@ -74,103 +110,95 @@
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Values</th>\n",
" <th>SpreadsheetData</th>\n",
" <th>UpdSpreadsheetData</th>\n",
" <th>UpdSpreadsheetData2</th>\n",
" <th>OpenWorm</th>\n",
" <th>WormNeuroAtlas</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Values</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Num Cells</th>\n",
" <td>Num Neurons</td>\n",
" <td>302</td>\n",
" <td>302</td>\n",
" <td>302</td>\n",
" <td>302</td>\n",
" <td>300</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Num muscles</th>\n",
" <td>Num Muscles</td>\n",
" <td>97</td>\n",
" <td>95</td>\n",
" <td>95</td>\n",
" <td>95</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Num conns</th>\n",
" <td>Num N->N conns</td>\n",
" <td>3363</td>\n",
" <td>5806</td>\n",
" <td>5821</td>\n",
" <td>5805</td>\n",
" <td>1650</td>\n",
" </tr>\n",
" <tr>\n",
" <th>#N-&gt;Musc</th>\n",
" <td>Num N with ->M</td>\n",
" <td>127</td>\n",
" <td>254</td>\n",
" <td>254</td>\n",
" <td>159</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <td>Num N->M conns</td>\n",
" <td>564</td>\n",
" <td>1118</td>\n",
" <td>1118</td>\n",
" <td>926</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <td>N neurotransmitters</td>\n",
" <td>Acetylcholine (394)<br/>Acetylcholine_Tyramine (29)<br/>Dopamine (120)<br/>FMRFamide (247)<br/>GABA (200)<br/>Generic_GJ (1084)<br/>Glutamate (962)<br/>Octapamine (20)<br/>Serotonin (178)<br/>Serotonin_Acetylcholine (104)<br/>Serotonin_Glutamate (25)<br/></td>\n",
" <td>Acetylcholine (3581)<br/>GABA (57)<br/>Generic_GJ (2168)<br/></td>\n",
" <td>Acetylcholine (3596)<br/>GABA (57)<br/>Generic_GJ (2168)<br/></td>\n",
" <td>Acetylcholine (2008)<br/>Acetylcholine_GJ (222)<br/>Acetylcholine_Tyramine (29)<br/>Acetylcholine_Tyramine_GJ (13)<br/>Dopamine (98)<br/>Dopamine_GJ (13)<br/>FMRFamide (170)<br/>FMRFamide_GJ (90)<br/>FRMFemide (45)<br/>FRMFemide_GJ (33)<br/>GABA (182)<br/>GABA_GJ (76)<br/>Generic_GJ (1356)<br/>Glutamate (824)<br/>Glutamate_GJ (324)<br/>Octapamine (19)<br/>Octapamine_GJ (4)<br/>Serotonin (163)<br/>Serotonin_Acetylcholine (91)<br/>Serotonin_Acetylcholine_GJ (13)<br/>Serotonin_GJ (20)<br/>Serotonin_Glutamate (11)<br/>Serotonin_Glutamate_GJ (1)<br/></td>\n",
" <td>Generic_GJ (1650)<br/></td>\n",
" </tr>\n",
" <tr>\n",
" <td>M neurotransmitters</td>\n",
" <td>**MISSING** (2)<br/>Acetylcholine (377)<br/>Acetylcholineplus_Tyramine (6)<br/>Dopamine (1)<br/>FMRFamide (3)<br/>FRMFemide (5)<br/>GABA (126)<br/>Glutamate (35)<br/>Serotonin (1)<br/>Serotoninplus_Acetylcholine (8)<br/></td>\n",
" <td>Acetylcholine (808)<br/>GABA (116)<br/>Generic_GJ (194)<br/></td>\n",
" <td>Acetylcholine (808)<br/>GABA (116)<br/>Generic_GJ (194)<br/></td>\n",
" <td>Acetylcholine (924)<br/>Generic_GJ (2)<br/></td>\n",
" <td></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
"</table>"
],
"text/plain": [
" SpreadsheetData UpdSpreadsheetData UpdSpreadsheetData2 \\\n",
"Values \n",
"Num Cells 302 302 302 \n",
"Num muscles 97 95 95 \n",
"Num conns 3363 5806 5821 \n",
"#N->Musc 127 254 254 \n",
"\n",
" OpenWorm WormNeuroAtlas \n",
"Values \n",
"Num Cells 302 300 \n",
"Num muscles 95 0 \n",
"Num conns 5805 1650 \n",
"#N->Musc 159 0 "
"<IPython.core.display.HTML object>"
]
},
"execution_count": 17,
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"from IPython.display import HTML\n",
"\n",
"df_all = pd.DataFrame(all_data)\n",
"df_all.set_index(\"Values\")\n"
"df_all.set_index(\"Values\")\n",
"\n",
"h = HTML(df_all.to_html(escape=False, index=False));h"
]
},
{
Expand Down

0 comments on commit bb91a43

Please sign in to comment.