Skip to content

Commit

Permalink
VarshneyDataReader
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinthanvickneswaran committed Feb 15, 2024
1 parent d5a8728 commit 3c59f01
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 54 deletions.
2 changes: 1 addition & 1 deletion c302/SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

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

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



Expand Down
78 changes: 39 additions & 39 deletions c302/VarshneyDataReader.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
from c302.NeuroMLUtilities import ConnectionInfo
from c302.NeuroMLUtilities import analyse_connections
from openpyxl import load_workbook

from xlrd import open_workbook
import os

spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/"

from c302 import print_

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

def read_data(include_nonconnected_cells=False, neuron_connect=True):
READER_DESCRIPTION = """Data extracted from NeuronConnectFormatted.xlsx for neuronal connectivity"""


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

# reading the NeuronConnectFormatted.xls file if neuron_connect = True
if neuron_connect:
conns = []
cells = []
filename = "%sNeuronConnectFormatted.xls"%spreadsheet_location
rb = open_workbook(filename)
print_("Opened the Excel file: " + filename)

for row in range(1,rb.sheet_by_index(0).nrows):
pre = str(rb.sheet_by_index(0).cell(row,0).value)
post = str(rb.sheet_by_index(0).cell(row,1).value)
syntype = rb.sheet_by_index(0).cell(row,2).value
num = int(rb.sheet_by_index(0).cell(row,3).value)
filename = "%sNeuronConnectFormatted.xlsx"%spreadsheet_location
wb = load_workbook(filename)
sheet = wb.worksheets[0]
print_("Opened the Excel file: " + filename)

for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row
pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse'

conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in cells:
cells.append(pre)
cells.append(pre)
if post not in cells:
cells.append(post)

return cells, conns

else:
conns = []
cells = []
filename = "%sCElegansNeuronTables.xls"%spreadsheet_location
rb = open_workbook(filename)
filename = "%sNeuronConnectFormatted.xlsx"%spreadsheet_location
wb = load_workbook(filename)
sheet = wb.worksheets[0]

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

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

for row in sheet.iter_rows(min_row=2, values_only=True):
pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse'


for row in range(1,rb.sheet_by_index(0).nrows):
pre = str(rb.sheet_by_index(0).cell(row,0).value)
post = str(rb.sheet_by_index(0).cell(row,1).value)
syntype = rb.sheet_by_index(0).cell(row,2).value
num = int(rb.sheet_by_index(0).cell(row,3).value)
synclass = rb.sheet_by_index(0).cell(row,4).value

conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in cells:
cells.append(pre)
cells.append(pre)
if post not in cells:
cells.append(post)

if include_nonconnected_cells:
for c in known_nonconnected_cells: cells.append(c)
if include_nonconnected_cells:
for c in known_nonconnected_cells: cells.append(c)

return cells, conns

Expand All @@ -72,24 +72,24 @@ def read_muscle_data():
neurons = []
muscles = []

filename = "%sNeuronConnectFormatted.xls"%spreadsheet_location
rb = open_workbook(filename)
filename = "%sNeuronConnectFormatted.xlsx"%spreadsheet_location
wb = load_workbook(filename)
sheet = wb.worksheets[0]

print_("Opened Excel file: "+ filename)

sheet = rb.sheet_by_index(0)
for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row
pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse'

for row in range(1,sheet.nrows):
pre = str(sheet.cell(row,0).value)
post = str(sheet.cell(row,1).value)
num = int(sheet.cell(row,3).value)
syntype = 'Send'
synclass = sheet.cell(row,2).value.replace(',', 'plus').replace(' ', '_')

conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in neurons:
neurons.append(pre)
if post not in muscles:
if syntype == "NMJ":
muscles.append(post)


Expand Down
9 changes: 8 additions & 1 deletion c302/W_SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

from openpyxl import load_workbook
import os
from c302 import print_


spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/"


from c302 import print_





class WitvlietDataReader1:
Expand Down Expand Up @@ -83,6 +87,9 @@ def read_muscle_data():
print_("Opened Excel file: "+ filename)

for row in sheet.iter_rows(min_row=2, values_only=True):
if not (is_neuron(pre) or is_body_wall_muscle(pre)) or not is_body_wall_muscle(post):
continue

pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
Expand Down
42 changes: 29 additions & 13 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": 23,
"execution_count": 1,
"id": "481d3c70-313a-4979-8475-d4a0089a8a0b",
"metadata": {
"tags": []
Expand Down Expand Up @@ -33,19 +33,35 @@
"c302 >>> Total connections found 926 \n",
"\n",
"****** Importing dataset WormNeuroAtlas using c302.WormNeuroAtlasReader ******\n",
"*This version of the NeuroAtlas does not include the CAN neurons. This will be fixed soon.\n",
"*In loading the anatomical connectome, the following conventions are used to allow for its comparison with the other datasets: AWCL->AWCOFF and AWCR->AWCON\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\wormneuroatlas\\WormBase.py:52: UserWarning: Wormbase.org updated its database to a new version (WS291). The version of Worm Neuro Atlas that you are using has been built for the wormbase database version WS287. To ensure reproducible results, upgrade Worm Neuro Atlas with `python -m pip install --upgrade wormneuroatlas` If this warning persists after upgrading, let the developers know by opening an issue here: https://github.com/francescorandi/wormneuroatlas/issues. NOTE: You can still use Worm Neuro Atlas in the meantime. The metadata accessible via wormneuroatlas.WormBase.get_metadata() and wormneuroatlas.NeuroAtlas.get_metadata() contain the version of wormbase that you are currently using, so make sure you save the metadata alongside your results. \n",
" warnings.warn(w)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"c302 >>> Initialising WormNeuroAtlasReader\n",
"\n",
"****** Importing dataset Varshney using c302.VarshneyDataReader ******\n",
"c302 >>> Opened the Excel file: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/NeuronConnectFormatted.xls\n",
"c302 >>> Opened Excel file: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/NeuronConnectFormatted.xls\n",
"\n",
"****** Importing dataset Witvliet(1) using c302.W_SpreadsheetDataReader ******\n",
"c302 >>> Opened Excel file..: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/witvliet_2020_1.xlsx\n",
"c302 >>> Opened Excel file: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/witvliet_2020_1.xlsx\n",
"c302 >>> Opened Excel file..: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/witvliet_2020_7.xlsx\n",
"c302 >>> Opened Excel file: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/witvliet_2020_7.xlsx\n",
"\n",
"****** Importing dataset Witvliet(2) using c302.W_SpreadsheetDataReader ******\n",
"c302 >>> Opened Excel file..: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/witvliet_2020_2.xlsx\n",
"c302 >>> Opened Excel file: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/witvliet_2020_2.xlsx\n"
"c302 >>> Opened Excel file..: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/witvliet_2020_8.xlsx\n",
"c302 >>> Opened Excel file: c:\\Users\\vyasi\\anaconda3\\envs\\ProWorm\\lib\\site-packages\\c302/data/witvliet_2020_8.xlsx\n"
]
}
],
Expand Down Expand Up @@ -140,7 +156,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 2,
"id": "2308051a-0a24-44db-a481-fc0d0f2af4fb",
"metadata": {
"tags": []
Expand Down Expand Up @@ -172,8 +188,8 @@
" <td>302</td>\n",
" <td>300</td>\n",
" <td>281</td>\n",
" <td>190</td>\n",
" <td>197</td>\n",
" <td>225</td>\n",
" <td>222</td>\n",
" </tr>\n",
" <tr>\n",
" <td>Num Muscles</td>\n",
Expand All @@ -194,8 +210,8 @@
" <td>5805</td>\n",
" <td>1650</td>\n",
" <td>6417</td>\n",
" <td>858</td>\n",
" <td>1110</td>\n",
" <td>2493</td>\n",
" <td>2496</td>\n",
" </tr>\n",
" <tr>\n",
" <td>Num N with ->M</td>\n",
Expand Down Expand Up @@ -227,8 +243,8 @@
" <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",
" <td>Chemical_Synapse (5386)<br/>Generic_GJ (1031)<br/></td>\n",
" <td>Chemical_Synapse (775)<br/>Generic_GJ (83)<br/></td>\n",
" <td>Chemical_Synapse (986)<br/>Generic_GJ (124)<br/></td>\n",
" <td>Chemical_Synapse (2202)<br/>Generic_GJ (291)<br/></td>\n",
" <td>Chemical_Synapse (2186)<br/>Generic_GJ (310)<br/></td>\n",
" </tr>\n",
" <tr>\n",
" <td>M neurotransmitters</td>\n",
Expand All @@ -248,7 +264,7 @@
"<IPython.core.display.HTML object>"
]
},
"execution_count": 24,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
Expand Down

0 comments on commit 3c59f01

Please sign in to comment.