Skip to content

Commit

Permalink
Merge pull request #31 from pgleeson/main
Browse files Browse the repository at this point in the history
Much improved cell pages & add Britten conatactome data
  • Loading branch information
pgleeson authored Nov 15, 2024
2 parents 6111971 + 20a9945 commit 209940a
Show file tree
Hide file tree
Showing 398 changed files with 1,189 additions and 151,275 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -669,3 +669,6 @@ __pycache__
/docs/vspR.md
/docs/vsrL.md
/docs/vsrR.md
/docs/Brittin*_data*.md
/docs/assets/Brittin2021*
/docs/*_Brittin2021_data*.md
91 changes: 91 additions & 0 deletions cect/BrittinDataReader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# -*- coding: utf-8 -*-

############################################################

# A script to read the values from Brittin et al 2021

############################################################


from cect.ConnectomeReader import ConnectionInfo
from cect.ConnectomeReader import analyse_connections

from cect.ConnectomeDataset import ConnectomeDataset
from cect.ConnectomeDataset import get_dataset_source_on_github

import os
from openpyxl import load_workbook

from cect import print_


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

filename = "%s41586_2021_3284_MOESM5_ESM.xlsx" % spreadsheet_location

READER_DESCRIPTION = (
"""Data extracted from %s for membrane contact information."""
% get_dataset_source_on_github(filename.split("/")[-1])
)


class BrittinDataReader(ConnectomeDataset):
"""Reader for datasets from [Brittin et al. 2021](../../Brittin_2021.md)"""

verbose = False

def __init__(self, reference_graph):
ConnectomeDataset.__init__(self)
self.reference_graph = reference_graph

cells, neuron_conns = self.read_data()
for conn in neuron_conns:
self.add_connection_info(conn)

def read_data(self):
cells = []
conns = []

wb = load_workbook(filename)

sheet = wb.get_sheet_by_name(self.reference_graph)

print_("Opened sheet %s in Excel file: %s" % (sheet, filename))
print(dir(sheet))

for row in sheet.rows:
print(row[0].value)
if "cell_1" not in row[0].value:
delta = int(row[3].value)
if delta == 4:
pre = row[0].value
post = row[1].value
num = float(row[2].value)
syntype = "Contact"
synclass = "%s%s" % (self.reference_graph, row[3].value)
synclass = "Contact"
ci = ConnectionInfo(pre, post, num, syntype, synclass)
print("Adding %s" % ci)
conns.append(ci)

if pre not in cells:
cells.append(pre)
if post not in cells:
cells.append(post)

return cells, conns


def get_instance():
return BrittinDataReader("M")


my_instance = get_instance()

if __name__ == "__main__":
wdr = get_instance()

cells, neuron_conns = wdr.read_data()
neurons2muscles, muscles, muscle_conns = wdr.read_muscle_data()

analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_conns)
83 changes: 55 additions & 28 deletions cect/CellInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,14 @@ def generate_cell_info_pages(connectomes):

cell_info = '---\ntitle: "Cell: %s"\n---\n\n' % cell

cell_ref = (
cell
if not ((cell.startswith("CA") or cell.startswith("CP")) and cell[2] == "0")
else "%s%s" % (cell[:2], cell[-1])
) # CA04 -> CA4 etc.

# TODO: investigate DX1, DX2, DX3, EF1, EF2, EF3
if is_any_neuron(cell) and "DX" not in cell and "EF" not in cell:
cell_ref = (
cell
if not (
(cell.startswith("CA") or cell.startswith("CP")) and cell[2] == "0"
)
else "%s%s" % (cell[:2], cell[-1])
) # CA04 -> CA4 etc.
acronym = cell_data[cell_ref][0]
lineage = cell_data[cell_ref][1]
desc = cell_data[cell_ref][2]
Expand Down Expand Up @@ -186,15 +185,25 @@ def generate_cell_info_pages(connectomes):
cell,
get_cell_notes(cell),
cell_data[cell_ref][0],
cell_data[cell_ref][1],
cell_data[cell_ref][2],
lineage,
desc,
]
)

else:
cell_info += '!!! question "**%s: %s**"\n\n' % (cell, get_cell_notes(cell))
cc = cell_classification[cell]
all_cell_info.append(
[cell, get_cell_notes(cell), cell_data[cell_ref][0], '""', '""', '""']
[
cell,
get_cell_notes(cell),
cell_data[cell_ref][0]
if cell_ref in cell_data
else "- To be added... - ",
get_cell_notes(cell),
"- To be added... - ",
cc[0].upper() + cc[1:],
]
)

cell_info += (
Expand Down Expand Up @@ -401,33 +410,51 @@ def generate_cell_info_pages(connectomes):


if __name__ == "__main__":
from cect.White_whole import get_instance
import sys

if "-i" in sys.argv:
from cect.Cells import ALL_PREFERRED_NEURON_NAMES
from cect.Cells import PREFERRED_MUSCLE_NAMES
from cect.Cells import ALL_NON_NEURON_MUSCLE_CELLS

print(" - 'Individual neurons': ")
for cell in sorted(ALL_PREFERRED_NEURON_NAMES):
print(f" - '{cell}': '{cell}.md'")
print(" - 'Individual muscles': ")
for cell in sorted(PREFERRED_MUSCLE_NAMES, key=lambda v: v.upper()):
print(f" - '{cell}': '{cell}.md'")
print(" - 'Other cells': ")
for cell in sorted(ALL_NON_NEURON_MUSCLE_CELLS, key=lambda v: v.upper()):
print(f" - '{cell}': '{cell}.md'")

cds_white = get_instance()
else:
from cect.White_whole import get_instance

from cect.WitvlietDataReader8 import get_instance
cds_white = get_instance()

cds_w8 = get_instance()
from cect.WitvlietDataReader8 import get_instance

connectomes = {"White_whole": cds_white, "Witvliet8": cds_w8}
cds_w8 = get_instance()

from cect.Cook2019HermReader import get_instance
connectomes = {"White_whole": cds_white, "Witvliet8": cds_w8}

connectomes["Cook2019Herm"] = get_instance()
from cect.Cook2019HermReader import get_instance

from cect.Cook2019MaleReader import get_instance
connectomes["Cook2019Herm"] = get_instance()

connectomes["Cook2019Male"] = get_instance()
from cect.Cook2019MaleReader import get_instance

"""
from cect.WormNeuroAtlasMAReader import get_instance
connectomes['Bentley2016_MA'] = get_instance()
connectomes["Cook2019Male"] = get_instance()

"""
from cect.WormNeuroAtlasMAReader import get_instance
connectomes['Bentley2016_MA'] = get_instance()
from cect.WormNeuroAtlasFuncReader import get_instance
connectomes['Randi2023'] = get_instance()
from cect.WormNeuroAtlasFuncReader import get_instance
connectomes['Randi2023'] = get_instance()
from cect.RipollSanchezShortRangeReader import get_instance
connectomes['RipollSanchezShortRange'] = get_instance() """
from cect.RipollSanchezShortRangeReader import get_instance
connectomes['RipollSanchezShortRange'] = get_instance() """

# load_individual_neuron_info()
generate_cell_info_pages(connectomes)
# load_individual_neuron_info()
generate_cell_info_pages(connectomes)
32 changes: 22 additions & 10 deletions cect/Cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,15 @@ def get_cell_notes(cell):

MOTORNEURONS_COOK = MOTORNEURONS_NONPHARYNGEAL_COOK + PHARYNGEAL_MOTORNEURONS

PREFERRED_NEURON_NAMES_COOK = (
PREFERRED_HERM_NEURON_NAMES_COOK = (
INTERNEURONS_COOK
+ SENSORY_NEURONS_COOK
+ MOTORNEURONS_COOK
+ PHARYNGEAL_POLYMODAL_NEURONS
+ UNKNOWN_FUNCTION_NEURONS
)

ALL_NEURON_NAMES_COOK = PREFERRED_HERM_NEURON_NAMES_COOK + MALE_SPECIFIC_NEURONS

COOK_GROUPING_1 = {
"Pharyngeal neurons": PHARYNGEAL_NEURONS,
Expand Down Expand Up @@ -991,13 +992,13 @@ def get_cell_notes(cell):
]

for n in PREFERRED_HERM_NEURON_NAMES:
assert n in PREFERRED_NEURON_NAMES_COOK
assert n in PREFERRED_HERM_NEURON_NAMES_COOK

for n in PREFERRED_NEURON_NAMES_COOK:
for n in PREFERRED_HERM_NEURON_NAMES_COOK:
assert n in PREFERRED_HERM_NEURON_NAMES

assert len(PREFERRED_NEURON_NAMES_COOK) == len(PREFERRED_HERM_NEURON_NAMES)
assert len(PREFERRED_NEURON_NAMES_COOK) == 302
assert len(PREFERRED_HERM_NEURON_NAMES_COOK) == len(PREFERRED_HERM_NEURON_NAMES)
assert len(PREFERRED_HERM_NEURON_NAMES_COOK) == 302

BODY_WALL_MUSCLE_NAMES = [
"MDL01",
Expand Down Expand Up @@ -1447,9 +1448,8 @@ def get_cell_notes(cell):
cell_notes["int"] = "intestine"


KNOWN_OTHER_CELLS_COOK_19 = (
[]
+ GLIAL_CELLS
KNOWN_HERM_NON_NEURON_MUSCLE_CELLS_COOK_19 = (
GLIAL_CELLS
+ PHARYNGEAL_MARGINAL_CELLS
+ PHARYNGEAL_EPITHELIUM
+ PHARYNGEAL_GLIAL_CELL
Expand All @@ -1461,15 +1461,24 @@ def get_cell_notes(cell):
+ INTESTINE
)

COOK_GROUPING_1["Other cells"] = list(KNOWN_OTHER_CELLS_COOK_19)
COOK_GROUPING_1["Other cells"] = list(KNOWN_HERM_NON_NEURON_MUSCLE_CELLS_COOK_19)

"""
KNOWN_OTHER_CELLS = KNOWN_OTHER_CELLS_COOK_19
KNOWN_OTHER_CELLS += (
MALE_SPECIFIC_NEURONS
+ MALE_RAY_STRUCTURAL_CELLS
+ PROCTODEUM_CELL_MALE
+ GONAD_CELL_MALE
)"""

ALL_NON_NEURON_MUSCLE_CELLS = (
KNOWN_HERM_NON_NEURON_MUSCLE_CELLS_COOK_19
+ MALE_RAY_STRUCTURAL_CELLS
+ PROCTODEUM_CELL_MALE
+ GONAD_CELL_MALE
)

COOK_GROUPING_1["Male specific neurons"] = MALE_SPECIFIC_NEURONS
Expand All @@ -1480,8 +1489,11 @@ def get_cell_notes(cell):
MALE_RAY_STRUCTURAL_CELLS + PROCTODEUM_CELL_MALE + GONAD_CELL_MALE
)

ALL_PREFERRED_NEURON_NAMES = PREFERRED_HERM_NEURON_NAMES + MALE_SPECIFIC_NEURONS


ALL_PREFERRED_CELL_NAMES = (
PREFERRED_HERM_NEURON_NAMES + PREFERRED_MUSCLE_NAMES + KNOWN_OTHER_CELLS
ALL_PREFERRED_NEURON_NAMES + PREFERRED_MUSCLE_NAMES + ALL_NON_NEURON_MUSCLE_CELLS
)


Expand Down
3 changes: 3 additions & 0 deletions cect/Comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"Cook2019Herm": "Cook2019Herm_data",
"Cook2019Male": "Cook2019Male_data",
"Cook2020": "Cook2020_data",
"Brittin2021": "Brittin2021_data",
"Witvliet1": "Witvliet1_data",
"Witvliet2": "Witvliet2_data",
"Witvliet3": "Witvliet3_data",
Expand Down Expand Up @@ -169,6 +170,8 @@ def generate_comparison_page(quick: bool, color_table=True):

readers["Cook2020"] = ["cect.Cook2020DataReader", "Cook_2020"]

readers["Brittin2021"] = ["cect.BrittinDataReader", "Brittin_2021"]

if not quick:
readers["Witvliet1"] = ["cect.WitvlietDataReader1", "Witvliet_2021"]
readers["Witvliet2"] = ["cect.WitvlietDataReader2", "Witvliet_2021"]
Expand Down
Loading

0 comments on commit 209940a

Please sign in to comment.