Skip to content

Commit

Permalink
Improved single cell views
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Nov 7, 2024
1 parent 7f4f30a commit 52bdc27
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 34 deletions.
73 changes: 49 additions & 24 deletions cect/CellInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from cect.Cells import is_any_neuron
from cect.Cells import get_primary_classification
from cect.Cells import get_standard_color
from cect.Cells import is_male_specific_cell


from cect import print_
Expand Down Expand Up @@ -134,12 +135,12 @@ def generate_cell_info_pages(connectomes):
"""Generates the individual cell pages
Args:
connectomes (list): The
connectomes (list): The list of connectome readers to use
"""
cell_data = load_individual_neuron_info()
cell_classification = get_primary_classification()

all_cell_info = []
all_cell_info = [["Cell name", "Type", "Name details", "Lineage", "Classification"]]

for cell in ALL_PREFERRED_CELL_NAMES:
print_("Generating individual cell page for: %s" % cell)
Expand All @@ -155,44 +156,59 @@ def generate_cell_info_pages(connectomes):
)
else "%s%s" % (cell[:2], cell[-1])
) # CA04 -> CA4 etc.
ackr = cell_data[cell_ref][0]
acronym = cell_data[cell_ref][0]
lineage = cell_data[cell_ref][1]
desc = cell_data[cell_ref][2]
from_ = 0
for c in cell:
# print('Replacing %s (from %s) in %s'%(c,from_,ackr))
if c in ackr:
ii = ackr.index(c, from_)
ackr = "%s<b>%s</b>%s" % (ackr[:ii], ackr[ii], ackr[ii + 1 :])
# print('Replacing %s (from %s) in %s'%(c,from_,acronym))
if c in acronym:
ii = acronym.index(c, from_)
acronym = "%s<u>%s</u>%s" % (
acronym[:ii],
acronym[ii],
acronym[ii + 1 :],
)
from_ = ii + 1

cell_info += '!!! question "**%s: %s**"\n\n' % (
cell,
cell_data[cell_ref][2],
acronym,
)
cell_info += (
' <p class="subtext">%s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' % (ackr)
' <p class="subtext"><b>%s</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
% (desc)
)
cell_info += "Lineage: <b>%s</b></p>\n\n" % (lineage)

all_cell_info.append(
[
cell,
get_cell_notes(cell),
cell_data[cell_ref][0],
cell_data[cell_ref][1],
cell_data[cell_ref][2],
]
)
cell_info += "Lineage: <b>%s</b></p>\n\n" % (cell_data[cell_ref][1])

all_cell_info.append([cell, get_cell_notes(cell), cell_data[cell_ref][0], cell_data[cell_ref][1], cell_data[cell_ref][2]])

else:
cell_info += '!!! question "**%s: %s**"\n\n' % (cell, get_cell_notes(cell))
all_cell_info.append([cell, get_cell_notes(cell), cell_data[cell_ref][0], '','',''])
all_cell_info.append(
[cell, get_cell_notes(cell), cell_data[cell_ref][0], '""', '""', '""']
)

cell_info += (
' <p class="subtext"><a href="../Cook_2019">Cook 2019</a> classification: <b>%s</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
% (get_cell_notes(cell))
)
cc = cell_classification[cell]
color = get_standard_color(cell)[1:]

color = get_standard_color(cell)

cell_info += (
'All cells of type: ![#%s](images/%s.png) <a href="../Cells/#%s"><b>%s</b></a></p>\n\n'
'All cells of type: <a href="../Cells/#%s"><b><span style="color:%s">%s</span></b></a></p>\n\n'
% (
color,
color,
cc.lower().replace(" ", "-").replace("(", "").replace(")", ""),
color,
cc[0].upper() + cc[1:],
)
)
Expand Down Expand Up @@ -220,7 +236,8 @@ def generate_cell_info_pages(connectomes):
cell, html=True, use_color=True, individual_cell_page=True
)

reference_cs = "Cook2019Herm"
reference_cs = "Cook2019Male" if is_male_specific_cell(cell) else "Cook2019Herm"

reference_gj = reference_cs
reference_mono = "Bentley2016_MA"
reference_pep = "RipollSanchezShortRange"
Expand Down Expand Up @@ -350,18 +367,18 @@ def generate_cell_info_pages(connectomes):
<tr>
<td><b><a href="#chemical-synaptic-connections-to-{cell.lower()}">Chemical</a></b></td>
<td style="width:40%">{conns_to_cs}</td>
<td style="width:5%" align="middle">→</td>
<td style="width:5%" style="vertical-align:bottom;text-align:center;">\u2198</td>
<td rowspan="4" style="vertical-align:middle;text-align:center;"><b>{cell_link}</b></td>
<td style="width:5%" align="middle">→</td>
<td style="width:5%" style="vertical-align:bottom;text-align:center;">\u2197</td>
<td style="width:40%">{conns_from_cs}</td>
</tr><tr>
<td><b><a href="#monoaminergic-connections-to-{cell.lower()}">Monoaminergic</a></b></td><td>{conns_to_mono}</td><td align="middle">→</td><td align="middle">→</td><td>{conns_from_mono}</td>
</tr><tr>
<td><b><a href="#peptidergic-connections-to-{cell.lower()}">Peptidergic</a></b></td> <td>{conns_to_pep}</td><td align="middle">→</td><td align="middle">→</td><td>{conns_from_pep}</td>
</tr><tr>
<td><b><a href="#functional-connections-to-{cell.lower()}">Functional</a></b></td> <td>{conns_to_func}</td><td align="middle"></td><td align="middle"></td><td>{conns_from_func}</td>
<td><b><a href="#functional-connections-to-{cell.lower()}">Functional</a></b></td> <td>{conns_to_func}</td><td align="middle">\u2197</td><td align="middle">\u2198</td><td>{conns_from_func}</td>
</tr><tr>
<td>&nbsp;</td> <td colspan="5" align="middle"></td>
<td>&nbsp;</td> <td colspan="5" align="middle">\u2195</td>
</tr><tr>
<td><b><a href="#electrical-synaptic-connections-fromto-{cell.lower()}">Electrical</a></b></td> <td colspan="5" align="middle">{conns_gj}</td>
</tr>
Expand All @@ -378,7 +395,7 @@ def generate_cell_info_pages(connectomes):
cell_info_filename = "cect/data/all_cell_info.csv"
with open(cell_info_filename, "w") as csv_file:
print_(f"Writing info on all cells to {cell_info_filename}")
csv_writer = csv.writer(csv_file, delimiter=',', quotechar='"')
csv_writer = csv.writer(csv_file, delimiter=",", quotechar='"')
for line in all_cell_info:
csv_writer.writerow(line)

