Skip to content

Commit

Permalink
Merge pull request #24 from pgleeson/main
Browse files Browse the repository at this point in the history
Adding Escape response circuit
  • Loading branch information
pgleeson authored Oct 18, 2024
2 parents 05c50d5 + 8b1cbf1 commit b345637
Show file tree
Hide file tree
Showing 509 changed files with 39,869 additions and 16,588 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ __pycache__
/docs/assets/WormNeuro*
/docs/.DS_Store
/docs/assets/RipollSanchez*
/docs/Escape_*data_*.md
/docs/Escape_*_data.md
73 changes: 46 additions & 27 deletions cect/Cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,10 @@


COOK_GROUPING_1 = {
"Interneurons": INTERNEURONS_COOK,
"Sensory neurons": SENSORY_NEURONS_COOK,
"Motorneurons": MOTORNEURONS_COOK,
"Pharyngeal polymodal neurons": PHARYNGEAL_POLYMODAL_NEURONS,
"Pharyngeal neurons": PHARYNGEAL_NEURONS,
"Sensory neurons": SENSORY_NEURONS_NONPHARYNGEAL_COOK,
"Interneurons": INTERNEURONS_NONPHARYNGEAL_COOK,
"Motorneurons": MOTORNEURONS_NONPHARYNGEAL_COOK,
"Unknown function neurons": UNKNOWN_FUNCTION_NEURONS,
}

Expand Down Expand Up @@ -1290,12 +1290,21 @@
cell_notes[cell] = "male ray structural cell"


INTESTINAL_MUSCLES = [
"mu_intL",
"mu_intR",
]

for cell in INTESTINAL_MUSCLES:
cell_notes[cell] = "intestinal muscles"

PREFERRED_MUSCLE_NAMES = (
BODY_WALL_MUSCLE_NAMES
+ PHARYNGEAL_MUSCLE_NAMES
+ VULVAL_MUSCLE_NAMES
+ ANAL_SPHINCTER_MUSCLES
+ MALE_SPECIFIC_MUSCLES
+ INTESTINAL_MUSCLES
+ UNSPECIFIED_BODY_WALL_MUSCLES
)

Expand All @@ -1305,7 +1314,6 @@
PHARYNGEAL_MUSCLE_NAMES
+ VULVAL_MUSCLE_NAMES
+ ANAL_SPHINCTER_MUSCLES
+ MALE_SPECIFIC_MUSCLES
+ UNSPECIFIED_BODY_WALL_MUSCLES
)

Expand Down Expand Up @@ -1414,15 +1422,6 @@
]
cell_notes["int"] = "intestine"

INTESTINAL_MUSCLES = [
"mu_intL",
"mu_intR",
]


for cell in INTESTINAL_MUSCLES:
cell_notes[cell] = "intestinal muscles"


KNOWN_OTHER_CELLS_COOK_19 = (
[]
Expand All @@ -1436,10 +1435,9 @@
+ HEAD_MESODERMAL_CELL
+ HYPODERMIS
+ INTESTINE
+ INTESTINAL_MUSCLES
)

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

KNOWN_OTHER_CELLS = KNOWN_OTHER_CELLS_COOK_19

Expand All @@ -1448,6 +1446,9 @@
)

COOK_GROUPING_1["Male specific neurons"] = MALE_SPECIFIC_NEURONS

COOK_GROUPING_1["Male specific muscles "] = MALE_SPECIFIC_MUSCLES

COOK_GROUPING_1["Male other cells"] = (
MALE_RAY_STRUCTURAL_CELLS + PROCTODEUM_CELL + GONAD_CELL
)
Expand Down Expand Up @@ -1487,6 +1488,9 @@ def get_SIM_class(cell):
elif cell in INTERNEURONS_COOK:
return "Interneuron"
else:
if len(cell) == 3:
if get_SIM_class("%sL" % cell) == get_SIM_class("%sR" % cell):
return get_SIM_class("%sL" % cell)
return "Other"


Expand Down Expand Up @@ -1576,7 +1580,7 @@ def convert_to_preferred_muscle_name(muscle):
elif muscle == "pm7d":
return "pm7D"
else:
if is_muscle(muscle):
if is_known_muscle(muscle):
return muscle
else:
return muscle + "???"
Expand Down Expand Up @@ -1625,13 +1629,19 @@ def get_body_wall_muscle_prefixes():
return ["BWM-D", "BWM-V", "LegacyBodyWallMuscles", "vBWM", "dBWM"]


def is_muscle(cell):
def is_potential_muscle(cell):
if cell in PREFERRED_MUSCLE_NAMES:
return True
known_muscle_prefixes = get_all_muscle_prefixes()
return cell.startswith(tuple(known_muscle_prefixes))


def is_known_muscle(cell):
if cell in PREFERRED_MUSCLE_NAMES:
return True
return False