Expand All @@ -394,6 +411,14 @@ def generate_cell_info_pages(connectomes):

connectomes = {"White_whole": cds_white, "Witvliet8": cds_w8}

from cect.Cook2019HermReader import get_instance

connectomes["Cook2019Herm"] = get_instance()

from cect.Cook2019MaleReader import get_instance

connectomes["Cook2019Male"] = get_instance()

"""
from cect.WormNeuroAtlasMAReader import get_instance
connectomes['Bentley2016_MA'] = get_instance()
Expand Down
35 changes: 25 additions & 10 deletions cect/Cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,10 +1259,10 @@ def get_cell_notes(cell):
)


GONAD_CELL = ["gonad"]
GONAD_CELL_MALE = ["gonad"]
cell_notes["gonad"] = "gonad (male specific)"

PROCTODEUM_CELL = ["proctodeum"]
PROCTODEUM_CELL_MALE = ["proctodeum"]
cell_notes["proctodeum"] = "proctodeum (male specific)"

# TODO: remove sh versions, R1shL, etc from here!!!
Expand Down Expand Up @@ -1308,6 +1308,9 @@ def get_cell_notes(cell):
for cell in MALE_RAY_STRUCTURAL_CELLS:
cell_notes[cell] = "male ray structural cell"

MALE_SPECIFIC_OTHER_CELLS = (
MALE_RAY_STRUCTURAL_CELLS + GONAD_CELL_MALE + PROCTODEUM_CELL_MALE
)

INTESTINAL_MUSCLES = [
"mu_intL",
Expand Down Expand Up @@ -1463,15 +1466,18 @@ def get_cell_notes(cell):
KNOWN_OTHER_CELLS = KNOWN_OTHER_CELLS_COOK_19

KNOWN_OTHER_CELLS += (
MALE_SPECIFIC_NEURONS + MALE_RAY_STRUCTURAL_CELLS + PROCTODEUM_CELL + GONAD_CELL
MALE_SPECIFIC_NEURONS
+ MALE_RAY_STRUCTURAL_CELLS
+ PROCTODEUM_CELL_MALE
+ GONAD_CELL_MALE
)

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
MALE_RAY_STRUCTURAL_CELLS + PROCTODEUM_CELL_MALE + GONAD_CELL_MALE
)

ALL_PREFERRED_CELL_NAMES = (
Expand Down Expand Up @@ -1603,10 +1609,10 @@ def get_primary_classification():
for cell in MALE_POSTERIOR_OBLIQUE_MUSCLES:
classification[cell] = cell_type
elif cell_type == "vas deferens":
for cell in GONAD_CELL:
for cell in GONAD_CELL_MALE:
classification[cell] = cell_type
elif cell_type == "proctodeum":
for cell in PROCTODEUM_CELL:
for cell in PROCTODEUM_CELL_MALE:
classification[cell] = cell_type
elif cell_type == "diagonal muscles":
for cell in MALE_DIAGONAL_MUSCLES:
Expand Down Expand Up @@ -1868,6 +1874,13 @@ def is_herm_neuron(cell):
return cell in PREFERRED_HERM_NEURON_NAMES


def is_male_specific_cell(cell):
return (
cell
in MALE_SPECIFIC_NEURONS + MALE_SPECIFIC_MUSCLES + MALE_SPECIFIC_OTHER_CELLS
)


def is_any_neuron(cell):
return cell in PREFERRED_HERM_NEURON_NAMES + MALE_SPECIFIC_NEURONS

Expand Down Expand Up @@ -1987,9 +2000,9 @@ def get_standard_color(cell):
elif cell in MALE_RAY_STRUCTURAL_CELLS:
return WA_COLORS["Male"]["Epithelial Tissue"]["ray structural cell"]

elif cell in PROCTODEUM_CELL:
elif cell in PROCTODEUM_CELL_MALE:
return WA_COLORS["Male"]["Reproductive System"]["proctodeum"]
elif cell in GONAD_CELL:
elif cell in GONAD_CELL_MALE:
return WA_COLORS["Male"]["Reproductive System"]["vas deferens"]

else:
Expand Down Expand Up @@ -2528,9 +2541,11 @@ def _generate_cell_table(cell_type, cells):
)

elif cell_type == "vas deferens":
f.write(_generate_cell_table(cell_type, GONAD_CELL))
f.write(_generate_cell_table(cell_type, GONAD_CELL_MALE))
elif cell_type == "proctodeum":
f.write(_generate_cell_table(cell_type, PROCTODEUM_CELL))
f.write(
_generate_cell_table(cell_type, PROCTODEUM_CELL_MALE)
)

elif cell_type == "diagonal muscles":
f.write(
Expand Down

0 comments on commit 52bdc27

Please sign in to comment.