def is_potential_body_wall_muscle(cell):
known_muscle_prefixes = get_body_wall_muscle_prefixes()
return cell.startswith(tuple(known_muscle_prefixes))
Expand Down Expand Up @@ -1821,7 +1831,7 @@ def get_cell_internal_link(cell_name, html=False, text=None, use_color=False):

return '<a href="%s" title="%s">%s</a>' % (
url,
get_short_description(cell_name),
(cell_name + " (%s)" if text else "%s") % get_short_description(cell_name),
link_text,
)
else:
Expand Down Expand Up @@ -1912,6 +1922,7 @@ def _generate_cell_table(cell_type, cells):
fig_md = ""

verbose = False
some_cells = False

for syn_summary in syn_summaries:
fig = go.Figure()
Expand Down Expand Up @@ -1955,6 +1966,7 @@ def _generate_cell_table(cell_type, cells):
line=dict(dash=dash),
)
nonempty_fig_present = True
some_cells = True

if nonempty_fig_present:
asset_filename = "assets/%s_%s_hist.json" % (
Expand Down Expand Up @@ -1997,7 +2009,14 @@ def _generate_cell_table(cell_type, cells):

table_md = df_all.to_markdown()

return "%s\n%s\n\n" % (fig_md, table_md)
title = cell_type[0].upper() + cell_type[1:]
title = ("%s" if some_cells else "<i>%s</i>") % title

title_md = "#### ![#{0}](https://via.placeholder.com/15/{0}/{0}.png) {1}\n".format(
color, title
)

return "%s\n%s\n%s\n\n" % (title_md, fig_md, table_md)


if __name__ == "__main__":
Expand All @@ -2010,9 +2029,9 @@ def _generate_cell_table(cell_type, cells):
filename = "docs/Cells.md"

with open(filename, "w") as f:
for sex in WA_COLORS:
f.write("---\ntitle: <C. elegans> cells\n---\n\n")
f.write("---\ntitle: <i>C. elegans</i> cells\n---\n\n")

for sex in WA_COLORS:
f.write("\n## %s\n" % sex)

for cell_class in WA_COLORS[sex]:
Expand All @@ -2021,15 +2040,15 @@ def _generate_cell_table(cell_type, cells):
for cell_type in WA_COLORS[sex][cell_class]:
if "General code" not in cell_type:
color = WA_COLORS[sex][cell_class][cell_type][1:]
f.write(
"#### ![#{0}](https://via.placeholder.com/15/{0}/{0}.png) {1}\n".format(
color, cell_type[0].upper() + cell_type[1:]
)
)

if cell_type == "body wall muscle":
f.write(
_generate_cell_table(cell_type, BODY_WALL_MUSCLE_NAMES)
)
elif cell_type == "vulval muscle":
f.write(
_generate_cell_table(cell_type, VULVAL_MUSCLE_NAMES)
)
elif cell_type == "interneuron":
f.write(
_generate_cell_table(
Expand Down
96 changes: 72 additions & 24 deletions cect/Comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"Witvliet8": "Witvliet8_data",
"WormNeuroAtlas": "WormNeuroAtlas_data",
"Randi2023": "Randi2023_data",
"RipollSanchez": "RipollSanchez_data",
"RipollSanchezShortRange": "RipollSanchezShortRange_data",
"RipollSanchezMidRange": "RipollSanchezMidRange_data",
"RipollSanchezLongRange": "RipollSanchezLongRange_data",
"Test": "Test_data",
"SSData": "SSData_data",
"UpdSSData": "UpdSSData_data",
Expand Down Expand Up @@ -149,39 +151,55 @@ def generate_comparison_page(quick: bool, color_table=True):
readers = {}

if not quick:
readers["SSData"] = ["cect.SpreadsheetDataReader", None]
readers["UpdSSData"] = ["cect.UpdatedSpreadsheetDataReader", None]
readers["UpdSSData2"] = ["cect.UpdatedSpreadsheetDataReader2", None]
readers["White_A"] = ["cect.White_A", "White_1986"]
readers["White_L4"] = ["cect.White_L4", "White_1986"]

readers["Varshney"] = ["cect.VarshneyDataReader", "Varshney_2011"]
readers["White_whole"] = ["cect.White_whole", "White_1986"]
readers["Test"] = ["cect.TestDataReader", None]
readers["Cook2020"] = ["cect.Cook2020DataReader", "Cook_2020"]
readers["Witvliet1"] = ["cect.WitvlietDataReader1", "Witvliet_2021"]
readers["Varshney"] = ["cect.VarshneyDataReader", "Varshney_2011"]

if not quick:
readers["RipollSanchez"] = [
"cect.RipollSanchezDataReader",
"RipollSanchez_2023",
]
readers["Bentley2016_MA"] = ["cect.WormNeuroAtlasMAReader", "Bentley_2016"]
readers["Bentley2016_PEP"] = ["cect.WormNeuroAtlasPepReader", "Bentley_2016"]
readers["Witvliet1"] = ["cect.WitvlietDataReader1", "Witvliet_2021"]
readers["Witvliet2"] = ["cect.WitvlietDataReader2", "Witvliet_2021"]
readers["Witvliet3"] = ["cect.WitvlietDataReader3", "Witvliet_2021"]
readers["Witvliet4"] = ["cect.WitvlietDataReader4", "Witvliet_2021"]
readers["Witvliet5"] = ["cect.WitvlietDataReader5", "Witvliet_2021"]
readers["Witvliet6"] = ["cect.WitvlietDataReader6", "Witvliet_2021"]
readers["Witvliet7"] = ["cect.WitvlietDataReader7", "Witvliet_2021"]
readers["Witvliet8"] = ["cect.WitvlietDataReader8", "Witvliet_2021"]
readers["White_A"] = ["cect.White_A", "White_1986"]
readers["White_L4"] = ["cect.White_L4", "White_1986"]
readers["Cook2019Herm"] = ["cect.Cook2019HermReader", "Cook_2019"]

readers["Cook2019Herm"] = ["cect.Cook2019HermReader", "Cook_2019"]

if not quick:
readers["Cook2019Male"] = ["cect.Cook2019MaleReader", "Cook_2019"]

readers["Cook2020"] = ["cect.Cook2020DataReader", "Cook_2020"]
readers["WormNeuroAtlas"] = ["cect.WormNeuroAtlasReader", "Randi_2023"]
readers["Randi2023"] = ["cect.WormNeuroAtlasFuncReader", "Randi_2023"]

readers["RipollSanchezShortRange"] = [
"cect.RipollSanchezShortRangeReader",
"RipollSanchez_2023",
]
readers["RipollSanchezMidRange"] = [
"cect.RipollSanchezMidRangeReader",
"RipollSanchez_2023",
]
readers["RipollSanchezLongRange"] = [
"cect.RipollSanchezLongRangeReader",
"RipollSanchez_2023",
]

if not quick:
readers["SSData"] = ["cect.SpreadsheetDataReader", None]
readers["UpdSSData"] = ["cect.UpdatedSpreadsheetDataReader", None]
readers["UpdSSData2"] = ["cect.UpdatedSpreadsheetDataReader2", None]

readers["Test"] = ["cect.TestDataReader", None]

main_mk = "# Comparison between data readers\n"
table = ""
table_html = ""

for reader_name, reader_info in readers.items():
reader = reader_info[0]
Expand Down Expand Up @@ -494,7 +512,7 @@ def generate_comparison_page(quick: bool, color_table=True):

if color_table:
STYLE = '"width:80px"'
table += f"<table>\n <tr>\n <th style={STYLE}>Group</th>\n"
table_html += f'<table>\n <tr>\n <th style={STYLE}><span style="font-size:150%"> </span></th>\n'

readers_to_include = []

Expand All @@ -503,10 +521,19 @@ def generate_comparison_page(quick: bool, color_table=True):
readers_to_include.append(reader_name)

for reader_name in readers_to_include:
table += f" <th style={STYLE}>{reader_name}</th>\n"
better_name = (
reader_name.replace("_", " ")
.replace("201", " 201")
.replace("chez", "chez ")
.replace("19", "19 ")
.replace("liet", "liet ")
.replace("MA", "Monoamin.")
.replace("PEP", "Peptid.")
)
table_html += f' <th style={STYLE}><span style="font-size:150%">{better_name}</span></th>\n'

for group in COOK_GROUPING_1:
table += f" <tr>\n<td >{group}</th>\n"
table_html += f' <tr>\n<td ><b><span style="font-size:150%">{group}</span></b></th>\n'

for reader_name in readers_to_include:
connectome = all_connectomes[reader_name]
Expand All @@ -519,16 +546,16 @@ def generate_comparison_page(quick: bool, color_table=True):
else:
pass # cells_here+='<s>%s</s>&nbsp;'%cell

if (cells_here.split("<br/>")[-1]).count("&nbsp;") > 5:
if (cells_here.split("<br/>")[-1]).count("&nbsp;") > 9:
cells_here += "<br/>\n"

table += f" <td >{cells_here}</th>\n"
table_html += f" <td >{cells_here}</th>\n"

table += " </tr>\n"
table_html += " </tr>\n"

table += " </tr>\n</table>\n"
table_html += " </tr>\n</table>\n"

main_mk += table
main_mk += table_html.replace("150%", "100%")

main_mk += df_all.to_markdown()

Expand All @@ -538,6 +565,27 @@ def generate_comparison_page(quick: bool, color_table=True):

print_("Written page: %s" % filename)

filename = "docs/Comparison_table.html"
with open(filename, "w") as f:
f.write(
"""<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
%s
</body>
</html>"""
% table_html
)

print_("Written page: %s" % filename)

return connectomes


Expand Down
Loading

0 comments on commit b345637

Please sign in to comment.