OSCR

Distributed control circuits across a brain-and-cord connectome.

Code ↔ Paper

40 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 40 matches · 1 of them tie a paragraph to a whole file, not to given lines: a weak match, whose lines are not tinted
  1. [1] § Methods › Clustering influence by influence and connectivity ↔ R/04_indirect_connectivity.Rmd, lines 978–1094 · score 0.98 · dynamic tree cut, cutreeDynamic, deepSplit, minClusterSize, min_dist, n_neighbors
  2. [2] § Methods › Naming effector groups ↔ banc/annotations/franken-annotations-fix.R, lines 1071–1130 · score 0.97 · SEZ_NSC_CAPA, l_NSC_CRZ, l_NSC_ITP, m_NSC_DH44, m_NSC_DILP, m_NSC_DMS
  3. [3] § Methods › Naming effector groups ↔ malecns/malecns-meta.R, lines 1152–1211 · score 0.96 · SEZ_NSC_CAPA, l_NSC_CRZ, l_NSC_ITP, m_NSC_DH44, m_NSC_DILP, m_NSC_DMS
  4. [4] § Methods › Naming effector groups ↔ banc/annotations/franken-annotations-fix.R, lines 711–770 · score 0.96 · long tendon muscle, tarsus levators, femur reductors, trochanter flexors, tibia flexors, leg muscle
  5. [5] § Methods › Naming effector groups ↔ malecns/malecns-meta.R, lines 732–791 · score 0.96 · long tendon muscle, tarsus levators, femur reductors, trochanter flexors, tibia flexors, leg muscle
  6. [6] § Methods › Clustering influence by influence and connectivity ↔ R/03_connectivity_analyses.Rmd, lines 1177–1265 · score 0.95 · dynamic tree cut, cutreeDynamic, deepSplit, minClusterSize, ward.D2, hierarchical clustering
  7. [7] § Methods › Naming effector groups ↔ exploration/R/abd-influence.R, lines 911–957 · score 0.94 · MNhm03, MNhm42, MNhm43, indirect flight, haltere motor neurons, tpn
  8. [8] § Methods › Neurotransmitter prediction ↔ resnet_18/scripts/02_train.py, lines 251–302 · score 0.91 · focal loss, random gamma, random affine, random noise, Adam, augmentation
  9. [9] § Methods › Cell-type matching and annotation › Expert manual annotation of sensory and effector neurons ↔ banc/annotations/franken-annotations-fix.R, lines 274–351 · score 0.90 · salivary glands, digestive tract, exit nerve, Wheeler, body part, metathoracic
  10. [10] § Methods › Cell-type matching and annotation › Overview ↔ banc/share/banc-nblast-share-gcs.R, the whole file · a weak match · score 0.90 · banc_fanc_1116_nblast.feather, banc_hemibrain_v1.2.1_nblast.feather, banc_manc_v1.2.1_nblast.feather, banc_fafb_783_nblast.feather, maleCNS, cross
  11. [11] § Methods › Naming effector groups ↔ malecns/malecns-meta.R, lines 1152–1211 · score 0.89 · EN27X010, haltere power, haltere steering, haltere motor neurons, wing steering, myomodulatory
  12. [12] § Methods › Annotation taxonomy ↔ banc/annotations/franken-annotations-fix.R, lines 1311–1393 · score 0.89 · PPL1 dopaminergic neuron, wing steering motor, front leg, Kenyon cell, leg motor neuron, cell function detailed
  13. [13] § Methods › Data analysis and visualization ↔ banc/annotations/franken-annotations-fix.R, lines 274–351 · score 0.88 · prosternal organ, salivary glands, digestive tract, retrocerebral complex, neurohemal complex, enteric
  14. [14] § Methods › Annotation taxonomy ↔ banc/curation/make_codex_annotations_flat_table_v888.R, lines 108–145 · score 0.87 · neuropeptide verified, codex annotations, neurotransmitter verified, body part sensory, peripheral target, match ID
  15. [15] § Methods › Cell-type matching and annotation › Overview ↔ banc/nblast/banc-nblast-compile.R, lines 1551–1602 · score 0.87 · banc_fanc_1116_nblast.feather, banc_hemibrain_v1.2.1_nblast.feather, banc_manc_v1.2.1_nblast.feather, banc_fafb_783_nblast.feather, cross, error
  16. [16] § Methods › Cell-type matching and annotation › Automated typing by morphology and connectivity ↔ alignment/banc-alignment-run.py, lines 501–579 · score 0.86 · connectivity profiles, individual FAFB, optic lobe, somata, Jaccard, centroids
  17. [17] § Methods › Colour maximum intensity projections ↔ fanc/render_neurons.py, lines 13–157 · score 0.86 · maximum intensity projections, JRC2018_UNISEX_20x_HR, jrc2018 vnc unisex, depth, mips, BANC
  18. [18] § Methods › Synapse detection ↔ o2/production/o2_banc_v888_rebuild.sh, lines 1–61 · score 0.85 · synapse neuropil lookup, synapses v3 enriched, v3 parquet, nt prediction, synapses v2, splits
  19. [19] § Methods › Naming CNS networks ↔ banc/annotations/franken-annotations-fix.R, lines 1131–1190 · score 0.82 · FB tangential, hDelta, vDelta, optic lobe, Delta7, PEN
  20. [20] § Methods › Naming CNS networks ↔ malecns/malecns-meta.R, lines 1272–1331 · score 0.82 · FB tangential, hDelta, vDelta, optic lobe, Delta7, PEN
  21. [21] § Methods › Naming effector groups ↔ exploration/R/abd-influence.R, lines 763–810 · score 0.82 · ventral cervical, dorsal prothoracic, head bristle, pharyngeal nerves, prosternal, motor neuron
  22. [22] § Methods › Naming effector groups ↔ banc/annotations/franken-annotations-fix.R, lines 1071–1130 · score 0.82 · sez nsc, salivary motor neuron, proboscis motor neuron, neurosecretory cells, DNg28, pharynx
  23. [23] § Methods › Synapse detection evaluation ↔ exploration/matlab/plot_heatmap_syn_per_np.m, lines 6–73 · score 0.81 · haltere tectulum, wing tectulum, lower tectulum, abdominal neuromere, accessory, medial
  24. [24] § A metric of influence ↔ python/fly_connectome_04_indirect_connectivity.ipynb, lines 1–111 · score 0.80 · indirect connections, log transform, computationally efficient, linear dynamical, signal propagation, steady state
  25. [25] § Methods › Synapse detection ↔ o2/oneshots/o2_banc_v890_rebuild.sh, lines 1–66 · score 0.80 · synapse neuropil lookup, synapses v3 enriched, nt prediction, synapses v2, parquet, splits
  26. [26] § Methods › Naming AN/DN clusters ↔ malecns/malecns-meta.R, lines 732–791 · score 0.80 · external taste sensilla, taste peg, hair plates, leg motor, labellum, bristles
  27. [27] § Methods › Specimen ↔ malecns/malecns-meta.R, lines 1272–1331 · score 0.78 · lobula plate, lamina intrinsic, optic lobes, intrinsic neurons, Lai, medulla
  28. [28] § A metric of influence ↔ R/04_indirect_connectivity.Rmd, lines 45–114 · score 0.78 · log transform, computationally efficient, indirect connections, linear dynamical, signal propagation, steady state
  29. [29] § Methods › Naming effector groups ↔ banc/annotations/franken-annotations-fix.R, lines 353–410 · score 0.77 · dorsal prothoracic, pharyngeal nerves, antennal nerves, labial, maxillary, cervical
  30. [30] § Methods › Naming effector groups ↔ exploration/R/abd-influence.R, lines 812–859 · score 0.77 · sez nsc, salivary motor neuron, proboscis motor neuron, Hugin, ingestion, neurosecretory
  31. [31] § Methods › Proofreading ↔ slackbots/deprecated_proofreading_status_bot.py, lines 81–116 · score 0.76 · proofread status, proofread neurons, Bot, Slack, edits, backbone
  32. [32] § A unified open-source connectome ↔ banc/legacy/banc-synapse-proportion-plot.R, lines 1–71 · score 0.75 · cumulative share, BANC synapse, synapses v2, identified neuron, roughly proofread, trachea
  33. [33] § Methods › Naming CNS networks ↔ malecns/malecns-meta.R, lines 1452–1511 · score 0.74 · DN1p, PPL1 dopaminergic, projection neurons, DN3, circadian, bristle
  34. [34] § Methods › Naming CNS networks ↔ banc/annotations/franken-annotations-fix.R, lines 1251–1310 · score 0.74 · single leg neuromere, serially convergent, VNC intrinsic, metathoracic, prothoracic, dorsal
  35. [35] § Methods › Overview ↔ banc/transforms/banc-ngl-upload.R, lines 369–415 · score 0.73 · Google Storage, nerve cord fly, FlyWire, lab_brain, lee, volume
  36. [36] § Methods › Cell-type matching and annotation › Expert manual annotation of sensory and effector neurons ↔ exploration/R/abd-influence.R, lines 763–810 · score 0.73 · abdominal nerves, metathoracic, prothoracic, tract, chemosensory, chordotonal
  37. [37] § Methods › Neuropils and template alignment ↔ fanc/transforms/template_alignment.py, lines 135–269 · score 0.72 · VNC templates, template space, female brain, warping, transform, resolution
  38. [38] § Methods › Synapse detection evaluation ↔ malecns/malecns-meta.R, lines 1332–1391 · score 0.72 · leg neuromere, Kenyon cells, mushroom body, lobula, medulla, medial
  39. [39] § Methods › Naming AN/DN clusters ↔ banc/annotations/franken-annotations-fix.R, lines 711–770 · score 0.72 · external taste sensilla, taste peg, leg motor neurons, labellum, effector, cells
  40. [40] § Methods › Spectral clustering ↔ banc/clustering/banc-spectral-clustering.R, lines 31–94 · score 0.71 · min connection strength, embedding seed, cluster seed, UMAP, Spectral, CNS

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R · 2,003 lines · 107 KB · GPL-3.0 · 10 matches

  1. #' franken-annotations-fix — Standardise franken-brain annotations against published labels.
  2. #'
  3. #' Diff `franken_meta()` cell_types against the published FAFB Supplemental
  4. #' table and apply targeted corrections to the franken-brain CSV (column
  5. #' harmonisation, dataset-specific fix blocks).
  6. #'
  7. #' @section Reads:
  8. #' - `franken_meta()`
  9. #' - `BANC-project/data/banc_annotations/Supplemental_file1_neuron_annotations.tsv`
  10. #'
  11. #' @section Writes:
  12. #' - `<banc.meta.save.path>/frankenbrain_v*_meta.csv` (per-fix-block)
  13. #'
  14. #' @section Notes:
  15. #' - Manual; many blocks are currently commented out — uncomment to apply.
  16. ############################################
  17. ### STANDARDISE THE ANNOTATIONS FOR BANC ###
  18. ############################################
  19. source("banc/banc-startup.R")
  20. # get current table
  21. franken.meta <- franken_meta()
  22. #######################################
  23. ## DIFFERENCE WITH PUBLISHED LABELS ###
  24. #######################################
  25. # # read published data
  26. # fafb.pub <- read_tsv("/Users/papers/BANC-project/data/banc_annotations/Supplemental_file1_neuron_annotations.tsv",
  27. # col_types = banc.col.types)
  28. #
  29. # # cell type difference
  30. # franken.cts <- franken.meta %>%
  31. # dplyr::filter(dataset=="FAFB", region!="optic_lobe") %>%
  32. # dplyr::distinct(cell_type) %>%
  33. # dplyr::pull(cell_type)
  34. # fafb.cts <- fafb.pub %>%
  35. # dplyr::mutate(cell_type = dplyr::case_when(
  36. # is.na(cell_type)&!is.na(hemibrain_type) ~ hemibrain_type,
  37. # is.na(cell_type)&!is.na(morphology_group) ~ morphology_group,
  38. # TRUE ~ cell_type
  39. # )) %>%
  40. # dplyr::distinct(cell_type) %>%
  41. # dplyr::pull(cell_type)
  42. #
  43. # # diff
  44. # ct.diff <- setdiff(franken.cts, fafb.cts)
  45. ######################################
  46. ## ADD MISSING NEURONS SINCE PRINT ###
  47. ######################################
  48. # ft.midbrain <- fafbseg::flytable_query("select root_id, root_783, supervoxel_id, nucleus_id, super_class, cell_class, cell_sub_class, top_nt, side from info")
  49. # ft.optic <- fafbseg::flytable_query("select root_id, root_783, supervoxel_id, nucleus_id, super_class, cell_class, cell_sub_class, top_nt, side from optic")
  50. # ft.glia <- rbind(ft.midbrain,ft.optic) %>%
  51. # dplyr::filter(grepl("glia",super_class)|grepl("glia",cell_class)|grepl("glia",cell_sub_class)) %>%
  52. # dplyr::distinct(root_id, .keep_all = TRUE)
  53. # readr::write_csv(ft.glia, file = "/Users/abates/Downloads/fafb_flywire_glia.csv")
  54. # ft.midbrain <- fafbseg::flytable_query("select _id, root_783, supervoxel_id, nucleus_id, flow, super_class, cell_class, cell_sub_class, cell_type, hemibrain_type, ito_lee_hemilineage, hartenstein_hemilineage, morphology_group, top_nt, top_nt_conf, side, nerve, vfb_id, fbbt_id, status, soma_x from info")
  55. # ft.midbrain$region <- "midbrain"
  56. # ft.optic <- fafbseg::flytable_query("select * from optic")
  57. # ft.optic$region <- "optic_lobe"
  58. # ft.update <- ft.midbrain %>%
  59. # rbind.fill(ft.optic.update) %>%
  60. # dplyr::filter(!root_783 %in% na.omit(unique(franken.meta$fafb_id))) %>%
  61. # dplyr::filter(!cell_class %in% c("fragment","trachea","large_fragment","ECM","tadpole")) %>%
  62. # dplyr::filter(!super_class %in% c("not_a_neuron")) %>%
  63. # dplyr::filter(!grepl("glia",cell_class)) %>%
  64. # dplyr::rename(neuron_id = root_783,
  65. # FAFB_supervoxel_id=supervoxel_id,
  66. # FAFB_nucleus_id=nucleus_id,
  67. # FAFB_flow=flow,
  68. # FAFB_super_class=super_class,
  69. # FAFB_cell_class=cell_class,
  70. # FAFB_cell_sub_class=cell_sub_class,
  71. # FAFB_cell_type=cell_type,
  72. # FAFB_hemibrain_type=hemibrain_type,
  73. # FAFB_ito_lee_hemilineage=ito_lee_hemilineage,
  74. # FAFB_hartenstein_hemilineage=hartenstein_hemilineage,
  75. # FAFB_morphology_group=morphology_group,
  76. # FAFB_top_nt=top_nt,
  77. # FAFB_top_nt_conf=top_nt_conf,
  78. # FAFB_side=side,
  79. # FAFB_nerve=nerve,
  80. # FAFB_vfb_id=vfb_id,
  81. # FAFB_fbbt_id=fbbt_id,
  82. # FAFB_status=status) %>%
  83. # dplyr::mutate(fafb_id = neuron_id,
  84. # flow=FAFB_flow,
  85. # super_class=FAFB_super_class,
  86. # cell_type=dplyr::case_when(
  87. # !is.na(matsliah_type) ~ matsliah_type,
  88. # TRUE ~ FAFB_cell_type
  89. # ),
  90. # cell_class = FAFB_cell_class,
  91. # cell_sub_class=FAFB_cell_sub_class,
  92. # hemilineage=dplyr::case_when(
  93. # !is.na(FAFB_ito_lee_hemilineage) ~ FAFB_ito_lee_hemilineage,
  94. # TRUE ~ FAFB_hartenstein_hemilineage
  95. # ),
  96. # top_nt=FAFB_top_nt,
  97. # side=FAFB_side,
  98. # nerve=FAFB_nerve) %>%
  99. # dplyr::select(neuron_id,
  100. # fafb_id,
  101. # region,
  102. # flow,
  103. # super_class,
  104. # cell_class,
  105. # cell_sub_class,
  106. # cell_type,
  107. # top_nt,
  108. # side,
  109. # nerve,
  110. # hemilineage,
  111. # FAFB_supervoxel_id,
  112. # FAFB_nucleus_id,
  113. # FAFB_flow,
  114. # FAFB_super_class,
  115. # FAFB_cell_class,
  116. # FAFB_cell_sub_class,
  117. # FAFB_cell_type,
  118. # FAFB_hemibrain_type,
  119. # FAFB_ito_lee_hemilineage,
  120. # FAFB_hartenstein_hemilineage,
  121. # FAFB_morphology_group,
  122. # FAFB_top_nt,
  123. # FAFB_top_nt_conf,
  124. # FAFB_side,
  125. # FAFB_nerve,
  126. # FAFB_vfb_id,
  127. # FAFB_fbbt_id,
  128. # FAFB_status) %>%
  129. # dplyr::filter(!is.na(cell_type))
  130. # ft.update[is.na(ft.update)] <- ''
  131. # banctable_append_rows(base='cns_meta',
  132. # table = "franken_meta",
  133. # df = as.data.frame(ft.update),
  134. # chunksize = 1000)
  135. ##################################
  136. ## USE ARIE'S OPTIC LOBE TYPES ###
  137. ##################################
  138. # Change to matisliah types
  139. # ft.optic <- fafbseg::flytable_query("select root_783, matsliah_type from optic")
  140. # allowed neurotransmitters (for neurotransmitters_verified column)
  141. allowed_neurotransmitters <- c(
  142. "acetylcholine", "gaba", "glutamate", "glycine", "dopamine",
  143. "serotonin", "histamine", "tyramine", "octopamine", "nitric_oxide"
  144. )
  145. # execute changes to annotations
  146. # documented here: https://github.com/wilson-lab/bancpipeline/blob/main/annotations/annotations.md
  147. franken.meta.update <- franken.meta %>%
  148. ### CELL TYPE CHANGES ####
  149. # # cell type left join
  150. # dplyr::left_join(ft.optic %>%
  151. # dplyr::distinct(root_783,
  152. # matsliah_type),
  153. # by = c("fafb_id"="root_783")) %>%
  154. # # cell_type
  155. # dplyr::mutate(cell_type = dplyr::case_when(
  156. # cell_type=="ocellar retinula cell" ~ "ocellar_retinula_cell",
  157. # !is.na(matsliah_type) ~ matsliah_type,
  158. # TRUE ~ cell_type
  159. # )) %>%
  160. # dplyr::select(-matsliah_type) %>%
  161. ### MOVING TO NEW POLICY ####
  162. # citation
  163. dplyr::mutate(citation_cell_type = dplyr::case_when(
  164. !is.na(FAFB_cell_type)&cell_type==FAFB_cell_type ~ "Schlegel et al., 2024 (cell type)",
  165. !is.na(MANC_type)&cell_type==MANC_type ~ "Marin et al., 2024 (cell type)",
  166. TRUE ~ NA
  167. ) ) %>%
  168. # flow
  169. dplyr::mutate(flow = dplyr::case_when(
  170. cell_type %in% c("AN_4_22ac4f12", "AN_4_63", "AN_4_None", "AN_4_c964e2c2", "AN_GNG_69", # corrections
  171. "SA_MDA_2", "SA_MDA_3", "Dm9", "L4", "C3", "Dm11", "L3", "Lawf1", "Lawf2") ~ "intrinsic",
  172. grepl("afferent",flow) ~ "afferent",
  173. grepl("sensory",super_class)&!grepl("efferent|intrinsic",flow) ~ "afferent",
  174. grepl("^R1-6$|^R7$|^R8$", cell_type) ~ "afferent",
  175. grepl("motor|endocrine|efferent",super_class) ~ "efferent",
  176. grepl("efferent",flow) ~ "efferent",
  177. grepl("^ascending$",super_class) ~ "intrinsic",
  178. grepl("^descending$",super_class) ~ "intrinsic",
  179. grepl("ascending|descending",super_class) ~ "intrinsic",
  180. grepl("intrinsic",flow) ~ "intrinsic",
  181. is.na(nerve) ~ "intrinsic",
  182. # none get NA, as desired
  183. TRUE ~ NA
  184. ) ) %>%
  185. # side
  186. dplyr::mutate(side = dplyr::case_when(
  187. grepl("right",side) ~ "right",
  188. grepl("left",side) ~ "left",
  189. grepl("center|midline|unpaired|both",side) ~ "center", # midline and unpaired unused
  190. # small number get NA, some sensory and others with missing class info
  191. TRUE ~ NA
  192. ) ) %>%
  193. # region — "neck_connective" disabled as a region value. Ascending/descending
  194. # neurons are identified via super_class; cervical_connective is a tract entry.
  195. dplyr::mutate(region = dplyr::case_when(
  196. grepl("visual_centrifugal",super_class) ~ "central_brain",
  197. (grepl("visual_projection|optic",super_class) &
  198. !grepl("ocellar_interneuron",super_class)) ~ "optic_lobe",
  199. grepl("ocellar",super_class) ~ "central_brain",
  200. grepl("ocellar",cell_class) ~ "central_brain",
  201. grepl("vnc|VNC",region) ~ "ventral_nerve_cord",
  202. grepl("midbrain|central_brain|sez",region) ~ "central_brain",
  203. grepl("OL|optic",region) ~ "optic_lobe",
  204. TRUE ~ NA
  205. ) ) %>%
  206. dplyr::mutate(body_part_sensory = dplyr::case_when(
  207. grepl("^R1-6$|^R7$|^R8$",cell_type) ~ "retina",
  208. cell_type %in% "R1-6" ~ "retina",
  209. cell_type %in% c("R7","R8") ~ "retina",
  210. !grepl("sensory|visceral",super_class) ~ NA,
  211. grepl("^ISN$",cell_type) ~ "hemolymph_sensory",
  212. # head
  213. ## head bristles
  214. grepl("BM_Ant",cell_type) ~ "antenna",
  215. grepl("BM_dOcci",cell_type) ~ "occipital_dorsal",
  216. grepl("BM_dPoOr",cell_type) ~ "postorbital_dorsal",
  217. grepl("BM_FrOr", cell_type) ~ "frontoorbital",
  218. grepl("BM_Fr",cell_type) ~ "frontal",
  219. grepl("BM_Hau",cell_type) ~ "haustellum",
  220. grepl("BM_InOc",cell_type) ~ "interocellar",
  221. grepl("BM_InOm",cell_type) ~ "interommatidial",
  222. grepl("BM_MaPa",cell_type) ~ "maxillary_palp",
  223. grepl("BM_Oc",cell_type) ~ "ocellar",
  224. grepl("BM_Or",cell_type) ~ "orbital",
  225. grepl("BM_Taste",cell_type) ~ "labellum",
  226. grepl("BM_Vib",cell_type) ~ "vibrissa",
  227. grepl("BM_vOcci_vPoOr",cell_type) ~ "postorbital_ventral",
  228. grepl("BM_Vt_PoOc",cell_type) ~ "postocellar",
  229. ## by prior annotation
  230. grepl("^eye$",body_part_sensory) ~ "eye",
  231. grepl("head$",body_part_sensory) ~ "head",
  232. grepl("antenna",nerve) ~ "antenna",
  233. grepl("antenna",body_part_sensory) ~ "antenna",
  234. grepl("aorta",body_part_sensory) ~ "aorta",
  235. grepl("CB0991",cell_type) ~ "aorta",
  236. grepl("crop",body_part_sensory) ~ "crop",
  237. grepl("cibarium",body_part_sensory) ~ "cibarium",
  238. grepl("retina",body_part_sensory) ~ "retina",
  239. cell_type %in% "HBeyelet" ~ "eyelet",
  240. grepl("ocellar_retinula_cell",cell_type) ~ "ocellus",
  241. grepl("ocellar|ocelli",body_part_sensory)&peripheral_target_type!="bristle" ~ "ocellus",
  242. grepl("ocellar|ocelli",cell_function)&peripheral_target_type!="bristle" ~ "ocellus",
  243. grepl("ocellar|ocelli",cell_function_detailed)&peripheral_target_type!="bristle" ~ "ocellus",
  244. grepl("vibrissa",body_part_sensory) ~ "vibrissa",
  245. grepl("labellum",body_part_sensory) ~ "labellum",
  246. grepl("proboscis",cell_function)&flow=="efferent" ~ "proboscis",
  247. grepl("pharynx",cell_function)&flow=="efferent" ~ "pharynx",
  248. grepl("proboscis-pharynx",body_part_sensory) ~ "proboscis-pharynx",
  249. grepl("proboscis",body_part_sensory) ~ "proboscis",
  250. grepl("pharynx",body_part_sensory) ~ "pharynx",
  251. grepl("palps",body_part_sensory) ~ "maxillary_palp",
  252. grepl("eye",body_part_sensory) ~ "eye",
  253. # CNS
  254. grepl("pars_intercerebralis",body_part_sensory) ~ "pars_intercerebralis",
  255. grepl("pars_lateralis",body_part_sensory) ~ "pars_lateralis",
  256. grepl("sez|subesophageal_zone",body_part_sensory) ~ "subesophageal_zone",
  257. grepl("ventral_nerve_cord|vnc",body_part_sensory) ~ "ventral_nerve_cord",
  258. # blood
  259. grepl("haemolymph|hemolymph",body_part_sensory) ~ "hemolymph",
  260. # thorax
  261. grepl("thorax",body_part_sensory) ~ "thorax",
  262. #grepl("neck",body_part_sensory) ~ "neck",
  263. # Legs
  264. grepl("front_leg",body_part_sensory) ~ "front_leg",
  265. grepl("middle_leg",body_part_sensory) ~ "middle_leg",
  266. grepl("hind_leg",body_part_sensory) ~ "hind_leg",
  267. grepl("leg",body_part_sensory) ~ "leg",
  268. # Flight
  269. grepl("haltere",body_part_sensory) ~ "haltere",
  270. grepl("notum|thorax",body_part_sensory) ~ "thorax",
  271. grepl("wing_base",body_part_sensory) ~ "wing_base",
  272. grepl("wing_margin",body_part_sensory) ~ "wing_margin",
  273. grepl("wing_tegula",body_part_sensory) ~ "wing_tegula",
  274. grepl("wing",body_part_sensory) ~ "wing",
  275. grepl("wing_endocrine",cell_function) ~ "wing",
  276. # Abdomen
  277. grepl("abdomen",body_part_sensory) ~ "abdomen",
  278. grepl("abdominal_wall",body_part_sensory) ~ "abdominal_wall",
  279. # Chordotonal organs
  280. grepl("metathoracic_chordotonal_organ",body_part_sensory) ~ "metathoracic_chordotonal_organ",
  281. grepl("prothoracic_chordotonal_organ",body_part_sensory) ~ "prothoracic_chordotonal_organ",
  282. grepl("prosternal_organ",body_part_sensory) ~ "prosternal_organ",
  283. grepl("wheelers_organ",body_part_sensory) ~ "wheelers_organ",
  284. # other
  285. !is.na(body_part_sensory) ~ body_part_sensory,
  286. ## by nerves
  287. grepl("^AN$",FAFB_nerve) ~ "antenna",
  288. grepl("^aPhN$",FAFB_nerve) ~ "pharynx",
  289. grepl("^PhN$",FAFB_nerve) ~ "pharynx",
  290. grepl("AbN2|AbN3|AbN4|AbNT",MANC_entryNerve) ~ "abdomen",
  291. grepl("DMetaN",MANC_entryNerve) ~ "haltere",
  292. grepl("DProN",MANC_entryNerve) ~ "front_leg",
  293. grepl("ProLN",MANC_entryNerve) ~ "front_leg",
  294. grepl("VProN",MANC_entryNerve) ~ "front_leg",
  295. grepl("MesoLN",MANC_entryNerve) ~ "middle_leg",
  296. grepl("MetaLN", MANC_entryNerve) ~ "hind_leg",
  297. grepl("PDMN",MANC_entryNerve) ~ "thorax",
  298. grepl("ADMN",MANC_entryNerve) ~ "wing",
  299. grepl("PrN",MANC_entryNerve) ~ "prosternal_organ",
  300. grepl("ProCN",MANC_entryNerve) ~ "prothoracic_chordotonal_organ",
  301. # remainder
  302. TRUE ~ "unknown"
  303. ) ) %>%
  304. dplyr::mutate(body_part_effector = dplyr::case_when(
  305. !grepl("efferent",flow) ~ NA,
  306. grepl("retrocerebral_complex",body_part_effector) ~ "retrocerebral_complex",
  307. grepl("enteric_complex",body_part_effector) ~ "digestive_tract",
  308. grepl("corpus_allatum",body_part_effector) ~ "corpus_allatum",
  309. grepl("salivary_gland",body_part_effector) ~ "salivary_gland",
  310. grepl("neurohemal_complex",body_part_effector) ~ "neurohemal_complex",
  311. grepl("antenna",body_part_effector) ~ "antenna",
  312. grepl("crop",body_part_effector) ~ "crop",
  313. grepl("eye",body_part_effector) ~ "eye",
  314. grepl("front_leg",body_part_effector) ~ "front_leg",
  315. grepl("middle_leg",body_part_effector) ~ "middle_leg",
  316. grepl("hind_leg",body_part_effector) ~ "hind_leg",
  317. grepl("haltere",body_part_effector) ~ "haltere",
  318. grepl("neck",body_part_effector) ~ "neck",
  319. grepl("proboscis",body_part_effector) ~ "proboscis",
  320. grepl("pharynx",body_part_effector) ~ "pharynx",
  321. grepl("wing",body_part_effector) ~ "wing",
  322. grepl("abdomen",body_part_effector) ~ "abdomen",
  323. grepl("prothorax",body_part_effector) ~ "prothorax",
  324. ## by nerves
  325. !is.na(body_part_effector) ~ body_part_effector,
  326. # grepl("^AN$",FAFB_nerve) ~ "antenna",
  327. # grepl("^aPhN$",FAFB_nerve) ~ "pharynx",
  328. # grepl("^PhN$",FAFB_nerve) ~ "pharynx",
  329. # grepl("^CV$|CvN|CVC",FAFB_nerve) ~ "neck",
  330. # grepl("AbN2|AbN3|AbN4|AbNT",MANC_exitNerve) ~ "abdomen",
  331. # grepl("DMetaN",MANC_exitNerve) ~ "haltere",
  332. # grepl("DProN",MANC_exitNerve) ~ "prothorax",
  333. # grepl("ProAN|ProLN",MANC_exitNerve) ~ "front_leg",
  334. # grepl("VProN",MANC_exitNerve) ~ "front_leg",
  335. # grepl("MesoLN",MANC_exitNerve) ~ "middle_leg",
  336. # grepl("MetaLN",MANC_exitNerve) ~ "hind_leg",
  337. # grepl("PDMN",MANC_exitNerve) ~ "wing",
  338. # grepl("ADMN|MesoAN",MANC_exitNerve) ~ "wing",
  339. # grepl("CvN|CVC|^CV$",MANC_exitNerve) ~ "neck",
  340. TRUE ~ "unknown"
  341. ) ) %>%
  342. dplyr::mutate(nerve = dplyr::case_when(
  343. grepl("NCC",nerve) & side=="right" ~ "right_corpus_cardiacum_nerve",
  344. grepl("NCC",nerve) &side=="left" ~ "left_corpus_cardiacum_nerve",
  345. grepl("NCC",nerve) ~ "left_corpus_cardiacum_nerve",
  346. grepl("^AN",nerve) & side=="right" ~ "right_antennal_nerve",
  347. grepl("^AN",nerve) &side=="left" ~ "left_antennal_nerve",
  348. grepl("^AN",nerve) ~ "antennal_nerve",
  349. grepl("MxLbN",nerve) & side=="right" ~ "right_maxillary-labial_nerve",
  350. grepl("MxLbN",nerve) &side=="left" ~ "left_maxillary-labial_nerve",
  351. grepl("MxLbN",nerve) ~ "maxillary-labial_nerve",
  352. grepl("PhN",nerve) & side=="right" ~ "right_pharyngeal_nerve",
  353. grepl("PhN",nerve) &side=="left" ~ "left_pharyngeal_nerve",
  354. grepl("PhN",nerve) ~ "pharyngeal_nerve",
  355. grepl("aPhN",nerve) & side=="right" ~ "right_accessory_pharyngeal_nerve",
  356. grepl("aPhN",nerve) &side=="left" ~ "left_accessory_pharyngeal_nerve",
  357. grepl("aPhN",nerve) ~ "accessory_pharyngeal_nerve",
  358. grepl("OCN",nerve) & side=="right" ~ "right_ocellar_nerve",
  359. grepl("OCN",nerve) &side=="left" ~ "left_ocellar_nerve",
  360. grepl("OCN",nerve) ~ "ocellar_nerve",
  361. grepl("^ON",nerve) & side=="right" ~ "right_optic_nerve",
  362. grepl("^ON",nerve) &side=="left" ~ "left_optic_nerve",
  363. grepl("^ON",nerve) ~ "optic_nerve",
  364. grepl("CvN_R",nerve) ~ "right_cervical_nerve",
  365. grepl("CvN_L",nerve) ~ "left_cervical_nerve",
  366. grepl("CvN",nerve) ~ "cervical_nerve",
  367. grepl("CV",nerve) & side=="right" ~ "right_cervical_nerve",
  368. grepl("CV",nerve) & side=="left" ~ "left_cervical_nerve",
  369. grepl("CV",nerve) & side=="left" ~ "cervical_nerve",
  370. grepl("DProN_R",nerve) ~ "right_dorsal_prothoracic_nerve",
  371. grepl("DProN_L",nerve) ~ "left_dorsal_prothoracic_nerve",
  372. grepl("DProN",nerve) ~ "dorsal_prothoracic_nerve",
  373. grepl("ProLN_R",nerve) ~ "right_prothoracic_leg_nerve",
  374. grepl("ProLN_L",nerve) ~ "left_prothoracic_leg_nerve",
  375. grepl("ProLN",nerve) ~ "prothoracic_leg_nerve",
  376. grepl("PrN_R",nerve) ~ "right_prosternal_nerve",
  377. grepl("PrN_L",nerve) ~ "left_prosternal_nerve",
  378. grepl("PrN",nerve) ~ "prosternal_nerve",
  379. grepl("ProAN_R",nerve) ~ "right_prothoracic_accessory_nerve",
  380. grepl("ProAN_L",nerve) ~ "left_prothoracic_accessory_nerve",
  381. grepl("ProAN",nerve) ~ "prothoracic_accessory_nerve",
  382. grepl("ProCN_R",nerve) ~ "right_prothoracic_chordotonal_nerve",
  383. grepl("ProCN_L",nerve) ~ "left_prothoracic_chordotonal_nerve",
  384. grepl("ProCN",nerve) ~ "prothoracic_chordotonal_nerve",
  385. grepl("VProN_R",nerve) ~ "right_ventral_prothoracic_nerve",
  386. grepl("VProN_L",nerve) ~ "left_ventral_prothoracic_nerve",
  387. grepl("VProN",nerve) ~ "ventral_prothoracic_nerve",
  388. grepl("ADMN_R",nerve) ~ "right_anterior_dorsal_mesothoracic_nerve",
  389. grepl("ADMN_L",nerve) ~ "left_anterior_dorsal_mesothoracic_nerve",
  390. grepl("ADMN",nerve) ~ "anterior_dorsal_mesothoracic_nerve",
  391. grepl("PDMN_R",nerve) ~ "right_posterior_dorsal_mesothoracic_nerve",
  392. grepl("PDMN_L",nerve) ~ "left_posterior_dorsal_mesothoracic_nerve",
  393. grepl("PDMN",nerve) ~ "posterior_dorsal_mesothoracic_nerve",
  394. grepl("MesoLN_R",nerve) ~ "right_mesothoracic_leg_nerve",
  395. grepl("MesoLN_L",nerve) ~ "left_mesothoracic_leg_nerve",
  396. grepl("MesoLN",nerve) ~ "mesothoracic_leg_nerve",
  397. grepl("MesoAN_R",nerve) ~ "right_mesothoracic_accessory_nerve",
  398. grepl("MesoAN_L",nerve) ~ "left_mesothoracic_accessory_nerve",
  399. grepl("MesoAN",nerve) ~ "mesothoracic_accessory_nerve",
  400. grepl("DMetaN_R",nerve) ~ "right_dorsal_metathoracic_nerve",
  401. grepl("DMetaN_L",nerve) ~ "left_dorsal_metathoracic_nerve",
  402. grepl("DMetaN",nerve) ~ "dorsal_metathoracic_nerve",
  403. grepl("MetaLN_R",nerve) ~ "right_metathoracic_leg_nerve",
  404. grepl("MetaLN_L",nerve) ~ "left_metathoracic_leg_nerve",
  405. grepl("MetaLN",nerve) ~ "metathoracic_leg_nerve",
  406. grepl("AbN1_R",nerve) ~ "right_first_abdominal_nerve",
  407. grepl("AbN1_L",nerve) ~ "left_first_abdominal_nerve",
  408. grepl("AbN1",nerve) ~ "first_abdominal_nerve",
  409. grepl("AbN2_R",nerve) ~ "right_second_abdominal_nerve",
  410. grepl("AbN2_L",nerve) ~ "left_second_abdominal_nerve",
  411. grepl("AbN2",nerve) ~ "second_abdominal_nerve",
  412. grepl("AbN3_R",nerve) ~ "right_third_abdominal_nerve",
  413. grepl("AbN3_L",nerve) ~ "left_third_abdominal_nerve",
  414. grepl("AbN3",nerve) ~ "third_abdominal_nerve",
  415. grepl("AbN4_R",nerve) ~ "right_fourth_abdominal_nerve",
  416. grepl("AbN4_L",nerve) ~ "left_fourth_abdominal_nerve",
  417. grepl("AbN4",nerve) ~ "fourth_abdominal_nerve",
  418. grepl("AbNT_R",nerve) ~ "right_abdominal_nerve_trunk",
  419. grepl("AbNT_L",nerve) ~ "left_abdominal_nerve_trunk",
  420. grepl("AbNT",nerve) ~ "abdominal_nerve_trunk",
  421. grepl("AbNX_R",nerve) ~ "right_abdominal_nerve_other",
  422. grepl("AbNX_L",nerve) ~ "left_abdominal_nerve_other",
  423. grepl("AbNX",nerve) ~ "abdominal_nerve_other",
  424. TRUE ~ NA
  425. ) ) %>%
  426. # translate neuropeptide names to FlyBase ones in neuropeptide_verified column
  427. dplyr::mutate(neuropeptide_verified = gsub("allatostatin-a","AstA",neuropeptide_verified)) %>%
  428. dplyr::mutate(neuropeptide_verified = gsub("allatostatin-c","AstC",neuropeptide_verified)) %>%
  429. dplyr::mutate(neuropeptide_verified = gsub("amnesiac","amn",neuropeptide_verified)) %>%
  430. dplyr::mutate(neuropeptide_verified = gsub("capability","Capa",neuropeptide_verified)) %>%
  431. dplyr::mutate(neuropeptide_verified = gsub("ccap","CCAP",neuropeptide_verified)) %>%
  432. dplyr::mutate(neuropeptide_verified = gsub("ccha1","CCHa1",neuropeptide_verified)) %>%
  433. dplyr::mutate(neuropeptide_verified = gsub("ccha2","CCHa2",neuropeptide_verified)) %>%
  434. dplyr::mutate(neuropeptide_verified = gsub("cnma","CNMa",neuropeptide_verified)) %>%
  435. dplyr::mutate(neuropeptide_verified = gsub("corazonin","Crz",neuropeptide_verified)) %>%
  436. dplyr::mutate(neuropeptide_verified = gsub("dARC1","dARC1",neuropeptide_verified)) %>%
  437. dplyr::mutate(neuropeptide_verified = gsub("dh31|Dh331","Dh31",neuropeptide_verified)) %>%
  438. dplyr::mutate(neuropeptide_verified = gsub("dh44","Dh44",neuropeptide_verified)) %>%
  439. dplyr::mutate(neuropeptide_verified = gsub("DILP","Ilp",neuropeptide_verified)) %>%
  440. dplyr::mutate(neuropeptide_verified = gsub("dsk","Dsk",neuropeptide_verified)) %>%
  441. dplyr::mutate(neuropeptide_verified = gsub("dnpf|^NPF","NPF",neuropeptide_verified)) %>%
  442. dplyr::mutate(neuropeptide_verified = gsub("drosulfakinin","Dsk",neuropeptide_verified)) %>%
  443. dplyr::mutate(neuropeptide_verified = gsub("eclosion hormone","Eh",neuropeptide_verified)) %>%
  444. dplyr::mutate(neuropeptide_verified = gsub("fmrfa","FMRFa",neuropeptide_verified)) %>%
  445. dplyr::mutate(neuropeptide_verified = gsub("gpa2","Gpa2",neuropeptide_verified)) %>%
  446. dplyr::mutate(neuropeptide_verified = gsub("gpb5","Gpb5",neuropeptide_verified)) %>%
  447. dplyr::mutate(neuropeptide_verified = gsub("hugin","Hug",neuropeptide_verified)) %>%
  448. dplyr::mutate(neuropeptide_verified = gsub("itp","ITP",neuropeptide_verified)) %>%
  449. dplyr::mutate(neuropeptide_verified = gsub("leucokinin","Lk",neuropeptide_verified)) %>%
  450. dplyr::mutate(neuropeptide_verified = gsub("MIP","Mip",neuropeptide_verified)) %>%
  451. dplyr::mutate(neuropeptide_verified = gsub("myosuppressin|myosupressin","Ms",neuropeptide_verified)) %>%
  452. dplyr::mutate(neuropeptide_verified = gsub("natalisin","Natalisin",neuropeptide_verified)) %>%
  453. dplyr::mutate(neuropeptide_verified = gsub("Nplp1","Nplp1",neuropeptide_verified)) %>%
  454. dplyr::mutate(neuropeptide_verified = gsub("Nplp2","Nplp2",neuropeptide_verified)) %>%
  455. dplyr::mutate(neuropeptide_verified = gsub("Nplp3","Nplp3",neuropeptide_verified)) %>%
  456. dplyr::mutate(neuropeptide_verified = gsub("Nplp4","Nplp4",neuropeptide_verified)) %>%
  457. dplyr::mutate(neuropeptide_verified = gsub("orcokinin","Orcokinin",neuropeptide_verified)) %>%
  458. dplyr::mutate(neuropeptide_verified = gsub("burisconin","Pburs",neuropeptide_verified)) %>%
  459. dplyr::mutate(neuropeptide_verified = gsub("pdf","Pdf",neuropeptide_verified)) %>%
  460. dplyr::mutate(neuropeptide_verified = gsub("proctolin","Proc",neuropeptide_verified)) %>%
  461. dplyr::mutate(neuropeptide_verified = gsub("ptth","Ptth",neuropeptide_verified)) %>%
  462. dplyr::mutate(neuropeptide_verified = gsub("ryanimide","RYa",neuropeptide_verified)) %>%
  463. dplyr::mutate(neuropeptide_verified = gsub("^sp$","SP",neuropeptide_verified)) %>%
  464. dplyr::mutate(neuropeptide_verified = gsub("SIFamide","SIFa",neuropeptide_verified)) %>%
  465. dplyr::mutate(neuropeptide_verified = gsub("sNPF","sNPF",neuropeptide_verified)) %>%
  466. dplyr::mutate(neuropeptide_verified = gsub("space blanket","Sb",neuropeptide_verified)) %>%
  467. dplyr::mutate(neuropeptide_verified = gsub("tachykinin","Tk",neuropeptide_verified)) %>%
  468. dplyr::mutate(neuropeptide_verified = gsub("trissin","Trissin",neuropeptide_verified)) %>%
  469. dplyr::mutate(neuropeptide_verified =
  470. ifelse(grepl("neuropeptide-negative|negative", neuropeptide_verified, ignore.case = TRUE),
  471. NA, neuropeptide_verified)) %>%
  472. # translate neuropeptide names to FlyBase ones in neurotransmitter_verified column
  473. dplyr::mutate(neurotransmitter_verified = gsub("allatostatin-a","AstA",neurotransmitter_verified)) %>%
  474. dplyr::mutate(neurotransmitter_verified = gsub("allatostatin-c","AstC",neurotransmitter_verified)) %>%
  475. dplyr::mutate(neurotransmitter_verified = gsub("amnesiac","amn",neurotransmitter_verified)) %>%
  476. dplyr::mutate(neurotransmitter_verified = gsub("capability","Capa",neurotransmitter_verified)) %>%
  477. dplyr::mutate(neurotransmitter_verified = gsub("ccap","CCAP",neurotransmitter_verified)) %>%
  478. dplyr::mutate(neurotransmitter_verified = gsub("ccha1","CCHa1",neurotransmitter_verified)) %>%
  479. dplyr::mutate(neurotransmitter_verified = gsub("ccha2","CCHa2",neurotransmitter_verified)) %>%
  480. dplyr::mutate(neurotransmitter_verified = gsub("cnma","CNMa",neurotransmitter_verified)) %>%
  481. dplyr::mutate(neurotransmitter_verified = gsub("corazonin","Crz",neurotransmitter_verified)) %>%
  482. dplyr::mutate(neurotransmitter_verified = gsub("dARC1","dARC1",neurotransmitter_verified)) %>%
  483. dplyr::mutate(neurotransmitter_verified = gsub("dh31|Dh331","Dh31",neurotransmitter_verified)) %>%
  484. dplyr::mutate(neurotransmitter_verified = gsub("dh44","Dh44",neurotransmitter_verified)) %>%
  485. dplyr::mutate(neurotransmitter_verified = gsub("DILP","Ilp",neurotransmitter_verified)) %>%
  486. dplyr::mutate(neurotransmitter_verified = gsub("dsk","Dsk",neurotransmitter_verified)) %>%
  487. dplyr::mutate(neurotransmitter_verified = gsub("dnpf|^NPF","NPF",neurotransmitter_verified)) %>%
  488. dplyr::mutate(neurotransmitter_verified = gsub("drosulfakinin","Dsk",neurotransmitter_verified)) %>%
  489. dplyr::mutate(neurotransmitter_verified = gsub("eclosion hormone","Eh",neurotransmitter_verified)) %>%
  490. dplyr::mutate(neurotransmitter_verified = gsub("fmrfa","FMRFa",neurotransmitter_verified)) %>%
  491. dplyr::mutate(neurotransmitter_verified = gsub("gpa2","Gpa2",neurotransmitter_verified)) %>%
  492. dplyr::mutate(neurotransmitter_verified = gsub("gpb5","Gpb5",neurotransmitter_verified)) %>%
  493. dplyr::mutate(neurotransmitter_verified = gsub("hugin","Hug",neurotransmitter_verified)) %>%
  494. dplyr::mutate(neurotransmitter_verified = gsub("itp","ITP",neurotransmitter_verified)) %>%
  495. dplyr::mutate(neurotransmitter_verified = gsub("leucokinin","Lk",neurotransmitter_verified)) %>%
  496. dplyr::mutate(neurotransmitter_verified = gsub("MIP","Mip",neurotransmitter_verified)) %>%
  497. dplyr::mutate(neurotransmitter_verified = gsub("myosuppressin|myosupressin","Ms",neurotransmitter_verified)) %>%
  498. dplyr::mutate(neurotransmitter_verified = gsub("natalisin","Natalisin",neurotransmitter_verified)) %>%
  499. dplyr::mutate(neurotransmitter_verified = gsub("Nplp1","Nplp1",neurotransmitter_verified)) %>%
  500. dplyr::mutate(neurotransmitter_verified = gsub("Nplp2","Nplp2",neurotransmitter_verified)) %>%
  501. dplyr::mutate(neurotransmitter_verified = gsub("Nplp3","Nplp3",neurotransmitter_verified)) %>%
  502. dplyr::mutate(neurotransmitter_verified = gsub("Nplp4","Nplp4",neurotransmitter_verified)) %>%
  503. dplyr::mutate(neurotransmitter_verified = gsub("orcokinin","Orcokinin",neurotransmitter_verified)) %>%
  504. dplyr::mutate(neurotransmitter_verified = gsub("burisconin","Pburs",neurotransmitter_verified)) %>%
  505. dplyr::mutate(neurotransmitter_verified = gsub("pdf","Pdf",neurotransmitter_verified)) %>%
  506. dplyr::mutate(neurotransmitter_verified = gsub("proctolin","Proc",neurotransmitter_verified)) %>%
  507. dplyr::mutate(neurotransmitter_verified = gsub("ptth","Ptth",neurotransmitter_verified)) %>%
  508. dplyr::mutate(neurotransmitter_verified = gsub("ryanimide","RYa",neurotransmitter_verified)) %>%
  509. dplyr::mutate(neurotransmitter_verified = gsub("^sp$","SP",neurotransmitter_verified)) %>%
  510. dplyr::mutate(neurotransmitter_verified = gsub("SIFamide","SIFa",neurotransmitter_verified)) %>%
  511. dplyr::mutate(neurotransmitter_verified = gsub("sNPF","sNPF",neurotransmitter_verified)) %>%
  512. dplyr::mutate(neurotransmitter_verified = gsub("space blanket","Sb",neurotransmitter_verified)) %>%
  513. dplyr::mutate(neurotransmitter_verified = gsub("tachykinin","Tk",neurotransmitter_verified)) %>%
  514. dplyr::mutate(neurotransmitter_verified = gsub("trissin","Trissin",neurotransmitter_verified)) %>%
  515. dplyr::mutate(neurotransmitter_verified =
  516. ifelse(grepl("neuropeptide-negative|negative", neurotransmitter_verified, ignore.case = TRUE),
  517. NA, neurotransmitter_verified)) %>%
  518. # change nitric oxide to include _
  519. dplyr::mutate(neurotransmitter_verified = gsub("nitric oxide","nitric_oxide",neurotransmitter_verified)) %>%
  520. # save existing neuropeptide_verified, neurotransmitter_verified,
  521. # make additional updates to new columns banc_neuropeptide_verified and
  522. # banc_neurotransmitter_verified
  523. dplyr::mutate(banc_neuropeptide_verified = neuropeptide_verified) %>%
  524. # join with semicolons, remove duplicates
  525. dplyr::mutate(banc_neuropeptide_verified =
  526. sapply(banc_neuropeptide_verified, function(entry) {
  527. # Check if entry is empty or NA
  528. if (is.na(entry) || entry == "") {
  529. return(NA) # Return NA if the entry is empty or NA
  530. }
  531. # Otherwise, proceed to split the entry
  532. split_entries <- unlist(str_split(entry, "[ ,;]+")) %>%
  533. unique() # Remove duplicates
  534. # Join the unique entries with "; "
  535. paste(split_entries, collapse = "; ")
  536. })
  537. ) %>%
  538. dplyr::mutate(banc_neurotransmitter_verified = neurotransmitter_verified) %>%
  539. # clean up banc_neurotransmitter_verified column to remove neuropeptides and
  540. # notes about being negative for specific neurotransmitter
  541. dplyr::mutate(banc_neurotransmitter_verified = map_chr(
  542. str_split(banc_neurotransmitter_verified, "[,;]\\s*"),
  543. function(values) {
  544. # Filter to keep only the allowed neurotransmitters
  545. valid_values <- values[values %in% allowed_neurotransmitters]
  546. # Remove any empty values that might remain
  547. valid_values <- valid_values[valid_values != ""]
  548. # Remove duplicates
  549. unique_values <- unique(valid_values)
  550. # Join with semicolons
  551. if(length(unique_values) > 0) {
  552. paste(unique_values, collapse = "; ")
  553. } else {
  554. NA # Return NA if no valid neurotransmitters
  555. }
  556. }
  557. )) %>%
  558. #dplyr::rowwise() %>%
  559. #dplyr::mutate(neurotransmitter_verified = strsplit(neurotransmitter_verified,split=",")) %>%
  560. #dplyr::ungroup() %>%
  561. dplyr::mutate(super_class = dplyr::case_when(
  562. # not neurons
  563. cell_class %in% c('glia','putative_glia') ~ "glia",
  564. grepl("trachea",super_class) ~ "trachea",
  565. grepl("not_a_neuron|NOT_A_NEURON",super_class) ~ "not_a_neuron",
  566. # Neck
  567. cell_type == "SNpp54" ~"ventral_nerve_cord_sensory",
  568. grepl("^ISN$",cell_type) ~ "central_brain_sensory",
  569. super_class %in% c("descending") ~ "descending",
  570. super_class %in% c("ascending") ~ "ascending",
  571. super_class %in% c("sensory_ascending") ~ "sensory_ascending",
  572. grepl("ascending|descending", super_class) & grepl('sensory_descending', super_class) ~ "sensory_descending",
  573. grepl("ascending|descending", super_class) & grepl('sensory', super_class) ~ "sensory_ascending",
  574. grepl("ascending|descending", super_class) & grepl('efferent|motor|endocrine', super_class) ~ "ascending_visceral_circulatory",
  575. grepl("ascending|descending", super_class) & grepl('afferent', flow) ~ "sensory_ascending",
  576. super_class %in% c("sensory_descending") ~ "sensory_descending",
  577. super_class %in% c("visceral_circulatory_ascending") ~ "ascending_motor",
  578. super_class %in% c("efferent_ascending") ~ "efferent_ascending",
  579. super_class %in% c("efferent_descending") ~ "efferent_descending",
  580. # Afferent
  581. grepl("afferent",flow) ~ paste0(region,"_sensory"),
  582. grepl("sensory",flow) ~ paste0(region,"_sensory"),
  583. cell_type %in% "HBeyelet" ~ "optic_lobe_sensory",
  584. grepl("ocellar_retinula", cell_type) ~ "central_brain_sensory",
  585. grepl("^R1-6$|^R7$|^R8$", cell_type) ~ "optic_lobe_sensory",
  586. # efferent
  587. grepl("endocrine|visceral_circulatory",cell_class) ~ paste0(region,"_visceral_circulatory"),
  588. grepl("endocrine|visceral_circulatory",super_class) ~ paste0(region,"_visceral_circulatory"),
  589. grepl("endocrine|visceral_circulatory",cell_function) ~ paste0(region,"_visceral_circulatory"),
  590. grepl("motor",cell_class) ~ paste0(region,"_motor"),
  591. grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ paste0(region,"_motor"),
  592. grepl("motor",cell_function) ~ paste0(region,"_motor"),
  593. # optic transfer
  594. super_class %in% c("visual_centrifugal") ~ "visual_centrifugal",
  595. super_class %in% c("visual_projection") ~ "visual_projection",
  596. # intrinsic
  597. grepl("ocellar",cell_class) ~ "central_brain_intrinsic",
  598. grepl("midbrain|central_brain",region) ~ "central_brain_intrinsic",
  599. grepl("vnc|ventral_nerve_cord",region) ~ "ventral_nerve_cord_intrinsic",
  600. grepl("vnc|ventral_nerve_cord",super_class) ~ "ventral_nerve_cord_intrinsic",
  601. grepl("vnc|ventral_nerve_cord",cell_class) ~ "ventral_nerve_cord_intrinsic",
  602. grepl("optic",region) ~ "optic_lobe_intrinsic",
  603. super_class %in% c("optic") ~ "optic_lobe_intrinsic",
  604. grepl("central",flow) ~ "central_brain_intrinsic",
  605. grepl("central",super_class) ~ "central_brain_intrinsic",
  606. TRUE ~ "unknown"
  607. )) %>%
  608. # flow again
  609. dplyr::mutate(flow = dplyr::case_when(
  610. super_class=="ascending_sensory"&grepl("^SA",cell_type) ~ "afferent",
  611. super_class=="ascending$"&!grepl("^SA",cell_type) ~ "intrinsic",
  612. cell_type %in% "HBeyelet" ~ "afferent",
  613. grepl("ocellar_retinula", cell_type) ~ "afferent",
  614. # none get NA, as desired
  615. TRUE ~ flow
  616. ) ) %>%
  617. # peripheral_target_type
  618. dplyr::mutate(peripheral_target_type = dplyr::case_when(
  619. # pain
  620. grepl("SNch01|SNxx19|SNxx20|SNxx21",MANC_type) ~ "multidendritic", # class_iv
  621. grepl("nociception",cell_function) ~ "multidendritic",
  622. grepl("pharynx|cibarium",body_part_sensory)&(grepl("mechanosensory|tactile|pumping|ciberial",cell_function)|grepl("mechanosensory|tactile|pumping|ciberial",cell_function_detailed)) ~ "multidendritic",
  623. # taste
  624. grepl("taste peg",cell_sub_class) ~ "taste_peg",
  625. grepl("taste_peg",cell_sub_class) ~ "taste_peg",
  626. grepl("taste bristle",cell_sub_class) ~ "taste_peg",
  627. grepl("taste_bristle",cell_sub_class) ~ "taste_peg",
  628. grepl("taste_peg",cell_function_detailed) ~ "taste_peg",
  629. grepl("hair plate",cell_sub_class) ~ "hair_plate",
  630. grepl("eye_bristle",cell_sub_class) ~ "bristle",
  631. grepl("head_bristle",cell_sub_class) ~ "bristle",
  632. grepl("bristle",cell_function_detailed) ~ "bristle",
  633. grepl("bristle",cell_function_detailed) ~ "bristle",
  634. grepl("mechanosensory_bristle",cell_sub_class) ~ "bristle",
  635. grepl("bristle",body_part_sensory) ~ "bristle",
  636. grepl("^JO-",cell_type) ~ "chordotonal_organ",
  637. grepl("chordotonal",cell_type) ~ "chordotonal_organ",
  638. grepl("chordotonal",cell_sub_class) ~ "chordotonal_organ",
  639. grepl("chordotonal",cell_function) ~ "chordotonal_organ",
  640. grepl("DNx01",cell_type) ~ "campaniform_sensillum",
  641. grepl("campaniform",cell_sub_class) ~ "campaniform_sensillum",
  642. grepl("campaniform",cell_function_detailed) ~ "campaniform_sensillum",
  643. grepl("campaniform",cell_function) ~ "campaniform_sensillum",
  644. # hemolymph
  645. grepl("haemolymph|hemolymph",body_part_sensory) ~ "nutrient_receptor",
  646. # both
  647. grepl("taste peg",cell_function_detailed) ~ "taste_peg",
  648. grepl("taste_peg",cell_function_detailed) ~ "taste_peg",
  649. grepl("taste_peg",cell_sub_class) ~ "taste_peg",
  650. grepl("bristle",cell_function_detailed) ~ "bristle",
  651. grepl("bristle",cell_sub_class) ~ "bristle",
  652. grepl("hair_plate",cell_function_detailed) ~ "hair_plate",
  653. grepl("hair_plate",cell_sub_class) ~ "hair_plate",
  654. grepl("taste peg",cell_function) ~ "taste_peg",
  655. grepl("taste_peg",cell_function) ~ "taste_peg",
  656. grepl("bristle",cell_function) ~ "bristle",
  657. grepl("bristle",cell_sub_class) ~ "bristle",
  658. grepl("hair_plate",cell_function) ~ "hair_plate",
  659. # from MANC
  660. grepl("campaniform sensilla",MANC_receptorType) ~ "campaniform_sensillum",
  661. grepl("chordotonal",MANC_receptorType) ~ "chordotonal_organ",
  662. grepl("chordotonal",cell_function_detailed) ~ "chordotonal_organ",
  663. grepl("hair plate",MANC_receptorType) ~ "hair_plate",
  664. grepl("putative sweet taste bristle",MANC_receptorType) ~ "taste_peg",
  665. grepl("sweet taste bristle",MANC_receptorType) ~ "taste_peg",
  666. grepl("taste bristle",MANC_receptorType) ~ "taste_peg",
  667. grepl("strand receptor",MANC_receptorType) ~ "strand",
  668. grepl("taste bristle",MANC_receptorType) ~ "taste_peg",
  669. # visual
  670. grepl("ocellar retinula",FAFB_cell_type) ~ "photoreceptor",
  671. grepl("ocellar_retinula",cell_type) ~ "photoreceptor",
  672. grepl("^R1-6|^R1-6|^R7|^R8",cell_type) ~ "photoreceptor",
  673. grepl("^R1-6|^R1-6|^R7|^R8",cell_type) ~ "photoreceptor",
  674. grepl("^HBeyelet",cell_type) ~ "photoreceptor",
  675. grepl("^HBeyelet",cell_type) ~ "photoreceptor",
  676. # from FAFB
  677. grepl("^ORN",cell_type)&cell_function=="olfactory" ~ "olfactory_sensillum",
  678. grepl("^TRN",cell_type)&cell_function=="thermosensory" ~ "thermosensory_sensillum",
  679. grepl("^HRN",cell_type)&cell_function=="hygrosensory" ~ "hygrosensory_sensillum",
  680. grepl("AC neuron|AC_neuron|ac_neuron",cell_type) ~ "internal_thermosensory_receptor",
  681. grepl("leg",body_part_sensory)&grepl("chemosensory|gustatory",cell_function) ~ "taste_peg",
  682. grepl("labellum",body_part_sensory)&grepl("chemosensory|gustatory",cell_function) ~ "external_taste_sensillum",
  683. grepl("abdomen",body_part_sensory)&grepl("chemosensory|gustatory",cell_function) ~ "external_taste_sensillum",
  684. grepl("pharynx|crop",body_part_sensory)&grepl("chemosensory|gustatory",cell_function) ~ "internal_taste_sensillum",
  685. grepl("wing_margin",body_part_sensory)&grepl("chemosensory|gustatory",cell_function) ~ "taste_sensillum",
  686. grepl("sensory",super_class) ~ "orphan",
  687. # motor
  688. # leg muscles - from MANC (note, subtle differences from FANC)
  689. grepl("Acc._ti_flexor", cell_class) ~ "accessory_tibia_flexor_muscle",
  690. grepl("Fe_reductor", cell_class) ~ "femur_reductor_muscle",
  691. grepl("ltm1-tibia", cell_class) ~ "long_tendon_muscle_1",
  692. grepl("ltm2-femur", cell_class) ~ "long_tendon_muscle_2",
  693. grepl("ltm", cell_class) ~ "long_tendon_muscle",
  694. grepl("Pleural_remotor/abductor", cell_class) ~ "pleural_remotor_and_abductor_muscle",
  695. grepl("Sternal_adductor", cell_class) ~ "sternal_adductor_muscle",
  696. grepl("Sternal_anterior_rotator", cell_class) ~ "sternal_anterior_rotator_muscle",
  697. grepl("Sternal_posterior_rotator", cell_class) ~ "sternal_posterior_rotator_muscle",
  698. grepl("Sternotrochanter", cell_class) ~ "sternotrochanter_extensor_muscle",
  699. grepl("Ta_depressor", cell_class) ~ "tarsus_depressor_muscle",
  700. grepl("Ta_levator", cell_class) ~ "tarsus_levator_muscle",
  701. grepl("Tergopleural/Pleural_promotor", cell_class) ~ "tergopleural_or_pleural_promotor_muscle",
  702. grepl("Tergotr.", cell_class) ~ "tergotrochanter_extensor_muscle",
  703. grepl("Ti_extensor", cell_class) ~ "tibia_extensor_muscle",
  704. grepl("Ti_flexor", cell_class) ~ "tibia_flexor_muscle",
  705. grepl("Tr_extensor", cell_class) ~ "trochanter_extensor_muscle",
  706. grepl("Tr_flexor", cell_class) ~ "trochanter_flexor_muscle",
  707. grepl("leg_motor", cell_function) ~ "leg_muscle",
  708. # wing muscles - from MANC (note, subtle differences from FANC)
  709. grepl("b1_motor_neuron", cell_class) ~ "b1_muscle",
  710. grepl("b2_motor_neuron", cell_class) ~ "b2_muscle",
  711. grepl("b3_motor_neuron", cell_class) ~ "b3_muscle",
  712. grepl("^DLM", cell_class) ~ "dorsal_longitudinal_muscle",
  713. grepl("^DVM", cell_class) ~ "dorsoventral_muscle",
  714. grepl("^hg1_motor_neuron", cell_class) ~ "iv1_muscle",
  715. grepl("^hg2_motor_neuron", cell_class) ~ "iv2_muscle",
  716. grepl("^hg3_motor_neuron", cell_class) ~ "iv3_muscle",
  717. grepl("^hg4_motor_neuron", cell_class) ~ "iv4_muscle",
  718. grepl("^i1_motor_neuron", cell_class) ~ "i1_muscle",
  719. grepl("^i2_motor_neuron", cell_class) ~ "i2_muscle",
  720. grepl("^iii1_motor_neuron", cell_class) ~ "iii1_muscle",
  721. grepl("^iii3_motor_neuron", cell_class) ~ "iii2_muscle",
  722. grepl("^ps1_motor_neuron", cell_class) ~ "ps1_muscle",
  723. grepl("^ps2_motor_neuron", cell_class) ~ "ps2_muscle",
  724. grepl("^tp1_motor_neuron", cell_class) ~ "tp1_muscle",
  725. grepl("^tp2_motor_neuron", cell_class) ~ "tp2_muscle",
  726. grepl("^tp_motor_neuron", cell_class) ~ "tergopleural_muscle",
  727. grepl("^TTM_motor_neuron", cell_class) ~ "trochanter_extensor_muscle",
  728. ((grepl("wing", body_part_effector) & grepl("motor", super_class)) |
  729. (grepl("wing_motor_neuron", cell_class))) ~ "wing_muscle",
  730. # haltere muscles - from MANC
  731. grepl("^hDVM_motor_neuron", cell_class) ~ "haltere_dorsoventral_muscle",
  732. grepl("^hi1_motor_neuron", cell_class) ~ "hi1_muscle",
  733. grepl("^hi2_motor_neuron", cell_class) ~ "hi2_muscle",
  734. grepl("^hiii2_motor_neuron", cell_class) ~ "hiii2_muscle",
  735. grepl("haltere_motor_neuron", cell_class) ~ "haltere_direct_control_muscle",
  736. # neck muscles - from MANC
  737. grepl("^CvN_A1$", cell_type) ~ "transverse_horizontal_1_muscle",
  738. grepl("^CvN_A2$", cell_type) ~ "transverse_horizontal_2_muscle",
  739. (grepl("^FNM2$", cell_type) & grepl("AD_motor_neuron", cell_class)) ~ "adductor_muscle",
  740. grepl("neck_motor_neuron", cell_class) ~ "neck_muscle",
  741. # antenna muscles - from FAFB (specific muscle targets unknown)
  742. grepl("antennal_motor_neuron", cell_class) ~ "antenna_muscle",
  743. # retina muscles - from FAFB (specific muscle targets unknown)
  744. grepl("eye_motor_neuron", cell_class) ~ "retina_muscle",
  745. # proboscis muscles (specific muscle targets unknown)
  746. (grepl("proboscis_motor_neuron", cell_class) | grepl("proboscis", body_part_effector)) ~ "proboscis_muscle",
  747. # pharynx muscles (specific muscle targets unknown)
  748. grepl("pharynx", body_part_effector) ~ "pharynx_muscle",
  749. # proboscis muscles (specific muscle targets unknown)
  750. grepl("proboscis_motor_neuron", cell_class) ~ "proboscis_muscle",
  751. # salivary muscle
  752. grepl("salivary_motor_neuron", cell_class) ~ "m13_muscle",
  753. # crop
  754. grepl("crop_motor_neuron", cell_class) ~ "crop_muscle",
  755. # remainder
  756. TRUE ~ NA
  757. ) ) %>%
  758. dplyr::mutate(cell_function_detailed = dplyr::case_when(
  759. # gustatory
  760. grepl("sugar_or_water",cell_function)|grepl("sugar_or_water",cell_function_detailed) ~ "sweet_or_water",
  761. grepl("putative sweet taste bristle",MANC_receptorType) ~ "sweet",
  762. grepl("sweet taste bristle",MANC_receptorType) ~ "sweet",
  763. grepl("sweet taste bristle",MANC_receptorType) ~ "sweet",
  764. grepl("sugar",cell_function)|grepl("sugar",cell_function_detailed) ~ "sweet",
  765. grepl("sweet",cell_function)|grepl("sweet",cell_function_detailed) ~ "sweet",
  766. grepl("water",cell_function)|grepl("water",cell_function_detailed)|grepl("water",cell_sub_class) ~ "water",
  767. grepl("bitter",cell_function)|grepl("bitter",cell_function_detailed)|grepl("bitter",cell_sub_class) ~ "bitter",
  768. grepl("low_salt",cell_function)|grepl("low_salt",cell_function_detailed)|grepl("low_salt",cell_sub_class) ~ "low_salt",
  769. grepl("pheromone_contact",cell_function)|grepl("pheromone_contact",cell_function_detailed) ~ "pheromone_contact",
  770. grepl("gustatory",cell_function)&grepl("pheromone",cell_function_detailed) ~ "pheromone_contact",
  771. grepl("chemosensory",cell_function)&grepl("pheromone",cell_function_detailed) ~ "pheromone_contact",
  772. # olfactory --add
  773. grepl("^ORN_VL2p$",cell_type)&cell_function=="olfactory" ~ "alcoholic_fermentation_volatile",
  774. grepl("^ORN_DL5$",cell_type)&cell_function=="olfactory" ~ "alcoholic_fermentation_volatile",
  775. grepl("^ORN_DM2$",cell_type)&cell_function=="olfactory" ~ "alcoholic_fermentation_volatile",
  776. grepl("^ORN_VM7d$",cell_type)&cell_function=="olfactory" ~ "alcoholic_fermentation_volatile",
  777. grepl("^ORN_VM3$",cell_type)&cell_function=="olfactory" ~ "alcoholic_fermentation_volatile",
  778. grepl("^ORN_VA2$",cell_type)&cell_function=="olfactory" ~ "alcoholic_fermentation_volatile",
  779. grepl("^ORN_DP1m$",cell_type)&cell_function=="olfactory" ~ "alcoholic_fermentation_volatile",
  780. grepl("^ORN_DP1l$",cell_type)&cell_function=="olfactory" ~ "alcoholic_fermentation_volatile",
  781. grepl("^ORN_VC4$",cell_type)&cell_function=="olfactory" ~ "alcoholic_fermentation_volatile",
  782. grepl("^ORN_V$",cell_type)&cell_function=="olfactory" ~ "carbon_dioxide_volatile",
  783. grepl("^ORN_DM1$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  784. grepl("^ORN_DM4$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  785. grepl("^ORN_VM7d$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  786. grepl("^ORN_VM5v$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  787. grepl("^ORN_DM3$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  788. grepl("^ORN_VA3$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  789. grepl("^ORN_VA4$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  790. grepl("^ORN_VC2$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  791. grepl("^ORN_DM1$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  792. grepl("^ORN_VA3$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  793. grepl("^ORN_VA6$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  794. grepl("^ORN_DM5$",cell_type)&cell_function=="olfactory" ~ "yeasty_volatile",
  795. grepl("^ORN_DM3$",cell_type)&cell_function=="olfactory" ~ "fruity_volatile",
  796. grepl("^ORN_VA3$",cell_type)&cell_function=="olfactory" ~ "fruity_volatile",
  797. grepl("^ORN_VM5v$",cell_type)&cell_function=="olfactory" ~ "fruity_volatile",
  798. grepl("^ORN_DM2$",cell_type)&cell_function=="olfactory" ~ "fruity_volatile",
  799. grepl("^ORN_VM2$",cell_type)&cell_function=="olfactory" ~ "fruity_volatile",
  800. grepl("^ORN_VM5d$",cell_type)&cell_function=="olfactory" ~ "fruity_volatile",
  801. grepl("^ORN_DL1$",cell_type)&cell_function=="olfactory" ~ "fruity_volatile",
  802. grepl("^ORN_DA3$",cell_type)&cell_function=="olfactory" ~ "fruity_volatile",
  803. grepl("^ORN_DL2d$",cell_type)&cell_function=="olfactory" ~ "decaying_fruit_volatile",
  804. grepl("^ORN_DL2v$",cell_type)&cell_function=="olfactory" ~ "decaying_fruit_volatile",
  805. grepl("^ORN_VC5$",cell_type)&cell_function=="olfactory" ~ "decaying_fruit_volatile",
  806. grepl("^ORN_VL2a$",cell_type)&cell_function=="olfactory" ~ "decaying_fruit_volatile",
  807. grepl("^ORN_VM4$",cell_type)&cell_function=="olfactory" ~ "decaying_fruit_volatile",
  808. grepl("^ORN_VL1$",cell_type)&cell_function=="olfactory" ~ "decaying_fruit_volatile",
  809. grepl("^ORN_VM1$",cell_type)&cell_function=="olfactory" ~ "decaying_fruit_volatile",
  810. grepl("^ORN_VA1v$",cell_type)&cell_function=="olfactory" ~ "pheromone_volatile",
  811. grepl("^ORN_VA1d$",cell_type)&cell_function=="olfactory" ~ "pheromone_volatile",
  812. grepl("^ORN_DA1$",cell_type)&cell_function=="olfactory" ~ "pheromone_volatile",
  813. grepl("^ORN_DL3$",cell_type)&cell_function=="olfactory" ~ "pheromone_volatile",
  814. grepl("^ORN_DC3$",cell_type)&cell_function=="olfactory" ~ "pheromone_volatile",
  815. grepl("^ORN_DA2$",cell_type)&cell_function=="olfactory" ~ "aversive_volatile",
  816. grepl("^ORN_DM3$",cell_type)&cell_function=="olfactory" ~ "aversive_volatile",
  817. grepl("^ORN_DC1$",cell_type)&cell_function=="olfactory" ~ "aversive_volatile",
  818. grepl("^ORN_DL5$",cell_type)&cell_function=="olfactory" ~ "aversive_volatile",
  819. grepl("^ORN_DL4$",cell_type)&cell_function=="olfactory" ~ "aversive_volatile",
  820. grepl("^ORN_DC4$",cell_type)&cell_function=="olfactory" ~ "aversive_volatile",
  821. grepl("^ORN_VC3$",cell_type)&cell_function=="olfactory" ~ "aversive_volatile",
  822. grepl("^ORN_DC2$",cell_type)&cell_function=="olfactory" ~ "plant_matter_volatile",
  823. grepl("^ORN_VC1$",cell_type)&cell_function=="olfactory" ~ "plant_matter_volatile",
  824. grepl("^ORN_VA5$",cell_type)&cell_function=="olfactory" ~ "animal_matter_volatile",
  825. grepl("^ORN_VA7l$",cell_type)&cell_function=="olfactory" ~ "animal_matter_volatile",
  826. grepl("co2|carbon_dioxide",cell_function)|grepl("co2|carbon_dioxide",cell_function_detailed) ~ "carbon_dioxide",
  827. grepl("pheromone_volatile",cell_function)|grepl("pheromone_volatile",cell_function_detailed) ~ "pheromone_volatile",
  828. grepl("olfactory",cell_function)&grepl("pheromone",cell_function_detailed) ~ "pheromone_volatile",
  829. # thermosensory
  830. grepl("TRN_VP1",cell_type) ~ "evaporation",
  831. grepl("TRN_VP2",cell_type) ~ "heating",
  832. grepl("TRN_VP3",cell_type) ~ "cooling",
  833. grepl("HRN_VP4",cell_type) ~ "dry",
  834. grepl("HRN_VP5",cell_type) ~ "humid",
  835. grepl("heating",cell_sub_class) ~ "heating",
  836. grepl("cooling",cell_sub_class) ~ "cooling",
  837. grepl("humid",cell_sub_class) ~ "humid",
  838. grepl("dry",cell_sub_class) ~ "dry",
  839. # mechanosensory
  840. ### chordotonal
  841. grepl("JO-A",cell_type) ~ "auditory_low_frequency",
  842. grepl("JO-B",cell_type) ~ "auditory_high_frequency",
  843. grepl("JO-C",cell_type) ~ "direction",
  844. grepl("JO-D",cell_type) ~ "position",
  845. grepl("JO-E",cell_type) ~ "position",
  846. grepl("JO-F",cell_type) ~ "position",
  847. grepl("chordotonal_club|club_chordotonal",cell_function_detailed)|grepl("club",cell_sub_class) ~ "vibro_tactile",
  848. grepl("chordotonal_claw|claw_chordotonal",cell_function_detailed)|grepl("claw",cell_sub_class) ~ "position",
  849. grepl("chordotonal_hook|hook_chordotonal",cell_function_detailed)|grepl("hook",cell_sub_class) ~ "direction",
  850. grepl("club",cell_sub_class) ~ "vibro_tactile",
  851. grepl("claw",cell_sub_class) ~ "position",
  852. grepl("hook",cell_sub_class) ~ "direction",
  853. grepl("vibro-tactile|vibro_tactile",cell_function)|grepl("vibro-tactile|vibro_tactile",cell_function_detailed) ~ "vibro_tactile",
  854. grepl("vibration",cell_function)|grepl("vibration",cell_function_detailed) ~ "vibration",
  855. grepl("position",cell_function)|grepl("position",cell_function_detailed) ~ "position",
  856. grepl("stretch",cell_function)|grepl("stretch",cell_function_detailed) ~ "stretch",
  857. grepl("deflection",cell_function)|grepl("deflection",cell_function_detailed) ~ "deflection",
  858. ### other
  859. grepl("_bristle",cell_function_detailed) ~ cell_function_detailed,
  860. grepl("campaniform",peripheral_target_type) ~ "mechanical_strain",
  861. grepl("hair_plate",peripheral_target_type) ~ "joint_angle",
  862. grepl("chordotonal",peripheral_target_type) ~ "vibro_position",
  863. ### putative pump
  864. grepl("ciberial",cell_function)|grepl("ciberial",cell_function_detailed) ~ "contractile",
  865. grepl("pumping",cell_function)|grepl("pumping",cell_function_detailed) ~ "contractile",
  866. grepl("ciberial",cell_function)|grepl("ciberial",cell_function_detailed) ~ "contractile",
  867. grepl("CB0991",cell_type) ~ "contractile",
  868. # respiratory
  869. grepl("oxygenation",cell_function)|grepl("oxygenation",cell_function_detailed) ~ "oxygenation",
  870. grepl("respiratory",cell_function)|grepl("respiratory",cell_function_detailed) ~ "respiratory",
  871. # interoceptive
  872. grepl("interoceptive",cell_function)|grepl("interoceptive",cell_function_detailed)|grepl("^ISN",cell_type) ~ "interoceptive",
  873. grepl("AC neuron|AC_neuron|ac_neuron",cell_type) ~ "internal_thermosensory",
  874. # motor related
  875. # leg
  876. grepl("Acc._ti_flexor", cell_class) ~ "flex_femur_tibia_joint",
  877. grepl("Fe_reductor", cell_class) ~ "unknown_leg_movement",
  878. grepl("ltm1-tibia", cell_class) ~ "pull_long_tendon",
  879. grepl("ltm2-femur", cell_class) ~ "pull_long_tendon",
  880. grepl("ltm", cell_class) ~ "pull_long_tendon",
  881. grepl("Pleural_remotor/abductor", cell_class) ~ "move_coxa_posterior_lateral",
  882. grepl("Sternal_adductor", cell_class) ~ "move_coxa_medial",
  883. grepl("Sternal_anterior_rotator", cell_class) ~ "move_coxa_anterior",
  884. grepl("Sternal_posterior_rotator", cell_class) ~ "move_coxa_posterior",
  885. grepl("Sternotrochanter", cell_class) ~ "extend_coxa_trochanter_joint",
  886. grepl("Ta_depressor", cell_class) ~ "extend_tibia_tarsus_joint",
  887. grepl("Ta_levator", cell_class) ~ "flex_tibia_tarsus_joint",
  888. grepl("Tergopleural/Pleural_promotor", cell_class) ~ "move_coxa_anterior",
  889. grepl("Tergotr.", cell_class) ~ "extend_coxa_trochanter_joint",
  890. grepl("Ti_extensor", cell_class) ~ "extend_femur_tibia_joint",
  891. grepl("Ti_flexor", cell_class) ~ "flex_femur_tibia_joint",
  892. grepl("Tr_extensor", cell_class) ~ "extend_coxa_trochanter_joint",
  893. grepl("Tr_flexor", cell_class) ~ "flex_coxa_trochanter_joint",
  894. grepl("leg_motor", cell_function) ~ "unknown_leg_movement",
  895. # wing - from MANC (note, subtle differences from FANC)
  896. grepl("^b1_motor_neuron", cell_class) ~ "tonic_wing_steering",
  897. grepl("^b2_motor_neuron", cell_class) ~ "phasic_wing_steering",
  898. grepl("^b3_motor_neuron", cell_class) ~ "tonic_wing_steering",
  899. grepl("^DLM", cell_class) ~ "wing_power",
  900. grepl("^DVM", cell_class) ~ "wing_power",
  901. grepl("hg1_motor_neuron", cell_class) ~ "phasic_wing_steering",
  902. grepl("hg2_motor_neuron", cell_class) ~ "phasic_wing_steering",
  903. grepl("hg3_motor_neuron", cell_class) ~ "phasic_wing_steering",
  904. grepl("hg4_motor_neuron", cell_class) ~ "tonic_wing_steering",
  905. grepl("^i1_motor_neuron", cell_class) ~ "phasic_wing_steering",
  906. grepl("^i2_motor_neuron", cell_class) ~ "tonic_wing_steering",
  907. grepl("^iii1_motor_neuron", cell_class) ~ "phasic_wing_steering",
  908. grepl("^iii3_motor_neuron", cell_class) ~ "unknown_wing_steering",
  909. grepl("^ps1_motor_neuron", cell_class) ~ "wing_tension",
  910. grepl("^ps2_motor_neuron", cell_class) ~ "wing_tension",
  911. grepl("^tp1_motor_neuron", cell_class) ~ "wing_tension",
  912. grepl("^tp2_motor_neuron", cell_class) ~ "wing_tension",
  913. grepl("^tp_motor_neuron", cell_class) ~ "wing_tension",
  914. grepl("^TTM_motor_neuron", cell_class) ~ "middle_leg_extension",
  915. # haltere muscles - from MANC
  916. grepl("hDVM_motor_neuron", cell_class) ~ "haltere_power",
  917. grepl("hi1_motor_neuron", cell_class) ~ "haltere_steering",
  918. grepl("hi2_motor_neuron", cell_class) ~ "haltere_steering",
  919. grepl("hiii2_motor_neuron", cell_class) ~ "haltere_steering",
  920. grepl("haltere_motor_neuron", cell_class) ~ "unknown_haltere",
  921. # visceral_circulatory - neuropeptide(s) for identified neurons (by Meet)
  922. grepl("^m_NSC_DILP$", cell_type) ~ banc_neuropeptide_verified,
  923. grepl("^m_NSC_DH44$", cell_type) ~ banc_neuropeptide_verified,
  924. (grepl("^ventral_nerve_cord_visceral_circulatory$", super_class) &
  925. grepl("Dh44", banc_neuropeptide_verified) &
  926. grepl("Lk", banc_neuropeptide_verified)) ~ banc_neuropeptide_verified,
  927. grepl("^m_NSC_DMS$", cell_type) ~ banc_neuropeptide_verified,
  928. grepl("^l_NSC_ITP$", cell_type) ~ banc_neuropeptide_verified,
  929. grepl("^l_NSC_CRZ$", cell_type) ~ banc_neuropeptide_verified,
  930. grepl("^l_NSC_DH31$", cell_type) ~ banc_neuropeptide_verified,
  931. grepl("^SEZ_NSC_Hugin$", cell_type) ~ banc_neuropeptide_verified,
  932. grepl("^SEZ_NSC_CAPA$", cell_type) ~ banc_neuropeptide_verified,
  933. grepl("^ENXXX012$", cell_type) ~ banc_neuropeptide_verified,
  934. grepl("^EN27X010$", cell_type) ~ banc_neuropeptide_verified,
  935. # for remainder, wipe cell_function_detailed from visceral_circulatory neurons
  936. grepl("visceral_circulatory", super_class) ~ NA,
  937. # remainder
  938. cell_function_detailed=="NA" ~ NA,
  939. is.na(cell_function_detailed) ~ cell_function_detailed,
  940. TRUE ~ cell_function_detailed
  941. ) ) %>%
  942. dplyr::mutate(cell_function = dplyr::case_when(
  943. grepl("CB0991",cell_type) ~ "aorta",
  944. # gustatory
  945. grepl("taste_peg",peripheral_target_type) ~ "gustatory_tactile",
  946. grepl("sensory",super_class) & cell_type=='TPMN' ~ "gustatory_tactile",
  947. grepl("bitter",cell_function)|grepl("bitter",cell_function_detailed) ~ "gustatory",
  948. grepl("sugar_or_water",cell_function)|grepl("sugar_or_water",cell_function_detailed) ~ "gustatory",
  949. grepl("sugar",cell_function)|grepl("sugar",cell_function_detailed) ~ "gustatory",
  950. grepl("water",cell_function)|grepl("water",cell_function_detailed) ~ "gustatory",
  951. grepl("pheromone_contact",cell_function)|grepl("pheromone_contact",cell_function_detailed) ~ "gustatory",
  952. grepl("pheromone_contact",cell_function)|grepl("low_salt",cell_function_detailed) ~ "gustatory",
  953. grepl("chemosensory|gustatory",cell_function) ~ "gustatory",
  954. grepl("chemosensory|gustatory",cell_function_detailed) ~ "gustatory",
  955. grepl("sensory",super_class) & grepl("^SA_VTV_",cell_type) ~ "gustatory",
  956. # olfactory
  957. grepl("co2|carbon_dioxide",cell_function)|grepl("co2|carbon_dioxide",cell_function_detailed) ~ "olfactory",
  958. grepl("pheromone_volatile",cell_function)|grepl("pheromone_volatile",cell_function_detailed) ~ "olfactory",
  959. grepl("olfactory",cell_function) ~ "olfactory",
  960. # thermosensory
  961. grepl("thermosensory",cell_function) ~ "thermosensory",
  962. grepl("^TRN",cell_type) ~ "thermosensory",
  963. grepl("hygrosensory",cell_function) ~ "hygrosensory",
  964. grepl("^HRN",cell_type) ~ "hygrosensory",
  965. # mechanosensory
  966. grepl("JO-",cell_type) ~ "proprioception",
  967. grepl("vibro-tactile|vibro_tactile",cell_function)|grepl("vibro-tactile|vibro_tactile",cell_function_detailed) ~ "proprioception",
  968. grepl("proprioception|proprioceptive",cell_function)|grepl("proprioception|proprioceptive",cell_function_detailed) ~ "proprioception",
  969. grepl("vibration",cell_function)|grepl("vibration",cell_function_detailed) ~ "proprioception",
  970. grepl("position",cell_function)|grepl("position",cell_function_detailed) ~ "proprioception",
  971. grepl("stretch",cell_function)|grepl("stretch",cell_function_detailed) ~ "proprioception",
  972. grepl("campaniform|hair_plate|chordotonal",peripheral_target_type) ~ "proprioception",
  973. ### bristle
  974. grepl("^tactile$",cell_function)|grepl("^tactile$",cell_function_detailed) ~ "tactile",
  975. grepl("mechanosensory|bristle",cell_function) ~ "tactile",
  976. grepl("bristle",peripheral_target_type) ~ "tactile",
  977. ### nociception
  978. grepl("nociception",cell_function)|grepl("nociception",cell_function_detailed) ~ "putative_nociception",
  979. ### contractile
  980. grepl("ciberial",cell_function)|grepl("ciberial",cell_function_detailed) ~ "contractile",
  981. grepl("pumping",cell_function)|grepl("pumping",cell_function_detailed) ~ "contractile",
  982. # visual
  983. cell_type %in% "R1-6" ~ "visual_achromatic",
  984. cell_type %in% c("L1","L2","L3","L4","L5") ~ "visual_achromatic",
  985. cell_type %in% "HBeyelet" ~ "visual_achromatic",
  986. cell_type %in% c("R7","R8") ~ "visual_chromatic",
  987. (grepl("^DmDRA", cell_type)) ~ "visual_polarized_light",
  988. grepl("ocellar",cell_function)|grepl("ocellar",cell_function_detailed) ~ "visual_ocellar",
  989. grepl("ocellar_retinula_cell",cell_type) ~ "visual_ocellar",
  990. grepl("^OCG",cell_type) ~ "visual_ocellar",
  991. grepl("visual_chromatic",cell_function)|grepl("visual_chromatic",cell_function_detailed) ~ "visual_chromatic",
  992. grepl("visual_achromatic",cell_function)|grepl("visual_achromatic",cell_function_detailed) ~ "visual_achromatic",
  993. grepl("ocellar",cell_function)|grepl("ocellar",cell_function_detailed) ~ "visual_ocellar",
  994. # respiratory
  995. grepl("oxygenation",cell_function)|grepl("oxygenation",cell_function_detailed) ~ "oxygenation",
  996. grepl("respiratory",cell_function)|grepl("respiratory",cell_function_detailed) ~ "respiratory",
  997. # interoceptive
  998. grepl("interoceptive",cell_function)|grepl("interoceptive",cell_function_detailed)|grepl("^ISN",cell_type) ~ "interoceptive",
  999. grepl("AC neuron",cell_type) ~ "thermosensory",
  1000. # motor
  1001. # leg
  1002. grepl("leg_motor", cell_function) ~ "leg_motor",
  1003. # wing muscles
  1004. grepl("b1_motor_neuron", cell_class) ~ "wing_steering",
  1005. grepl("b2_motor_neuron", cell_class) ~ "wing_steering",
  1006. grepl("b3_motor_neuron", cell_class) ~ "wing_steering",
  1007. grepl("^DLM", cell_class) ~ "wing_power",
  1008. grepl("^DVM", cell_class) ~ "wing_power",
  1009. grepl("^hg1_motor_neuron", cell_class) ~ "wing_steering",
  1010. grepl("^hg2_motor_neuron", cell_class) ~ "wing_steering",
  1011. grepl("^hg3_motor_neuron", cell_class) ~ "wing_steering",
  1012. grepl("^hg4_motor_neuron", cell_class) ~ "wing_steering",
  1013. grepl("^i1_motor_neuron", cell_class) ~ "wing_steering",
  1014. grepl("^i2_motor_neuron", cell_class) ~ "wing_steering",
  1015. grepl("^iii1_motor_neuron", cell_class) ~ "wing_steering",
  1016. grepl("^iii3_motor_neuron", cell_class) ~ "wing_steering",
  1017. grepl("^ps1_motor_neuron", cell_class) ~ "wing_tension",
  1018. grepl("^ps2_motor_neuron", cell_class) ~ "wing_tension",
  1019. grepl("^tp1_motor_neuron", cell_class) ~ "wing_tension",
  1020. grepl("^tp2_motor_neuron", cell_class) ~ "wing_tension",
  1021. grepl("^tp_motor_neuron", cell_class) ~ "wing_tension",
  1022. grepl("^TTM_motor_neuron", cell_class) ~ "jump_escape",
  1023. ((grepl("wing", body_part_effector) & grepl("motor", super_class)) |
  1024. (grepl("wing_motor_neuron", cell_class))) ~ "unknown_wing_motor",
  1025. # haltere
  1026. grepl("^hDVM_motor_neuron", cell_class) ~ "haltere_power",
  1027. grepl("^hi1_motor_neuron", cell_class) ~ "haltere_steering",
  1028. grepl("^hi2_motor_neuron", cell_class) ~ "haltere_steering",
  1029. grepl("^hiii2_motor_neuron", cell_class) ~ "haltere_steering",
  1030. grepl("haltere_motor_neuron", cell_class) ~ "unknown_haltere_motor",
  1031. # neck - from MANC
  1032. grepl("neck_motor_neuron", cell_class) ~ "neck_motor",
  1033. grepl("neck_motor_neuron", cell_sub_class) ~ "neck_motor",
  1034. # antenna
  1035. grepl("antennal_motor_neuron", cell_class) ~ "antenna_motor",
  1036. # retina
  1037. grepl("eye_motor_neuron", cell_class) ~ "retina_motor",
  1038. # proboscis
  1039. (grepl("proboscis_motor_neuron", cell_class) | grepl("proboscis", body_part_effector)) ~ "proboscis_motor",
  1040. # pharynx
  1041. grepl("pharynx", body_part_effector) ~ "pharynx_motor",
  1042. # proboscis muscles (specific muscle targets unknown)
  1043. grepl("proboscis_motor_neuron", cell_class) ~ "proboscis_motor",
  1044. # salivary
  1045. grepl("salivary_motor_neuron", cell_class) ~ "salivary_motor",
  1046. # crop
  1047. grepl("crop_motor_neuron", cell_class) ~ "crop_motor",
  1048. # visceral_circulatory - functions defined by Meet
  1049. grepl("^m_NSC_DILP$", cell_type) ~ "energy_metabolism; food_intake",
  1050. grepl("^m_NSC_DH44$", cell_type) ~
  1051. "diuresis; food_intake; energy_metabolism; post_mating_responses",
  1052. (grepl("^ventral_nerve_cord_visceral_circulatory$", super_class) &
  1053. grepl("Dh44", banc_neuropeptide_verified) &
  1054. grepl("Lk", banc_neuropeptide_verified)) ~
  1055. "diuresis; stress_tolerance; pain_threshold",
  1056. grepl("^m_NSC_DMS$", cell_type) ~ "food_intake",
  1057. grepl("^l_NSC_ITP$", cell_type) ~
  1058. "hormone_regulation; stress_tolerance; energy_metabolism; osmotic_balance",
  1059. grepl("^l_NSC_CRZ$", cell_type) ~
  1060. "cardiostimulation; energy_metabolism; stress_tolerance; hormone_regulation",
  1061. grepl("^l_NSC_DH31$", cell_type) ~
  1062. "diuresis; gut_motility; hormone_regulation",
  1063. grepl("^SEZ_NSC_CAPA$", cell_type) ~ "anti_diuresis; stress_tolerance",
  1064. grepl("^ENXXX012$", cell_type) ~
  1065. "anti_diuresis; stress_tolerance; energy_metabolism",
  1066. grepl("^EN27X010$", cell_type) ~ "myomodulation; energy_metabolism",
  1067. # remainder
  1068. TRUE ~ NA
  1069. ) ) %>%
  1070. dplyr::mutate(cell_function_detailed = dplyr::case_when(
  1071. cell_function == cell_function_detailed ~ NA,
  1072. TRUE ~ cell_function_detailed
  1073. )) %>%
  1074. dplyr::mutate(cell_class = dplyr::case_when(
  1075. # 'endocrine'
  1076. grepl("^ISN$",cell_type) ~ "nutrient_sensory_neuron",
  1077. grepl("^PSI$",cell_type) ~ "peripheral_intrinsic_neuron",
  1078. grepl("^ascending_visceral_circulatory",super_class) ~ "ventral_nerve_cord_neurosecretory_cell",
  1079. grepl("^m_NSC_unknown$",cell_type) ~ "pars_intercerebralis_neurosecretory_cell",
  1080. grepl("^DNg28$",cell_type) ~ "subesophageal_zone_neurosecretory_cell",
  1081. grepl("^m-NSC$|medial_NSC|medial_neurosecretory_cell",cell_sub_class) ~ "pars_intercerebralis_neurosecretory_cell",
  1082. grepl("^l-NSC$|lateral_NSC|lateral_neurosecretory_cell",cell_sub_class) ~ "pars_lateralis_neurosecretory_cell",
  1083. grepl("SEZ-NSC|subesophageal_zone_neurosecretory_cell",cell_sub_class) ~ "subesophageal_zone_neurosecretory_cell",
  1084. grepl("^PI$",FAFB_cell_type) ~ "pars_intercerebralis_efferent_neuron",
  1085. grepl("FMRFa|CAPA",neuropeptide_verified)&grepl("efferent",flow)&grepl("ventral_nerve_cord",region)&grepl("ANm",MANC_origin) ~ "ventral_nerve_cord_neurosecretory_cell",
  1086. grepl("endocrine",cell_class)&grepl("ventral_nerve_cord",region)&grepl("hemal",body_part_effector)&grepl("ANm",MANC_origin) ~ "ventral_nerve_cord_neurosecretory_cell",
  1087. grepl("^ad_encodrine_neuron$|ANm_endocrine",cell_class)&grepl("hemal",body_part_effector) ~ "ventral_nerve_cord_neurosecretory_cell",
  1088. grepl("^EN$",cell_sub_class)&grepl("ventral_nerve_cord",region)&grepl("hemal",body_part_effector)&grepl("ANm",MANC_origin) ~ "ventral_nerve_cord_neurosecretory_cell",
  1089. grepl("FMRFa|CAPA",neuropeptide_verified)&grepl("efferent",flow)&grepl("ventral_nerve_cord",region) ~ "ventral_nerve_cord_neurosecretory_cell",
  1090. grepl("endocrine",cell_class)&grepl("ventral_nerve_cord",region)&grepl("hemal",body_part_effector) ~ "ventral_nerve_cord_neurosecretory_cell",
  1091. grepl("^EN$",cell_sub_class)&grepl("ventral_nerve_cord",region)&grepl("hemal",body_part_effector) ~ "ventral_nerve_cord_neurosecretory_cell",
  1092. grepl("^ad_encodrine_neuron$|ANm_endocrine",cell_class)&!grepl("hemal",body_part_effector)&grepl("ANm",MANC_origin) ~ "ventral_nerve_cord_neurosecretory_cell",
  1093. grepl("^ad_encodrine_neuron$",cell_sub_class)&grepl("ANm",MANC_origin) ~ "ventral_nerve_cord_neurosecretory_cell",
  1094. grepl("endocrine",cell_class)&grepl("ventral_nerve_cord",region)&!grepl("hemal",body_part_effector) ~ "ventral_nerve_cord_neurosecretory_cell",
  1095. grepl("^EN$",cell_sub_class)&grepl("ventral_nerve_cord",region)&!grepl("hemal",body_part_effector) ~ "ventral_nerve_cord_neurosecretory_cell",
  1096. grepl("^multi_endocrine$",cell_class) ~ "ventral_nerve_cord_efferent_neuron",
  1097. grepl("^EN$",cell_sub_class)&grepl("brain",region) ~ "central_brain_efferent_neuron",
  1098. grepl("endocrine",cell_class)&grepl("brain",region) ~ "central_brain_efferent_neuron",
  1099. cell_sub_class=="NSC" ~ paste0(region,"_neurosecretory_cell"),
  1100. # sensory
  1101. ## classics
  1102. grepl("^ORN",cell_type) ~ "olfactory_receptor_neuron",
  1103. grepl("^GRN",cell_type) ~ "gustatory_receptor_neuron",
  1104. grepl("^HRN",cell_type) ~ "hygrosensory_receptor_neuron",
  1105. grepl("^TRN",cell_type) ~ "thermosensory_receptor_neuron",
  1106. grepl("AC neuron|AC_neuron|ac_neuron",cell_type) ~ "thermosensory_receptor_neuron",
  1107. ### conjunctions
  1108. grepl("sensory",super_class)&!is.na(peripheral_target_type) ~ paste0(peripheral_target_type,"_neuron"),
  1109. grepl("sensory",super_class)&is.na(peripheral_target_type) ~ "orphan_sensory_neuron",
  1110. # grepl("sensory",super_class)&grepl("head|^frontal|^frontoorbital|^orbital|^interocellar|^vibrissa|^interommatidial|^occipital_dorsal|^occipital_ventral|^postorbital_dorsal|^postorbital_ventral|^vertical|^postocellar|^supracervical|^haustellum|^ocellar",body_part_sensory)&!is.na(peripheral_target_type) ~ paste0("head_",peripheral_target_type,"_neuron"),
  1111. # central complex
  1112. grepl("CX|central_complex",cell_class) & grepl("^hDelta|^vDelta|^FC|columnar|^PEN$",cell_sub_class) ~ "central_complex_intrinsic_neuron",
  1113. grepl("CX|central_complex",cell_class) & grepl("^EL$|^EPG|^Delta7|^P6\\-8P9|^P1\\-9|^PFN|^FC",cell_type) ~ "central_complex_intrinsic_neuron",
  1114. grepl("CX|central_complex",cell_class) & grepl("^NO$|PB_input|ER|fb_tangential|FB_tangential|ExR|NO_input|CB.FB|^SA1|^SA2|^SA3|^SAF|^FB",cell_sub_class) ~ "central_complex_input_neuron",
  1115. grepl("CX|central_complex",cell_class) & grepl("^NO$|PB_input|ER|fb_tangential|FB_tangential|ExR|NO_input|CB.FB|^SA1|^SA2|^SA3|^SAF|^FB",cell_type) ~ "central_complex_input_neuron",
  1116. grepl("CX|central_complex",cell_class) & grepl("^FS|^PFL|^PFR|^FR|^PFG|^PEG",cell_sub_class) ~ "central_complex_output_neuron",
  1117. # motor
  1118. grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) & is.na(body_part_effector) ~ "orphan_motor_neuron",
  1119. grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) & grepl("leg",body_part_effector) ~ "leg_motor_neuron",
  1120. grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) & grepl("spiracle", cell_class) ~ "spiracle_motor_neuron",
  1121. grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) & grepl("wing",body_part_effector) ~ "wing_motor_neuron",
  1122. grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) & grepl("neck",body_part_effector) ~ "neck_motor_neuron",
  1123. grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) & grepl("salivary",body_part_effector) ~ "salivary_motor_neuron",
  1124. grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ paste0(body_part_effector,"_motor_neuron"),
  1125. # neck
  1126. super_class=="ascending" ~ "ascending_neuron",
  1127. super_class=="descending" ~ "descending_neuron",
  1128. grepl("sensory_ascending",cell_class) ~ "sensory_ascending_neuron",
  1129. grepl("sensory_descending",cell_class) ~ "sensory_descending_neuron",
  1130. grepl("efferent_ascending",cell_class) ~ "efferent_ascending_neuron",
  1131. grepl("efferent_descending",cell_class) ~ "efferent_descending_neuron",
  1132. # circadian
  1133. grepl("^clock$|circadian",cell_class) ~ "circadian_neuron",
  1134. cell_type %in% "HBeyelet" ~ "circadian_neuron",
  1135. grepl("APDN3|LTe71|SLP1500|LMTe01|SLP249|PLP080",cell_type)~ "circadian_neuron",
  1136. grepl("^LNd|^LNv|^DN1p|^DN1a|^DN1b|^DN3|^LPN$|CB1215|PV7c11",cell_type)~ "circadian_neuron",
  1137. grepl("SLPpl1",FAFB_ito_lee_hemilineage)&grepl("clock|circadian",cell_class)~ "circadian_neuron",
  1138. # optic
  1139. (grepl("^C2$|^C3$", cell_type)) ~ "optic_lobe_intrinsic_centrifugal",
  1140. (grepl("^Dm\\d+", cell_type)) ~ "distal_medulla",
  1141. (grepl("^CB3849$", cell_type)) ~ "distal_medulla",
  1142. (grepl("^DmDRA", cell_type)) ~ "distal_medulla_dorsal_rim_area",
  1143. (grepl("^Lai$", cell_type)) ~ "lamina_intrinsic",
  1144. (grepl("^L\\d$", cell_type)) ~ "lamina_monopolar",
  1145. (grepl("^L\\d-\\d$", cell_type)) ~ "lamina_monopolar",
  1146. (grepl("^Lat$", cell_type)) ~ "lamina_tangential",
  1147. (grepl("Lawf", cell_type)) ~ "lamina_wide_field",
  1148. (grepl("^Li\\d+$", cell_type)) ~ "lobula_intrinsic",
  1149. (grepl("^CB3815$", cell_type)) ~ "lobula_intrinsic",
  1150. (grepl("^LLPt$", cell_type)) ~ "lobula_lobula_plate_tangential",
  1151. (grepl("^CT1$|^LMa\\d$", cell_type)) ~ "lobula_medulla_amacrine",
  1152. (grepl("^CB3818$", cell_type)) ~ "lobula_medulla_amacrine",
  1153. (grepl("^LMt\\d$", cell_type)) ~ "lobula_medulla_tangential",
  1154. (grepl("CB3820", cell_type)) ~ "lobula_medulla_tangential",
  1155. (grepl("^LPi\\d+$", cell_type)) ~ "lobula_plate_intrinsic",
  1156. (grepl("^CB3826$", cell_type)) ~ "lobula_plate_intrinsic",
  1157. (grepl("^Mi\\d+$", cell_type)) ~ "medulla_intrinsic",
  1158. (grepl("^Am1$", cell_type)) ~ "medulla_lobula_lobula_plate_amacrine",
  1159. (grepl("^MLt\\d$", cell_type)) ~ 'medulla_lobula_tangential',
  1160. (grepl("^CB3833$", cell_type)) ~ 'medulla_lobula_tangential',
  1161. (grepl("^PDt$", cell_type)) ~ "proximal_distal_medulla_tangential",
  1162. (grepl("^Pm\\d+$", cell_type)) ~ "proximal_medulla",
  1163. (grepl("^Sm\\d+$", cell_type)) ~ "serpentine_medulla",
  1164. (grepl("^CB3825$|^CB3832$", cell_type)) ~ "serpentine_medulla",
  1165. (grepl("^T\\d", cell_type)) ~ 'transverse_neuron',
  1166. (grepl("^Tlp\\d+$", cell_type)) ~ "translobula_plate",
  1167. (grepl("^Tm\\d+", cell_type)) ~ "transmedullary",
  1168. (grepl("^CB3851$|^CB3864$", cell_type)) ~ "transmedullary",
  1169. (grepl("^TmY\\d+", cell_type)) ~ "transmedullary_y",
  1170. (grepl("^CB3816$", cell_type)) ~ "transmedullary_y",
  1171. (grepl("^Y\\d+$", cell_type)) ~ "y_neuron",
  1172. (grepl("^CB3846$", cell_type)) ~ "y_neuron",
  1173. (grepl("^LC", cell_type)) ~ "lobula_columnar",
  1174. (grepl("^LT", cell_type)) ~ "lobula_tangential",
  1175. (grepl("^LPC\\d+$", cell_type)) ~ "lobula_plate_columnar",
  1176. (grepl("^LPLC\\d+$", cell_type)) ~ "lobula_plate_lobula_columnar",
  1177. (grepl("^LLPC\\d+$", cell_type)) ~ "lobula_lobula_plate_columnar",
  1178. (grepl("^LPT|^Nod|^VS|^HS|^H1$|^H2$|^DCH$|^FD1$|^FD3$|^V1$|^vCal1$|^VCH$", cell_type))
  1179. ~ "lobula_plate_tangential_cell",
  1180. (grepl("^MeMe", cell_type)) ~ "medulla_medulla",
  1181. (grepl("^MeTu", cell_type)) ~ "medulla_tubercle",
  1182. (grepl("^MeLp", cell_type)) ~ "medulla_lobula_plate",
  1183. (grepl("^aMe", cell_type)) ~ "amacrine_medulla",
  1184. (grepl("^MTe|MC65", cell_type)) ~ "medulla_tangential",
  1185. (grepl("^mALC\\d+", cell_type)) ~ "medial_antennal_lobula",
  1186. (grepl("^cM\\d+", cell_type)) ~ "centrifugal_medulla",
  1187. (grepl("^cML\\d+", cell_type)) ~ "centrifugal_medulla_lobula",
  1188. (grepl("^cMLLP\\d+", cell_type)) ~ "centrifugal_medulla_lobula_lobula_plate",
  1189. (grepl("^cL\\d+", cell_type)) ~ "centrifugal_lobula",
  1190. (grepl("^cLM\\d+", cell_type)) ~ "centrifugal_lobula_medulla",
  1191. (grepl("^cLP", cell_type)) ~ "centrifugal_lobula_plate",
  1192. (grepl("^cLLP\\d+", cell_type)) ~ "centrifugal_lobula_lobula_plate",
  1193. (grepl("cLLPM\\d+", cell_type)) ~ "centrifugal_lobula_lobula_plate_medulla",
  1194. (grepl("^OA-A", cell_type)) ~ "optic_anterior",
  1195. (grepl("^R\\d$|^R1-6$", cell_type)) ~ "photoreceptor",
  1196. grepl("^TuBu$",cell_class)|grepl("^TuBu$",cell_type) ~ "tubercular_bulbar_neuron",
  1197. grepl("ocellar_projection",cell_class)|grepl("ocellar_projection",cell_sub_class) ~ "ocellar_projection_neuron",
  1198. grepl("^OCC",cell_type)|grepl("ocellar_centrifugal",cell_sub_class) ~ "ocellar_centrifugal_neuron",
  1199. grepl("^OCI|^OCL",cell_type)|grepl("ocellar_interneuron",cell_sub_class) ~ "ocellar_intrinsic_neuron",
  1200. grepl("ocellar",cell_sub_class) ~ "ocellar_intrinsic_neuron",
  1201. # classics
  1202. grepl("^ALIN$",cell_class) ~ "antennal_lobe_centrifugal_neuron",
  1203. grepl("^ALON$",cell_class) ~ "antennal_lobe_output_neuron",
  1204. grepl("^ALPN$",cell_class) ~ "antennal_lobe_projection_neuron",
  1205. grepl("^ALLN$",cell_class) ~ "antennal_lobe_local_neuron",
  1206. grepl("^TPN$",cell_class) ~ "subesophageal_zone_projection_neuron",
  1207. grepl("^water_PN|^mAL",cell_sub_class) ~ "subesophageal_zone_projection_neuron",
  1208. grepl("^water_PN|^mAL$",cell_class)|grepl("^mAL$",cell_sub_class) ~ "subesophageal_zone_projection_neuron",
  1209. grepl("^WEDPN$",cell_class) ~ "wedge_projection_neuron",
  1210. grepl("^MBON$",cell_class) ~ "mushroom_body_output_neuron",
  1211. grepl("^MBIN$",cell_class) ~ "mushroom_body_extrinsic_neuron",
  1212. cell_type %in% c("APL","DPM") ~ "mushroom_intrinsic_body",
  1213. grepl("^DAN$",cell_class)&grepl("^PAM|^PPL",cell_type) ~ "mushroom_body_dopaminergic_neuron",
  1214. grepl("^DAN$",cell_class)&grepl("^PPM",cell_type) ~ "PPM_dopaminergic_neuron",
  1215. #grepl("^TOON$",cell_class) ~ "third_order_olfactory_neuron",
  1216. grepl("^LHON$",cell_class) ~ "lateral_horn_output_neuron",
  1217. grepl("^LHLN$",cell_class) ~ "lateral_horn_local_neuron",
  1218. grepl("^LHCENT$",cell_class) ~ "lateral_horn_centrifugal_neuron",
  1219. grepl("^KC$|^Kenyon_cell|Kenyon_Cell",cell_class) ~ "kenyon_cell",
  1220. grepl("^bilateral$",cell_class) ~ "bilateral_neuron",
  1221. # VNC intrinsic
  1222. grepl("independent leg",MANC_serialMotif) ~ "single_leg_neuromere",
  1223. grepl("sequential",MANC_serialMotif) ~ "sequential_leg_neuromeres",
  1224. grepl("centrifugal",MANC_serialMotif) ~ "ventral_nerve_cord_centrifugal",
  1225. grepl("dorsal",MANC_serialMotif) ~ "ventral_nerve_cord_dorsal",
  1226. grepl("centripetal",MANC_serialMotif) ~ "ventral_nerve_cord_centripetal",
  1227. grepl("convergent",MANC_serialMotif) ~ "ventral_nerve_cord_serially_convergent",
  1228. # bad
  1229. grepl("^Interneuron_TBD$",cell_class) ~ NA,
  1230. grepl("^TBD$",FAFB_cell_class) ~ NA,
  1231. grepl("^TBD$",cell_class) ~ NA,
  1232. TRUE ~ NA
  1233. )) %>%
  1234. #dplyr::rowwise() %>%
  1235. dplyr::mutate(cell_sub_class = dplyr::case_when(
  1236. grepl("^ISN$",cell_type) ~ "hemolymph_sensory_neuron",
  1237. # chordotonals
  1238. grepl("chordotonal_club|club_chordotonal",cell_function_detailed) ~ paste0(body_part_sensory,"_club_chordotonal_organ_neuron"),
  1239. grepl("chordotonal_claw|claw_chordotonal",cell_function_detailed) ~ paste0(body_part_sensory,"_claw_chordotonal_organ_neuron"),
  1240. grepl("chordotonal_hook|hook_chordotonal",cell_function_detailed) ~ paste0(body_part_sensory,"_hook_chordotonal_organ_neuron"),
  1241. grepl("chordotonal_club|club_chordotonal",cell_sub_class) ~ paste0(body_part_sensory,"_club_chordotonal_organ_neuron"),
  1242. grepl("chordotonal_claw|claw_chordotonal",cell_sub_class) ~ paste0(body_part_sensory,"_claw_chordotonal_organ_neuron"),
  1243. grepl("chordotonal_hook|hook_chordotonal",cell_sub_class) ~ paste0(body_part_sensory,"_hook_chordotonal_organ_neuron"),
  1244. grepl("chordotonal_claw",cell_function_detailed) ~ paste0(body_part_sensory,"_claw_chordotonal_organ_neuron"),
  1245. grepl("chordotonal_club",cell_function_detailed) ~ paste0(body_part_sensory,"_club_chordotonal_organ_neuron"),
  1246. grepl("chordotonal_hook",cell_function_detailed) ~ paste0(body_part_sensory,"_hook_chordotonal_organ_neuron"),
  1247. grepl("^JO-A",cell_type) ~ "johnstons_organ_A_neuron",
  1248. grepl("^JO-B",cell_type) ~ "johnstons_organ_B_neuron",
  1249. grepl("^JO-C",cell_type) ~ "johnstons_organ_C_neuron",
  1250. grepl("^JO-D",cell_type) ~ "johnstons_organ_D_neuron",
  1251. grepl("^JO-E",cell_type) ~ "johnstons_organ_E_neuron",
  1252. grepl("^JO-F",cell_type) ~ "johnstons_organ_F_neuron",
  1253. grepl("^JO-",cell_type) ~ "johnstons_organ_other_neuron",
  1254. grepl("chordotonal organ, JO",cell_class) ~ "johnstons_organ_neuron",
  1255. # sensory
  1256. grepl("AC neuron|AC_neuron|ac_neuron",cell_type) ~ "internal_thermosensory_receptor_neuron",
  1257. grepl("sensory",super_class)&!is.na(body_part_sensory)&!grepl("metathoracic|wheelers|prothoracic",cell_class) ~ paste0(gsub("_chordotonal_organ|_organ","",body_part_sensory),"_",cell_class),
  1258. grepl("sensory",super_class)&!is.na(body_part_sensory) ~ paste0(body_part_sensory,"_",cell_class),
  1259. # ALPNS
  1260. grepl("multiglomerular",cell_sub_class) ~ "multiglomerular_projection_neuron",
  1261. grepl("uniglomerular",cell_sub_class) ~ "uniglomerular_projection_neuron",
  1262. # bristles
  1263. grepl("_bristle",cell_sub_class) ~ cell_sub_class,
  1264. # central complex
  1265. FAFB_cell_class=="CX" & grepl("hDelta",cell_type) ~ "hDelta",
  1266. FAFB_cell_class=="CX" & grepl("vDelta",cell_type) ~ "vDelta",
  1267. FAFB_cell_class=="CX" & grepl("^FB|^CB.FB|^SA1|^SA2|^SA3",cell_type) ~ "FB_tangential",
  1268. FAFB_cell_class=="CX" & grepl("^ExR",cell_type) ~ "ExR",
  1269. FAFB_cell_class=="CX" & grepl("^FC",cell_type) ~ "FC",
  1270. FAFB_cell_class=="CX" & grepl("^FS",cell_type) ~ "FS",
  1271. FAFB_cell_class=="CX" & grepl("^PFL",cell_type) ~ "PFL",
  1272. FAFB_cell_class=="CX" & grepl("^PFN",cell_type) ~ "PFN",
  1273. FAFB_cell_class=="CX" & grepl("^ER",cell_type) ~ "EB_input",
  1274. FAFB_cell_class=="CX" & grepl("^FR1|^FR2",cell_type) ~ "FR",
  1275. FAFB_cell_class=="CX" & grepl("^PFR$",cell_type) ~ "PFR",
  1276. FAFB_cell_class=="CX" & grepl("^PFGs$",cell_type) ~ "PFG",
  1277. FAFB_cell_class=="CX" & grepl("^PEG",cell_type) ~ "PEG",
  1278. FAFB_cell_class=="CX" & grepl("^PEN_",cell_type) ~ "PEN",
  1279. FAFB_cell_class=="CX" & grepl("^GLNO$|^LCNOp$|^LCNOpm$|^LNO1$|^LNO1$|^LNO2$",cell_type) ~ "NO_input",
  1280. FAFB_cell_class=="CX" & grepl("^IbSpsP|^LPsP|^SpsP",cell_type) ~ "PB_input",
  1281. # kenyon cells
  1282. grepl("^KCab",cell_type)~ "KCab",
  1283. grepl("^KCapbp",cell_type)~ "KCapbp",
  1284. grepl("^KCg",cell_type)~ "KCg",
  1285. # wing
  1286. #grepl("^w-cHIN",cell_type)~ "w-cHIN",
  1287. #grepl("^n-cHIN",cell_type)~ "n-cHIN",
  1288. # dopamine
  1289. grepl("^PAM",cell_type) ~ "PAM_dopaminergic_neuron",
  1290. grepl("^CB2730",cell_type) ~ "PAM_dopaminergic_neuron",
  1291. grepl("^PPL1",cell_type)~ "PPL1_dopaminergic_neuron",
  1292. grepl("^PPL2",cell_type)~ "PPL2_dopaminergic_neuron",
  1293. grepl("^PPM",cell_type)|grepl("^PPM",cell_type)~ "PPM_dopaminergic_neuron",
  1294. # circadian
  1295. grepl("APDN3|LTe71|SLP1500|LMTe01|SLP249|PLP080",cell_type)~ "APDN3",
  1296. grepl("^LNd",cell_type)~ "LNd",
  1297. grepl("^LNv",cell_type)~ "LNv",
  1298. grepl("^DN1p",cell_type)~ "DN1p",
  1299. grepl("^DN1a",cell_type)~ "DN1a",
  1300. grepl("^DN1b",cell_type)~ "DN1b",
  1301. grepl("^DN3",cell_type)~ "DN3",
  1302. grepl("^DN1p",cell_sub_class)~ "DN1p",
  1303. grepl("^DN1a",cell_sub_class)~ "DN1a",
  1304. grepl("^DN1b",cell_sub_class)~ "DN1b",
  1305. grepl("^DN3",cell_sub_class)~ "DN3",
  1306. grepl("^LPN$|CB1215|PV7c11",cell_type)~ "LPN",
  1307. grepl("SLPpl1",FAFB_ito_lee_hemilineage)&grepl("clock|circadian",cell_class)~ "s-CPDN",
  1308. cell_type %in% "HBeyelet" ~ "hofbauer_buchner_eyelet_neuron",
  1309. # ventral nerve cord
  1310. grepl("ventral_nerve_cord_intrinsic",super_class)&MANC_subclass=="BR" ~ "ventral_nerve_cord_bilateral_restricted",
  1311. grepl("ventral_nerve_cord_intrinsic",super_class)&MANC_subclass=="IR" ~ "ventral_nerve_cord_ipsilateral_restricted",
  1312. grepl("ventral_nerve_cord_intrinsic",super_class)&MANC_subclass=="CR" ~ "ventral_nerve_cord_contralateral_restricted",
  1313. grepl("ventral_nerve_cord_intrinsic",super_class)&MANC_subclass=="BI" ~ "ventral_nerve_cord_bilateral_interconnecting",
  1314. grepl("ventral_nerve_cord_intrinsic",super_class)&MANC_subclass=="II" ~ "ventral_nerve_cord_ipsilateral_interconnecting",
  1315. grepl("ventral_nerve_cord_intrinsic",super_class)&MANC_subclass=="CI" ~ "ventral_nerve_cord_contralateral_interconnecting",
  1316. # motor
  1317. grepl("front_leg",body_part_effector)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "front_leg_motor_neuron",
  1318. grepl("haltere_power",cell_function)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "haltere_power_neuron",
  1319. grepl("haltere_steering",cell_function)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "haltere_steering_neuron",
  1320. grepl("hind_leg",body_part_effector)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "hind_leg_motor_neuron",
  1321. grepl("jump_escape",cell_function)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "middle_leg_extension_jump_motor_neuron",
  1322. grepl("middle_leg",body_part_effector)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "middle_leg_motor_neuron",
  1323. grepl("neck_pitch",cell_function_detailed)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "neck_pitch_motor_neuron",
  1324. grepl("neck_roll",cell_function_detailed)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "neck_roll_motor_neuron",
  1325. grepl("neck_yaw",cell_function_detailed)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "neck_yaw_motor_neuron",
  1326. grepl("wing_power",cell_function)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "wing_power_motor_neuron",
  1327. grepl("wing_steering",cell_function)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "wing_steering_motor_neuron",
  1328. grepl("wing_tension",cell_function)&grepl("central_brain_motor|ventral_nerve_cord_motor",super_class) ~ "wing_tension_motor_neuron",
  1329. # endocrine
  1330. grepl("^PSI$",cell_type) ~ paste0(body_part_effector, "_peripheral_intrinsic_neuron"),
  1331. grepl("visceral",super_class) ~ paste0(body_part_effector,gsub("pars_intercerebralis_|pars_lateralis_|ventral_nerve_cord_|central_brain_|subesophageal_zone_|abdominal_neuromere_","_",cell_class)),
  1332. #grepl("^l_NSC_unknown|l_NSC_DH31",cell_type)~ "circadian_neuroendocrine_neuron", # DNES
  1333. #grepl("abdomen_endocrine",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "abdomen_endocrine",
  1334. # grepl("pars_intercerebralis_endocrine_enteric",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "pars_intercerebralis_enteric_endocrine_neuron",
  1335. # grepl("pars_intercerebralis_endocrine_unknown",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "pars_intercerebralis_unknown_endocrine_neuron",
  1336. # grepl("pars_lateralis_endocrine_corpus_allatum",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "pars_lateralis_corpus_allatum_endocrine_neuron",
  1337. # grepl("pars_lateralis_endocrine_retrocerebral_complex",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "pars_lateralis_retrocerebral_complex_endocrine_neuron",
  1338. # grepl("pars_lateralis_endocrine_unknown",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "pars_lateralis_unknown_endocrine_neuron",
  1339. # !is.na(body_part_effector)&grepl("endocrine|visceral_circulatory",super_class) ~ paste0(body_part_effector,"_endocrine_neuron"),
  1340. # !is.na(body_part_effector)&grepl("^EN$",cell_class)|grepl("^EN$",cell_sub_class) ~ paste(body_part_effector,"_endocrine"),
  1341. # grepl("SEZ_endocrine",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "subesophageal_zone_endocrine",
  1342. # grepl("wing_endocrine",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "wing_endocrine_neuron",
  1343. # grepl("neurohemal_complex_endocrine",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "neurohemal_complex_endocrine_neuron",
  1344. # grepl("ovulation",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "ovulation_endocrine_neuron",
  1345. # grepl("peripheral_serotonin",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "peripheral_serotonin_neuron",
  1346. # grepl("^endocrine$",cell_function)&grepl("endocrine|visceral_circulatory",super_class) ~ "endocrine_neuron",
  1347. # other
  1348. grepl("^water_PN",cell_sub_class) ~ "BiT",
  1349. grepl("^mAL$",cell_class)|grepl("^mAL$",cell_sub_class) ~ "mAL",
  1350. TRUE ~ NA
  1351. ))
  1352. #dplyr::mutate(cell_class = gsub("\\>|\\.","-",cell_class)) %>%
  1353. # select changed columns
  1354. franken.meta.update.toPush <- franken.meta.update %>%
  1355. select(flow, super_class, cell_class, cell_sub_class, cell_function,
  1356. cell_function_detailed, peripheral_target_type, body_part_sensory,
  1357. body_part_effector, nerve, banc_neuropeptide_verified,
  1358. banc_neurotransmitter_verified, side, region, `_id`)
  1359. # add old franken_meta columns to updated version, for relevant columns, as
  1360. # franken_[column name]
  1361. # columns that have changed with above code
  1362. franken.meta.keep <- franken.meta %>%
  1363. # rename columns
  1364. mutate(franken_flow = flow,
  1365. franken_super_class = super_class,
  1366. franken_cell_class = cell_class,
  1367. franken_cell_sub_class = cell_sub_class,
  1368. franken_cell_function = cell_function,
  1369. franken_cell_function_detailed = cell_function_detailed,
  1370. franken_peripheral_target_type = peripheral_target_type,
  1371. franken_body_part_sensory = body_part_sensory,
  1372. franken_body_part_effector = body_part_effector,
  1373. franken_nerve = nerve,
  1374. franken_side = side,
  1375. franken_region = region,) %>%
  1376. select(franken_flow, franken_super_class, franken_cell_class,
  1377. franken_cell_sub_class, franken_cell_function,
  1378. franken_cell_function_detailed, franken_peripheral_target_type,
  1379. franken_body_part_sensory, franken_body_part_effector,
  1380. franken_nerve, franken_side, franken_region,
  1381. neurotransmitter_verified, neuropeptide_verified, `_id`)
  1382. # join with franken.meta.update.toPush
  1383. franken.meta.joined <- franken.meta.update.toPush %>%
  1384. inner_join(franken.meta.keep, by = "_id")
  1385. # write to franken_meta SeaTable
  1386. banctable_update_rows(base='cns_meta',
  1387. table = "franken_meta",
  1388. df = as.data.frame(franken.meta.joined),
  1389. append_allowed = FALSE,
  1390. chunksize = 1000)
  1391. # 250619 - policy update to super_class - implement here, given previous update
  1392. # has already been pushed to the table
  1393. franken.meta.update <- franken.meta %>%
  1394. mutate(super_class = case_when(
  1395. grepl("central_brain_motor|ventral_nerve_cord_motor", super_class) ~ "motor",
  1396. grepl("central_brain_sensory|optic_lobe_sensory|ventral_nerve_cord_sensory",
  1397. super_class) ~ "sensory",
  1398. grepl("central_brain_visceral_circulatory|ventral_nerve_cord_visceral_circulatory",
  1399. super_class) ~ "visceral_circulatory",
  1400. TRUE ~ super_class
  1401. ))
  1402. franken.meta.update.toPush <- franken.meta.update %>%
  1403. select(super_class, banc_id, `_id`)
  1404. banctable_update_rows(base='cns_meta',
  1405. table = "franken_meta",
  1406. df = as.data.frame(franken.meta.update.toPush),
  1407. append_allowed = FALSE,
  1408. chunksize = 1000)
  1409. # 250626 - update to nerve - right and left cervical nerve will only apply to
  1410. # neurons that leave the side of the neck and not regular ascending and
  1411. # descending neurons
  1412. franken.meta.update <- franken.meta %>%
  1413. filter((grepl("cervical_nerve", nerve) & !grepl("ventral", nerve) &
  1414. !grepl("motor", super_class))) %>%
  1415. mutate(nerve = case_when(
  1416. (grepl("cervical_nerve", nerve) & !grepl("ventral", nerve) &
  1417. !grepl("motor", super_class)) ~ NA,
  1418. TRUE ~ nerve
  1419. ))
  1420. franken.meta.update.toPush <- franken.meta.update %>%
  1421. select(nerve, sexual_dimorphism, `_id`)
  1422. banctable_update_rows(base='cns_meta',
  1423. table = "franken_meta",
  1424. df = as.data.frame(franken.meta.update.toPush),
  1425. append_allowed = FALSE,
  1426. chunksize = 1000)
  1427. # 250627 - super_class for TmY14 is wrong
  1428. franken.meta.update <- franken_meta %>%
  1429. filter(grepl("^TmY14$", cell_type)) %>%
  1430. mutate(super_class = case_when(
  1431. grepl("^TmY14$", cell_type) ~ "optic_lobe_intrinsic",
  1432. TRUE ~ super_class
  1433. )) %>%
  1434. select(super_class, sexual_dimorphism, `_id`)
  1435. banctable_update_rows(base='cns_meta',
  1436. table = "franken_meta",
  1437. df = as.data.frame(franken.meta.update),
  1438. append_allowed = FALSE,
  1439. chunksize = 1000)
  1440. # 250627 - there are a subset of ascending neurons with flow afferent, which is wrong
  1441. franken.meta.update <- franken_meta %>%
  1442. filter(grepl("afferent", flow) & grepl("^ascending$", super_class)) %>%
  1443. mutate(flow = case_when(
  1444. (grepl("afferent", flow) & grepl("^ascending$", super_class)) ~ "intrinsic",
  1445. TRUE ~ flow
  1446. )) %>%
  1447. select(flow, sexual_dimorphism, `_id`)
  1448. banctable_update_rows(base='cns_meta',
  1449. table = "franken_meta",
  1450. df = as.data.frame(franken.meta.update),
  1451. append_allowed = FALSE,
  1452. chunksize = 1000)
  1453. # 6/29/25 - missing organ_neuron after hook_chordotonal for small subset
  1454. franken.meta.update <- franken.meta %>%
  1455. filter(grepl("hook_chordotonal", cell_sub_class) & !grepl("neuron", cell_sub_class)) %>%
  1456. mutate(cell_sub_class = gsub("hook_chordotonal", "hook_chordotonal_organ_neuron",
  1457. cell_sub_class)) %>%
  1458. select(`_id`, cell_sub_class, sexual_dimorphism)
  1459. banctable_update_rows(base='cns_meta',
  1460. table = "franken_meta",
  1461. df = as.data.frame(franken.meta.update),
  1462. append_allowed = FALSE,
  1463. chunksize = 1000)
  1464. # View and check a chosen snippet
  1465. snippet <- franken.meta.update %>%
  1466. # dplyr::filter(grepl("visceral",super_class)) %>%
  1467. dplyr::group_by(flow,super_class, cell_class, cell_sub_class,cell_function, cell_function_detailed) %>%
  1468. dplyr::summarize(
  1469. count = dplyr::n()
  1470. ) %>%
  1471. dplyr::arrange(flow,super_class, cell_class, cell_sub_class, cell_function, cell_function_detailed)
  1472. knitr::kable(snippet)
  1473. clipr::write_clip(knitr::kable(snippet))
  1474. ### STANDARDIZATION TESTS FOR BANC ANNOTATIONS ###
  1475. # Helper function to compare original and updated values for a column
  1476. compare_and_summarize <- function(original_df, updated_df, column_name) {
  1477. if(!(column_name %in% colnames(original_df) && column_name %in% colnames(updated_df))) {
  1478. return(paste("Column", column_name, "not found in one or both dataframes"))
  1479. }
  1480. # Get original and updated values
  1481. orig_values <- original_df[[column_name]]
  1482. updt_values <- updated_df[[column_name]]
  1483. # Create mapping table
  1484. mapping_df <- data.frame(
  1485. original = orig_values,
  1486. updated = updt_values,
  1487. row_id = 1:length(orig_values)
  1488. ) %>%
  1489. filter(original != updated | (is.na(original) & !is.na(updated)) | (!is.na(original) & is.na(updated)))
  1490. # Create unique mapping combinations with counts
  1491. unique_mapping_df <- mapping_df %>%
  1492. dplyr::group_by(original, updated) %>%
  1493. dplyr::summarize(
  1494. count = dplyr::n(),
  1495. example_row_id = first(row_id),
  1496. .groups = 'drop'
  1497. ) %>%
  1498. dplyr::arrange(desc(count))
  1499. # Generate summary
  1500. orig_counts <- table(orig_values, useNA = "ifany")
  1501. updt_counts <- table(updt_values, useNA = "ifany")
  1502. orig_summary <- data.frame(
  1503. value = names(orig_counts),
  1504. count = as.numeric(orig_counts),
  1505. dataset = "original"
  1506. )
  1507. updt_summary <- data.frame(
  1508. value = names(updt_counts),
  1509. count = as.numeric(updt_counts),
  1510. dataset = "updated"
  1511. )
  1512. summary_df <- rbind(orig_summary, updt_summary)
  1513. return(list(
  1514. mapping = mapping_df,
  1515. unique_mapping = unique_mapping_df,
  1516. summary = summary_df,
  1517. changed_count = nrow(mapping_df),
  1518. total_count = length(orig_values),
  1519. change_percent = round(nrow(mapping_df) / length(orig_values) * 100, 2)
  1520. ))
  1521. }
  1522. # Function to print a nicely formatted report for a column
  1523. print_column_report <- function(comparison_result, column_name) {
  1524. cat("\n\n======================================\n")
  1525. cat("ANALYSIS FOR COLUMN:", column_name, "\n")
  1526. cat("======================================\n\n")
  1527. cat("CHANGE STATISTICS:\n")
  1528. cat("Total rows:", comparison_result$total_count, "\n")
  1529. cat("Changed rows:", comparison_result$changed_count, "\n")
  1530. cat("Change percentage:", comparison_result$change_percent, "%\n\n")
  1531. if(nrow(comparison_result$unique_mapping) > 0) {
  1532. cat("UNIQUE MAPPING COMBINATIONS (top 150):\n")
  1533. unique_mappings_to_show <- head(comparison_result$unique_mapping, 150)
  1534. # Format NA values for better display
  1535. unique_mappings_to_show$original <- ifelse(is.na(unique_mappings_to_show$original),
  1536. "NA",
  1537. as.character(unique_mappings_to_show$original))
  1538. unique_mappings_to_show$updated <- ifelse(is.na(unique_mappings_to_show$updated),
  1539. "NA",
  1540. as.character(unique_mappings_to_show$updated))
  1541. # Calculate percentage of total changes
  1542. unique_mappings_to_show$percent <- round(unique_mappings_to_show$count / comparison_result$changed_count * 100, 1)
  1543. # Create a nice display format
  1544. for(i in 1:nrow(unique_mappings_to_show)) {
  1545. cat(sprintf("'%s' → '%s': %d occurrences (%.1f%% of changes, example row: %d)\n",
  1546. unique_mappings_to_show$original[i],
  1547. unique_mappings_to_show$updated[i],
  1548. unique_mappings_to_show$count[i],
  1549. unique_mappings_to_show$percent[i],
  1550. unique_mappings_to_show$example_row_id[i]))
  1551. }
  1552. if(nrow(comparison_result$unique_mapping) > 150) {
  1553. cat("... and", nrow(comparison_result$unique_mapping) - 150, "more combinations\n")
  1554. }
  1555. cat("\n")
  1556. }
  1557. cat("VALUE INVENTORY (top 150 values before and after):\n")
  1558. orig_top <- comparison_result$summary %>%
  1559. dplyr::filter(dataset == "original") %>%
  1560. dplyr::arrange(desc(count)) %>%
  1561. head(150)
  1562. updt_top <- comparison_result$summary %>%
  1563. dplyr::filter(dataset == "updated") %>%
  1564. dplyr::arrange(desc(count)) %>%
  1565. head(150)
  1566. cat("Original top values:\n")
  1567. print(orig_top)
  1568. cat("\nUpdated top values:\n")
  1569. print(updt_top)
  1570. # Check if any values disappeared or appeared
  1571. orig_values <- comparison_result$summary$value[comparison_result$summary$dataset == "original"]
  1572. updt_values <- comparison_result$summary$value[comparison_result$summary$dataset == "updated"]
  1573. disappeared <- setdiff(orig_values, updt_values)
  1574. appeared <- setdiff(updt_values, orig_values)
  1575. if(length(disappeared) > 0) {
  1576. cat("\nValues that disappeared after standardization:\n")
  1577. print(disappeared)
  1578. }
  1579. if(length(appeared) > 0) {
  1580. cat("\nNew values that appeared after standardization:\n")
  1581. print(appeared)
  1582. }
  1583. }
  1584. # List of columns to check
  1585. columns_to_check <- c(
  1586. "citation_cell_type", "flow", "side", "region", "peripheral_target_type",
  1587. "cell_function_detailed", "cell_function", "nerve", "body_part_sensory",
  1588. "body_part_effector", "super_class", "cell_sub_class", "cell_class"
  1589. )
  1590. # Run tests for all columns
  1591. test_results <- list()
  1592. for(column in columns_to_check) {
  1593. test_results[[column]] <- compare_and_summarize(franken.meta, franken.meta.update, column)
  1594. print_column_report(test_results[[column]], column)
  1595. }
  1596. # Additional validation tests
  1597. cat("\n\n======================================\n")
  1598. cat("ADDITIONAL VALIDATION CHECKS\n")
  1599. cat("======================================\n\n")
  1600. # Check for any NAs introduced in critical columns
  1601. for(column in columns_to_check) {
  1602. orig_na_count <- sum(is.na(franken.meta[[column]]))
  1603. updt_na_count <- sum(is.na(franken.meta.update[[column]]))
  1604. if(updt_na_count > orig_na_count) {
  1605. cat("WARNING: Column", column, "has more NAs after standardization.\n")
  1606. cat(" Original NA count:", orig_na_count, "\n")
  1607. cat(" Updated NA count:", updt_na_count, "\n")
  1608. cat(" Difference:", updt_na_count - orig_na_count, "\n\n")
  1609. }
  1610. }
  1611. # Check for standardization consistency
  1612. for(column in columns_to_check) {
  1613. mapping_df <- test_results[[column]]$mapping
  1614. if(nrow(mapping_df) > 0) {
  1615. # Check if same original value maps to different updated values
  1616. inconsistencies <- mapping_df %>%
  1617. dplyr::filter(!is.na(original)) %>%
  1618. dplyr::group_by(original) %>%
  1619. dplyr::summarize(unique_updates = dplyr::n_distinct(updated, na.rm = TRUE)) %>%
  1620. dplyr::filter(unique_updates > 1)
  1621. if(nrow(inconsistencies) > 0) {
  1622. cat("WARNING: Inconsistent mappings found in column", column, "\n")
  1623. for(i in 1:nrow(inconsistencies)) {
  1624. orig_val <- inconsistencies$original[i]
  1625. cat(" Original value '", orig_val, "' maps to multiple updated values:\n", sep="")
  1626. examples <- mapping_df %>%
  1627. dplyr::filter(original == orig_val) %>%
  1628. dplyr::group_by(updated) %>%
  1629. dplyr::slice(1) %>%
  1630. dplyr::ungroup()
  1631. for(j in 1:nrow(examples)) {
  1632. cat(" -> '", examples$updated[j], "' (example row: ", examples$row_id[j], ")\n", sep="")
  1633. }
  1634. }
  1635. cat("\n")
  1636. }
  1637. }
  1638. }
  1639. # Print summary statistics for all columns
  1640. cat("\n\n======================================\n")
  1641. cat("OVERALL STANDARDIZATION SUMMARY\n")
  1642. cat("======================================\n\n")
  1643. summary_df <- data.frame(
  1644. column = character(),
  1645. total_rows = integer(),
  1646. changed_rows = integer(),
  1647. change_percent = numeric(),
  1648. original_distinct = integer(),
  1649. updated_distinct = integer(),
  1650. distinct_change = integer(),
  1651. stringsAsFactors = FALSE
  1652. )
  1653. for(column in columns_to_check) {
  1654. result <- test_results[[column]]
  1655. orig_distinct <- length(unique(franken.meta[[column]]))
  1656. updt_distinct <- length(unique(franken.meta.update[[column]]))
  1657. summary_df <- rbind(summary_df, data.frame(
  1658. column = column,
  1659. total_rows = result$total_count,
  1660. changed_rows = result$changed_count,
  1661. change_percent = result$change_percent,
  1662. original_distinct = orig_distinct,
  1663. updated_distinct = updt_distinct,
  1664. distinct_change = updt_distinct - orig_distinct
  1665. ))
  1666. }
  1667. summary_df <- summary_df %>% dplyr::arrange(desc(change_percent))
  1668. print(summary_df)
  1669. # Make full changelog
  1670. franken.meta.changelog <- data.frame(
  1671. timestamp = Sys.time(),
  1672. columns_changed = length(columns_to_check),
  1673. total_rows = nrow(franken.meta),
  1674. total_changes = sum(sapply(test_results, function(x) x$changed_count))
  1675. )
  1676. # Add a detailed description of changes
  1677. changelog_text <- paste0(
  1678. "BANC METADATA STANDARDIZATION CHANGELOG\n",
  1679. "Generated: ", format(Sys.time(), "%Y-%m-%d %H:%M:%S"), "\n",
  1680. "Total rows processed: ", nrow(franken.meta), "\n",
  1681. "Total columns modified: ", length(columns_to_check), "\n\n",
  1682. "SUMMARY OF CHANGES BY COLUMN:\n"
  1683. )
  1684. # Add summary stats for each column
  1685. for (column in columns_to_check) {
  1686. result <- test_results[[column]]
  1687. orig_distinct <- length(unique(franken.meta[[column]]))
  1688. updt_distinct <- length(unique(franken.meta.update[[column]]))
  1689. changelog_text <- paste0(
  1690. changelog_text,
  1691. "Column: ", column, "\n",
  1692. " - Changed values: ", result$changed_count, " (", result$change_percent, "% of data)\n",
  1693. " - Original distinct values: ", orig_distinct, "\n",
  1694. " - Updated distinct values: ", updt_distinct, "\n",
  1695. " - Net change in distinct values: ", updt_distinct - orig_distinct, "\n\n"
  1696. )
  1697. # Add top 150 most frequent mappings
  1698. if (nrow(result$unique_mapping) > 0) {
  1699. changelog_text <- paste0(
  1700. changelog_text,
  1701. " Top 150 most common transformations:\n"
  1702. )
  1703. top_mappings <- head(result$unique_mapping, 150)
  1704. for (i in 1:nrow(top_mappings)) {
  1705. orig_val <- if(is.na(top_mappings$original[i])) "NA" else as.character(top_mappings$original[i])
  1706. updt_val <- if(is.na(top_mappings$updated[i])) "NA" else as.character(top_mappings$updated[i])
  1707. changelog_text <- paste0(
  1708. changelog_text,
  1709. " '", orig_val, "' → '", updt_val, "': ",
  1710. top_mappings$count[i], " occurrences (",
  1711. round(top_mappings$count[i] / result$changed_count * 100, 1), "% of changes)\n"
  1712. )
  1713. }
  1714. changelog_text <- paste0(changelog_text, "\n")
  1715. }
  1716. # Add values that disappeared
  1717. orig_values <- result$summary$value[result$summary$dataset == "original"]
  1718. updt_values <- result$summary$value[result$summary$dataset == "updated"]
  1719. disappeared <- setdiff(orig_values, updt_values)
  1720. appeared <- setdiff(updt_values, orig_values)
  1721. if (length(disappeared) > 0) {
  1722. changelog_text <- paste0(
  1723. changelog_text,
  1724. " Values that were removed (up to 150):\n ",
  1725. paste(head(disappeared, 150), collapse = ", "),
  1726. if(length(disappeared) > 150) paste0(" (and ", length(disappeared) - 150, " more)") else "",
  1727. "\n\n"
  1728. )
  1729. }
  1730. if (length(appeared) > 0) {
  1731. changelog_text <- paste0(
  1732. changelog_text,
  1733. " New values that were added (up to 150):\n ",
  1734. paste(head(appeared, 150), collapse = ", "),
  1735. if(length(appeared) > 150) paste0(" (and ", length(appeared) - 150, " more)") else "",
  1736. "\n\n"
  1737. )
  1738. }
  1739. # Check for inconsistent mappings
  1740. inconsistencies <- result$mapping %>%
  1741. dplyr::filter(!is.na(original)) %>%
  1742. dplyr::group_by(original) %>%
  1743. dplyr::summarize(unique_updates = dplyr::n_distinct(updated, na.rm = TRUE)) %>%
  1744. dplyr::filter(unique_updates > 1)
  1745. if (nrow(inconsistencies) > 0) {
  1746. changelog_text <- paste0(
  1747. changelog_text,
  1748. " WARNING: Inconsistent mappings found for ", nrow(inconsistencies), " original value(s):\n"
  1749. )
  1750. for (i in 1:min(nrow(inconsistencies), 5)) {
  1751. orig_val <- inconsistencies$original[i]
  1752. examples <- result$mapping %>%
  1753. dplyr::filter(original == orig_val) %>%
  1754. dplyr::group_by(updated) %>%
  1755. dplyr::slice(1)
  1756. changelog_text <- paste0(
  1757. changelog_text,
  1758. " '", orig_val, "' maps to: ",
  1759. paste(sapply(examples$updated, function(x) ifelse(is.na(x), "NA", as.character(x))), collapse = ", "),
  1760. "\n"
  1761. )
  1762. }
  1763. if (nrow(inconsistencies) > 5) {
  1764. changelog_text <- paste0(
  1765. changelog_text,
  1766. " (and ", nrow(inconsistencies) - 5, " more inconsistent mappings)\n"
  1767. )
  1768. }
  1769. changelog_text <- paste0(changelog_text, "\n")
  1770. }
  1771. }
  1772. # Complete the object with the text
  1773. franken.meta.changelog$changes_detail <- changelog_text
  1774. # Save original
  1775. franken.meta.concise <- franken.meta.update %>%
  1776. dplyr::distinct(neuron_id,
  1777. dataset,
  1778. side,
  1779. nerve,
  1780. hemilineage,
  1781. flow,
  1782. super_class,
  1783. cell_class,
  1784. cell_sub_class,
  1785. cell_type,
  1786. body_part_sensory,
  1787. body_part_effector,
  1788. peripheral_target_type,
  1789. cell_function,
  1790. cell_function_detailed,
  1791. top_nt)
  1792. save.path <- "/Users/abates/projects/flyconnectome/bancpipeline/data/meta"
  1793. readr::write_csv(franken.meta, file.path(save.path,"franken_meta_v1.csv"))
  1794. readr::write_csv(franken.meta.update, file.path(save.path,"franken_meta_update_for_v2.csv"))
  1795. readr::write_csv(franken.meta.concise, file.path(save.path,"franken_meta_concise_update_for_v2.csv"))
  1796. writeLines(changelog_text, file.path(save.path,"franken_meta_v1_to_v2_changelog.txt"))
  1797. # # update
  1798. # banctable_update_rows(base='cns_meta',
  1799. # table = "franken_meta",
  1800. # df = as.data.frame(franken.meta.update),
  1801. # append_allowed = FALSE,
  1802. # chunksize = 1000)
  1803. #######################
  1804. ### Plots to assess ###
  1805. #######################
  1806. # Create a heatmap to visualize the complete hierarchy
  1807. # This helps show which combinations exist and their frequencies
  1808. hierarchy_heatmap <- franken.meta.update %>%
  1809. dplyr::filter(!is.na(flow) & !is.na(super_class) & !is.na(cell_class)) %>%
  1810. dplyr::count(flow, super_class, cell_class) %>%
  1811. # Transform to log scale to better show differences
  1812. dplyr::mutate(log_n = log10(n + 1))
  1813. # Get top cell classes by count for visualization clarity
  1814. top_cell_classes <- hierarchy_heatmap %>%
  1815. dplyr::group_by(cell_class) %>%
  1816. dplyr::summarize(total = sum(n)) %>%
  1817. dplyr::arrange(desc(total)) %>%
  1818. utils::head(40) %>%
  1819. dplyr::pull(cell_class)
  1820. p1 <- hierarchy_heatmap %>%
  1821. dplyr::filter(cell_class %in% top_cell_classes) %>%
  1822. ggplot2::ggplot(ggplot2::aes(x = reorder(cell_class, log_n),
  1823. y = reorder(super_class, log_n),
  1824. fill = log_n)) +
  1825. ggplot2::geom_tile() +
  1826. ggplot2::facet_wrap(~flow, ncol = 1, scales = "free_y") +
  1827. ggplot2::scale_fill_viridis_c(name = "log10(count+1)") +
  1828. ggplot2::labs(title = "Hierarchical Relationship Matrix",
  1829. subtitle = "flow > super_class > cell_class",
  1830. x = "cell_class", y = "super_class") +
  1831. ggplot2::theme_minimal() +
  1832. ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, hjust = 1, size = 7),
  1833. axis.text.y = ggplot2::element_text(size = 7),
  1834. panel.grid = ggplot2::element_blank())
  1835. # Create a heatmap to visualize the complete hierarchy
  1836. # This helps show which combinations exist and their frequencies
  1837. hierarchy_heatmap <- franken.meta.update %>%
  1838. dplyr::filter(!is.na(flow) & !is.na(super_class) & !is.na(cell_class),
  1839. super_class == "sensory") %>%
  1840. dplyr::count(cell_class, cell_sub_class) %>%
  1841. # Transform to log scale to better show differences
  1842. dplyr::mutate(log_n = log10(n + 1))
  1843. # Get top cell classes by count for visualization clarity
  1844. top_cell_classes <- hierarchy_heatmap %>%
  1845. dplyr::group_by(cell_sub_class) %>%
  1846. dplyr::summarize(total = sum(n)) %>%
  1847. dplyr::arrange(desc(total)) %>%
  1848. utils::head(40) %>%
  1849. dplyr::pull(cell_sub_class)
  1850. p2 <- hierarchy_heatmap %>%
  1851. dplyr::filter(cell_sub_class %in% top_cell_classes) %>%
  1852. ggplot2::ggplot(ggplot2::aes(x = reorder(cell_sub_class, log_n),
  1853. y = reorder(cell_class, log_n),
  1854. fill = log_n)) +
  1855. ggplot2::geom_tile() +
  1856. #ggplot2::facet_wrap(~flow, ncol = 1, scales = "free_y") +
  1857. ggplot2::scale_fill_viridis_c(name = "log10(Count+1)") +
  1858. ggplot2::labs(title = "Hierarchical Relationship Matrix",
  1859. subtitle = " cell_class > cell_sub_class",
  1860. x = "cell_sub_class", y = "cell_class") +
  1861. ggplot2::theme_minimal() +
  1862. ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, hjust = 1, size = 7),
  1863. axis.text.y = ggplot2::element_text(size = 7),
  1864. panel.grid = ggplot2::element_blank())

franken-annotations-fix.R, under GPL-3.0 · at the source

Overview

Authors: Alexander S Bates1,2, Jasper S Phelps1,3, Minsu Kim1,4,5, Helen H Yang1, Arie Matsliah6, Zaki Ajabi1, Eric Perlman7, Kevin M Delgado1, Mohammed Abdal Monium Osman1, Christopher K Salmon6, Jay Gager6, Benjamin Silverman6, Sophia Renauld1, Farzaan Salman8,9, Janki Patel1, Matthew F Collie1, Jingxuan Fan1, Diego A Pacheco1, Yunzhi Zhao1, Wenyi Zhang1
and 81 other authorsLaia Serratosa Capdevila10, Ruairí J V Roberts10, Eva J Munnelly10, Nina Griggs10, Helen Langley10, Borja Moya-Llamas10, Zuoyu Zhang11,12, Ryan T Maloney13,14,15, Szi-chieh Yu6, Amy R Sterling6, Marissa Sorek6, Krzysztof Kruk16, Nikitas Serafetinidis16, Serene Dhawan6, Finja Klemm17, Paul Brooks18, Ellen Lesser19, Jessica M Jones20, Sara E Pierce-Lundgren20, Su-Yee Lee20, Yichen Luo20, Andrew P Cook21, Theresa H McKim22, Dimitrios Stasi Giakoumas23,24, Benjamin Gorko25, Justin Ellis-Joyce26,27, Jiayi Zhang28, Emily C Kophs29, Tjalda Falt30, Alexa M Negron-Morales31, Austin Burke6, James Hebditch6, Kyle P Willie6, Ryan Willie6, Sergiy Popovych32, Nico Kemnitz32, Dodam Ih32, Kisuk Lee32, Ran Lu32, Akhilesh Halageri32, J Alexander Bae32, Ben Jourdan33, Gregory Schwartzman34, Damian D Demarest35, Emily Behnke6, Doug Bland16, Anne Kristiansen16, Jaime Skelton16, Tom Stocks16, Dustin Garner25, Anthony Hernandez16, Sandeep Kumar6, The BANC-FlyWire Consortium36,37,38, Kevin C Daly8,39, Sven Dorkenwald40, Forrest Collman40, Marie P Suver29, Lisa M Fenk30, Michael J Pankratz35, Zepeng Yao23,41,42,43, Fei Wang28, Stephen J Huston44, Tomke Stürner45, Gregory S X E Jefferis18,45, Katharina Eichler17, Andrew M Seeds31, Stefanie Hampel31, Sweta Agrawal21, Tatsuo S Okubo11,12, Meet Zandawala46,47, Thomas Macrina32, Diane-Yayra Adjavon26, Jan Funke26, John C Tuthill20, Anthony Azevedo20, H Sebastian Seung6,48, Benjamin L de Bivort13,14, Mala Murthy6, Jan Drugowitsch1, Rachel I Wilson1, Wei-Chung Allen Lee1,49
49 affiliations
  1. Department of Neurobiology, Harvard Medical School, Boston, MA USA
  2. Centre for Neural Circuit and Behaviour, University of Oxford, Oxford, UK
  3. Present Address: Neuroengineering Laboratory, Brain Mind Institute and Institute of Bioengineering, EPFL, Lausanne, Switzerland
  4. Present Address: Department of Molecular and Cellular Biology, Harvard University, Cambridge, MA USA
  5. Present Address: Center for Brain Science, Harvard University, Cambridge, MA USA
  6. Princeton Neuroscience Institute, Princeton University, Princeton, NJ USA
  7. Yikes, Baltimore, MD USA
  8. Department of Biology, West Virginia University, Morgantown, WV USA
  9. Present Address: Department of Neurobiology, Harvard Medical School, Boston, MA USA
  10. Aelysia, Bristol, UK
  11. Beijing Institute for Brain Research, Chinese Academy of Medical Sciences and Peking Union Medical College, Beijing, China
  12. Chinese Institute for Brain Research, Beijing, Beijing, China
  13. Department of Organismic and Evolutionary Biology, Harvard University, Cambridge, MA USA
  14. Center for Brain Science, Harvard University, Cambridge, MA USA
  15. Present Address: Psychology Department, Colorado College, Colorado Springs, CO USA
  16. Eyewire, Boston, MA USA
  17. Genetics Department, Leipzig University, Leipzig, Germany
  18. Zoology Department, University of Cambridge, Cambridge, UK
  19. Department of Molecular Genetics and Cell Biology, The University of Chicago, Chicago, IL USA
  20. Department of Neurobiology and Biophysics, University of Washington, Seattle, WA USA
  21. School of Neuroscience, Virginia Tech, Blacksburg, VA USA
  22. Department of Biology, University of Nevada Reno, Reno, NV USA
  23. Department of Biology, University of Florida, Gainesville, FL USA
  24. Present Address: Interdisciplinary Graduate Program in Neuroscience, University of Iowa, Iowa City, IA USA
  25. Molecular, Cellular, and Developmental Biology, University of California Santa Barbara, Santa Barbara, CA USA
  26. HHMI Janelia, Ashburn, VA USA
  27. Department of Neuroscience, Johns Hopkins University, Baltimore, MD USA
  28. Institute of Neuroscience, Center for Excellence in Brain Science and Intelligence Technology, Chinese Academy of Sciences, Shanghai, China
  29. Department of Biological Sciences, Vanderbilt University, Nashville, TN USA
  30. Max Planck Institute for Biological Intelligence, Martinsried, Germany
  31. Institute of Neurobiology, University of Puerto Rico Medical Sciences Campus, San Juan, Puerto Rico
  32. Zetta AI, Sherrill, NY USA
  33. School of Informatics, University of Edinburgh, Edinburgh, UK
  34. Japan Advanced Institute of Science and Technology (JAIST), Nomi, Japan
  35. Molecular Brain Physiology and Behavior, LIMES Institute, University of Bonn, Bonn, Germany
  36. Champalimaud Neuroscience Programme, Champalimaud Centre for the Unknown, Lisbon, Portugal
  37. Department of Biology, Leipzig University, Leipzig, Germany
  38. RWTH Aachen University, Aachen, Germany
  39. Department of Neuroscience, West Virginia University, Morgantown, WV USA
  40. Allen Institute for Brain Science, Seattle, WA USA
  41. Florida Chemical Senses Institute, University of Florida, Gainesville, FL USA
  42. McKnight Brain Institute, University of Florida, Gainesville, FL USA
  43. Genetics Institute, University of Florida, Gainesville, FL USA
  44. Department of Neuroscience, Zuckerman Mind Brain Behavior Institute, Columbia University, New York, NY USA
  45. Neurobiology Division, MRC Laboratory of Molecular Biology, Cambridge, UK
  46. Department of Biochemistry and Molecular Biology, University of Nevada Reno, Reno, NV USA
  47. Neurobiology and Genetics, Theodor-Boveri-Institute, Biocenter, Julius-Maximilians-University of Würzburg, Am Hubland, Würzburg, Germany
  48. Computer Science Department, Princeton University, Princeton, NJ USA
  49. F. M. Kirby Neurobiology Center, Boston Children’s Hospital, Harvard Medical School, Boston, MA USA
Journal: Nature, volume 656, issue 8129, pages 957-970
Dates: received 1 August 2025; accepted 29 May 2026; published online 8 June 2026; in print 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1038/s41586-026-10735-w · PMID 42259917 · PMCID PMC13518251 · OpenAlex W4412828391
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: drosophila (organism)
Methods: Connectivity, Statistics, Smoothing, state filtering, decompositions, Machine learning, Preprocessing
Keywords: Neural circuits, Reflexes, Reward
MeSH: Connectome*, Drosophila melanogaster*, Neural Pathways*, Animals, Brain, Endocrine Cells, Female, Male, Motor Neurons, Neurons, Neurons, Efferent, Sensory Receptor Cells, Synapses (* major topic)
Topic: Neurobiology and Insect Physiology Research (Cellular and Molecular Neuroscience, Neuroscience), according to OpenAlex
Funding: NIMH NIH HHS (RF1 MH117808, RF1 MH129268); NIGMS NIH HHS (T32 GM144273); NINDS NIH HHS (R01 NS121874, U24 NS126935, R01 NS121911)
Citations: cited by 13 papers (Europe PMC); 331 references in the paper

Abstract

Just as genomes revolutionized molecular genetics, connectomes (maps of neurons and synapses) are transforming neuroscience. To date, the only organisms with complete connectomes are worms1–3, sea squirts4 and comb jellies5 (103–104 synapses). By contrast, the fruit fly is more complex (108 synaptic connections), with a brain that supports learning and spatial memory6,7 and an intricate ventral nerve cord analogous to the vertebrate spinal cord8–12. Here we report a densely reconstructed adult fly connectome that unites the brain and ventral nerve cord, and we leverage this resource to investigate principles of neural control. We show that effector neurons (motor neurons, endocrine cells and efferent neurons targeting the viscera) are primarily influenced by sensory neurons in the same body part, forming local feedback loops. These local loops are linked by long-range circuits that involve ascending and descending neurons organized into behaviour-centric modules. Single ascending and descending neurons are often positioned to influence the voluntary movements of multiple body parts, together with the endocrine cells or visceral organs that support those movements. Brain regions involved in learning and navigation supervise these circuits. These results reveal an architecture that is distributed, parallelized and embodied, reminiscent of distributed control architectures in engineered systems13,14.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repositories

Its files are read in the Code ↔ Paper reader above, with 40 matches between paragraphs and lines of code.

doi:10.7910/dvn/7wth1n

License: none: the authors keep all their rights
State: unreachable at the last attempt, verified on 29 September 2026
Evidence: found in the paper
Software Heritage: not checked
Found in: “Code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 5 checks, the latest on 29 September 2026: unreachable at the last attempt (HTTP 202)
  • 29 September 2026: unreachable at the last attempt (HTTP 202)
  • 28 September 2026: unreachable at the last attempt (HTTP 202)
  • 28 September 2026: unreachable at the last attempt (HTTP 202)
  • 27 September 2026: unreachable at the last attempt (HTTP 202)
  • 27 September 2026: unreachable at the last attempt (HTTP 202)

Zenodo 15999929

License: BSD-3-Clause
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: DataCite
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: pandas (4 files), NumPy (3 files), Matplotlib (1 file), SciPy (1 file), seaborn (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
8 files

jasper-tms/the-banc-fly-connectome

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 01d797a23beb5e79032e509d03b4218c3f5cc60e, 15 May 2026
Languages: Python (31), Jupyter (4), Shell (3)
Size: 410 files, 38 scripts
Software Heritage: not archived
Found in: the text, “Annotation taxonomy”
Holds: README, license file, environment (pyproject.toml), tests, continuous integration, 4 notebooks
Not found: CITATION.cff, documentation
Tools: NumPy (16 files), pandas (13 files), Matplotlib (3 files), scikit-image (1 file), SciPy (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
40 files

huit.harvard.edu/ai-sandbox

License: none: the authors keep all their rights
State: unreachable at the last attempt, verified on 29 September 2026
Evidence: found in the paper
Software Heritage: not checked
Found in: the text, “Data analysis and visualization”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 5 checks, the latest on 29 September 2026: unreachable at the last attempt (HTTP 403)
  • 29 September 2026: unreachable at the last attempt (HTTP 403)
  • 28 September 2026: unreachable at the last attempt (HTTP 403)
  • 28 September 2026: unreachable at the last attempt (HTTP 403)
  • 27 September 2026: unreachable at the last attempt (HTTP 403)
  • 27 September 2026: unreachable at the last attempt (HTTP 403)

console.cloud.google.com/storage/browser

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: the link answers
Software Heritage: not checked
Found in: “Data availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)

CAVEconnectome/pcg_skel

License: MIT
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: d0178be10a5a037e5fc64b8f754ef560f7466ee3, 14 April 2025
Languages: Python (12), Shell (1), Jupyter (1)
Size: 42 files, 14 scripts
Software Heritage: not archived
Found in: “Data availability”
Holds: README, license file, environment (pyproject.toml, uv.lock), tests, continuous integration, documentation, 1 notebook
Not found: CITATION.cff
Tools: NumPy (11 files), pandas (5 files), SciPy (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
16 files

sjcabs/fly_connectome_data_tutorial

License: MIT
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 85c66244cfb2c02b2442905c4428b42a0d8e6656, 7 June 2026
Languages: R (7), Shell (7), Jupyter (7), Python (3)
Size: 151 files, 24 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file, 12 notebooks
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: pandas (8 files), Plotly (8 files), NumPy (6 files), UMAP (6 files), NetworkX (4 files), SciPy (4 files), Matplotlib (3 files), reticulate (3 files), seaborn (3 files), tidyverse (3 files), pheatmap (2 files), ggplot2 (1 file), igraph (1 file), patchwork (1 file), scikit-learn (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
18 files

Zenodo 20350642

License: CC-BY-4.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
At the source:

Zenodo 20350572

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: tidyverse (199 files), ggplot2 (30 files), NumPy (20 files), pandas (19 files), igraph (13 files), reshape2 (12 files), data.table (10 files), pheatmap (9 files), Matplotlib (8 files), Plotly (8 files), SciPy (8 files), reticulate (7 files), UMAP (6 files), scikit-learn (3 files), ComplexHeatmap (2 files), NetworkX (2 files), seaborn (2 files), caret (1 file), circlize (1 file), ggpubr (1 file), scikit-image (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
334 files
At the source:

Zenodo 20350564

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: the references
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: reticulate (5 files), tidyverse (3 files), data.table (1 file), ggplot2 (1 file), NumPy (1 file), pandas (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
15 files
At the source:

Zenodo 20350570

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: the references
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: PyTorch (5 files), pandas (4 files), NumPy (3 files), scikit-learn (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
8 files
At the source:

Zenodo 20350648

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: the references
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
At the source:

Zenodo 20350566

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: the references
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: ggplot2 (5 files), tidyverse (3 files)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
20 files
At the source:

Zenodo 21282630

License: BSD-3-Clause
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: DataCite
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: pandas (4 files), NumPy (3 files), Matplotlib (1 file), SciPy (1 file), seaborn (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
8 files

Code availability

A comprehensive collection of community tools and software packages for working with the BANC dataset can be found at the project hub (https://banc.community) and the FlyWire Apps portal (https://flywire.ai/apps). All code developed for this project is open-source, publicly available and archived on the Harvard Dataverse repository (10.7910/DVN/7WTH1N). This archive contains the following repositories, also hosted on GitHub or Zenodo: the specific code used to perform the analyses and generate the figures for this manuscript (BANC-Project, 10.5281/zenodo.20350642)320; our data pre-processing pipeline post-proofreading for BANC, including skeletonization, neuron matching pipeline, neuron matching algorithms, metadata management, axon–dendrite splitting, neuropil assignment to synapses, among others (bancpipeline, 10.5281/zenodo.20350572)321; the Python code for computing influence scores (Connectome Influence Calculator, 10.5281/zenodo.15999929)42; the R code for computing influence scores (influencer, 10.5281/zenodo.20350564)322; the code for training and running the neurotransmitter prediction model (synister_banc, 10.5281/zenodo.20350570)323; the Python client code for querying and analysing BANC (banc, https://pypi.org/project/banc/); an R client package compatible with the natverse105 for querying and analysing BANC (bancr, 10.5281/zenodo.20350648)324; an R package for neuroanatomical plots (nat.ggplot, 10.5281/zenodo.20350566)325; and a Python + R tutorial for fly connectome data analyses that brings many of these tools and data together (fly_connectome_data_tutorial, https://github.com/sjcabs/fly_connectome_data_tutorial). We have also made our association of published, verified neurotransmission with connectomic cell types available as citable resources (drosophila_neurotransmitters210, 10.5281/zenodo.20818141, and drosophila_neuropeptides211, 10.5281/zenodo.20818143).

Reproduced under the paper's license (CC BY), from the paper cited above.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 14 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 448 scripts, each with its path and the digest of its content;
  • 40 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

Datasets cited

Data Availability Statement

Data are freely accessible through multiple platforms. A general overview of the resource and links to these tools are available at the BANC portal (https://banc.community). FlyWire Codex319 (https://codex.flywire.ai/banc (https://codex.flywire.ai/?dataset=banc)) provides an interactive web interface for exploring the BANC connectome, which enables users to search for neurons, visualize morphology, traverse synaptic pathways and download metadata such as cell-type annotations, neurotransmitter predictions and connectivity matrices. Volumetric EM data, including 3D neuron meshes and annotations, can be viewed at the BANC portal (https://ng.banc.community/view) or accessed programmatically via CAVE28. We used CAVE materialization v.626 (21 July 2025) for our preprint, and v.888 (17 April 2026) for the final print version. Static data and code dumps are also available for download from a DOI-minting repository, the Harvard Dataverse (10.7910/DVN/7WTH1N) and on a Google Storage Bucket (console.cloud.google.com/storage/browser/lee-lab_brain-and-nerve-cord-fly-connectome/). Note that this Harvard Dataverse version supersedes our previous Harvard Dataverse for the preprint216, v.626 (10.7910/DVN/8TFGGB). Direct downloads from the Harvard Dataverse and Google Storage Bucket include the following resources: the synaptic connectivity edgelist, NBLAST results of BANC neurons against hemibrain, FAFB, FANC and MANC as well as BANC all-by-all; neuronal L2 skeletons (made using: https://github.com/CAVEconnectome/pcg_skel); neuronal colorMIPs; influence scores; our aligned BANC metadata; template registrations; behavioural data for the BANC fly; and snapshots of our code. Ground-truth labels are available for neurotransmitters210 (10.5281/zenodo.20818141) and neuropeptides211 (10.5281/zenodo.20818143). Aligned image data and flat segmentation data for cells, nuclei and mitochondria are available on BossDB (DOI: 10.60533/boss-2025-941r, or URL: https://bossdb.org/project/bates_phelps_kim_yang2025 (https://urldefense.proofpoint.com/v2/url?u=https-3A__bossdb.org_project_bates-5Fphelps-5Fkim-5Fyang2025&d=DwMGaQ&c=WO-RGvefibhHBZq3fL85hQ&r=05CZNFMizRthoqFifTbE5jUpMoumJjV40DQodPJ0Tr8&m=0sTP3wKkE0-xEeet1nhSHdRSv704wfZtKhngRVYIPBVHo-teqHuAJJjpgWZjhHzB&s=JteUoybGQSHuaKyXIwIHtCs-i2WIZdH9dfgEKLaaiEc&e=)). Schematics are available as vector graphics from GitHub (https://github.com/wilson-lab/schematics?tab=readme-ov-file). Please see Supplementary Information for a full list of the data and code resources we have made available, along with their web addresses.

A comprehensive collection of community tools and software packages for working with the BANC dataset can be found at the project hub (https://banc.community) and the FlyWire Apps portal (https://flywire.ai/apps). All code developed for this project is open-source, publicly available and archived on the Harvard Dataverse repository (10.7910/DVN/7WTH1N). This archive contains the following repositories, also hosted on GitHub or Zenodo: the specific code used to perform the analyses and generate the figures for this manuscript (BANC-Project, 10.5281/zenodo.20350642)320; our data pre-processing pipeline post-proofreading for BANC, including skeletonization, neuron matching pipeline, neuron matching algorithms, metadata management, axon–dendrite splitting, neuropil assignment to synapses, among others (bancpipeline, 10.5281/zenodo.20350572)321; the Python code for computing influence scores (Connectome Influence Calculator, 10.5281/zenodo.15999929)42; the R code for computing influence scores (influencer, 10.5281/zenodo.20350564)322; the code for training and running the neurotransmitter prediction model (synister_banc, 10.5281/zenodo.20350570)323; the Python client code for querying and analysing BANC (banc, https://pypi.org/project/banc/); an R client package compatible with the natverse105 for querying and analysing BANC (bancr, 10.5281/zenodo.20350648)324; an R package for neuroanatomical plots (nat.ggplot, 10.5281/zenodo.20350566)325; and a Python + R tutorial for fly connectome data analyses that brings many of these tools and data together (fly_connectome_data_tutorial, https://github.com/sjcabs/fly_connectome_data_tutorial). We have also made our association of published, verified neurotransmission with connectomic cell types available as citable resources (drosophila_neurotransmitters210, 10.5281/zenodo.20818141, and drosophila_neuropeptides211, 10.5281/zenodo.20818143).

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 2, 28 September 2026

  • Publisher: n/a → Nature Portfolio

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 101 authors, 3 keywords, 13 MeSH terms, 3 funders, 303 references.

Cite

This paper

Bates, A. S., Phelps, J. S., Kim, M., Yang, H. H., Matsliah, A., Ajabi, Z., Perlman, E., Delgado, K. M., Osman, M. A. M., Salmon, C. K., Gager, J., Silverman, B., Renauld, S., Salman, F., Patel, J., Collie, M. F., Fan, J., Pacheco, D. A., Zhao, Y., . . . Lee, W.-C. A. (2026). Distributed control circuits across a brain-and-cord connectome. Nature, 656(8129), 957-970. https://doi.org/10.1038/s41586-026-10735-w

BibTeX

@article{bates2026distributed,
author = {Bates, Alexander S and Phelps, Jasper S and Kim, Minsu and Yang, Helen H and Matsliah, Arie and Ajabi, Zaki and Perlman, Eric and Delgado, Kevin M and Osman, Mohammed Abdal Monium and Salmon, Christopher K and Gager, Jay and Silverman, Benjamin and Renauld, Sophia and Salman, Farzaan and Patel, Janki and Collie, Matthew F and Fan, Jingxuan and Pacheco, Diego A and Zhao, Yunzhi and Zhang, Wenyi and Serratosa Capdevila, Laia and Roberts, Ruairí J V and Munnelly, Eva J and Griggs, Nina and Langley, Helen and Moya-Llamas, Borja and Zhang, Zuoyu and Maloney, Ryan T and Yu, Szi-chieh and Sterling, Amy R and Sorek, Marissa and Kruk, Krzysztof and Serafetinidis, Nikitas and Dhawan, Serene and Klemm, Finja and Brooks, Paul and Lesser, Ellen and Jones, Jessica M and Pierce-Lundgren, Sara E and Lee, Su-Yee and Luo, Yichen and Cook, Andrew P and McKim, Theresa H and Giakoumas, Dimitrios Stasi and Gorko, Benjamin and Ellis-Joyce, Justin and Zhang, Jiayi and Kophs, Emily C and Falt, Tjalda and Negron-Morales, Alexa M and Burke, Austin and Hebditch, James and Willie, Kyle P and Willie, Ryan and Popovych, Sergiy and Kemnitz, Nico and Ih, Dodam and Lee, Kisuk and Lu, Ran and Halageri, Akhilesh and Bae, J Alexander and Jourdan, Ben and Schwartzman, Gregory and Demarest, Damian D and Behnke, Emily and Bland, Doug and Kristiansen, Anne and Skelton, Jaime and Stocks, Tom and Garner, Dustin and Hernandez, Anthony and Kumar, Sandeep and {The BANC-FlyWire Consortium} and Daly, Kevin C and Dorkenwald, Sven and Collman, Forrest and Suver, Marie P and Fenk, Lisa M and Pankratz, Michael J and Yao, Zepeng and Wang, Fei and Huston, Stephen J and Stürner, Tomke and Jefferis, Gregory S X E and Eichler, Katharina and Seeds, Andrew M and Hampel, Stefanie and Agrawal, Sweta and Okubo, Tatsuo S and Zandawala, Meet and Macrina, Thomas and Adjavon, Diane-Yayra and Funke, Jan and Tuthill, John C and Azevedo, Anthony and Seung, H Sebastian and de Bivort, Benjamin L and Murthy, Mala and Drugowitsch, Jan and Wilson, Rachel I and Lee, Wei-Chung Allen},
title = {{Distributed control circuits across a brain-and-cord connectome}},
journal = {Nature},
year = {2026},
month = jun,
volume = {656},
number = {8129},
pages = {957--970},
publisher = {Nature Portfolio},
issn = {0028-0836},
doi = {10.1038/s41586-026-10735-w},
url = {https://doi.org/10.1038/s41586-026-10735-w},
pmid = {42259917},
pmcid = {PMC13518251}
}

RIS

TY - JOUR
AU - Bates, Alexander S
AU - Phelps, Jasper S
AU - Kim, Minsu
AU - Yang, Helen H
AU - Matsliah, Arie
AU - Ajabi, Zaki
AU - Perlman, Eric
AU - Delgado, Kevin M
AU - Osman, Mohammed Abdal Monium
AU - Salmon, Christopher K
AU - Gager, Jay
AU - Silverman, Benjamin
AU - Renauld, Sophia
AU - Salman, Farzaan
AU - Patel, Janki
AU - Collie, Matthew F
AU - Fan, Jingxuan
AU - Pacheco, Diego A
AU - Zhao, Yunzhi
AU - Zhang, Wenyi
AU - Serratosa Capdevila, Laia
AU - Roberts, Ruairí J V
AU - Munnelly, Eva J
AU - Griggs, Nina
AU - Langley, Helen
AU - Moya-Llamas, Borja
AU - Zhang, Zuoyu
AU - Maloney, Ryan T
AU - Yu, Szi-chieh
AU - Sterling, Amy R
AU - Sorek, Marissa
AU - Kruk, Krzysztof
AU - Serafetinidis, Nikitas
AU - Dhawan, Serene
AU - Klemm, Finja
AU - Brooks, Paul
AU - Lesser, Ellen
AU - Jones, Jessica M
AU - Pierce-Lundgren, Sara E
AU - Lee, Su-Yee
AU - Luo, Yichen
AU - Cook, Andrew P
AU - McKim, Theresa H
AU - Giakoumas, Dimitrios Stasi
AU - Gorko, Benjamin
AU - Ellis-Joyce, Justin
AU - Zhang, Jiayi
AU - Kophs, Emily C
AU - Falt, Tjalda
AU - Negron-Morales, Alexa M
AU - Burke, Austin
AU - Hebditch, James
AU - Willie, Kyle P
AU - Willie, Ryan
AU - Popovych, Sergiy
AU - Kemnitz, Nico
AU - Ih, Dodam
AU - Lee, Kisuk
AU - Lu, Ran
AU - Halageri, Akhilesh
AU - Bae, J Alexander
AU - Jourdan, Ben
AU - Schwartzman, Gregory
AU - Demarest, Damian D
AU - Behnke, Emily
AU - Bland, Doug
AU - Kristiansen, Anne
AU - Skelton, Jaime
AU - Stocks, Tom
AU - Garner, Dustin
AU - Hernandez, Anthony
AU - Kumar, Sandeep
AU - The BANC-FlyWire Consortium
AU - Daly, Kevin C
AU - Dorkenwald, Sven
AU - Collman, Forrest
AU - Suver, Marie P
AU - Fenk, Lisa M
AU - Pankratz, Michael J
AU - Yao, Zepeng
AU - Wang, Fei
AU - Huston, Stephen J
AU - Stürner, Tomke
AU - Jefferis, Gregory S X E
AU - Eichler, Katharina
AU - Seeds, Andrew M
AU - Hampel, Stefanie
AU - Agrawal, Sweta
AU - Okubo, Tatsuo S
AU - Zandawala, Meet
AU - Macrina, Thomas
AU - Adjavon, Diane-Yayra
AU - Funke, Jan
AU - Tuthill, John C
AU - Azevedo, Anthony
AU - Seung, H Sebastian
AU - de Bivort, Benjamin L
AU - Murthy, Mala
AU - Drugowitsch, Jan
AU - Wilson, Rachel I
AU - Lee, Wei-Chung Allen
TI - Distributed control circuits across a brain-and-cord connectome
T2 - Nature
J2 - Nature
PY - 2026
DA - 2026/06/08
VL - 656
IS - 8129
SP - 957
EP - 970
SN - 0028-0836
PB - Nature Portfolio
DO - 10.1038/s41586-026-10735-w
UR - https://doi.org/10.1038/s41586-026-10735-w
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41586-026-10735-w",
"type": "article-journal",
"title": "Distributed control circuits across a brain-and-cord connectome",
"container-title": "Nature",
"author": [
{
"family": "Bates",
"given": "Alexander S"
},
{
"family": "Phelps",
"given": "Jasper S"
},
{
"family": "Kim",
"given": "Minsu"
},
{
"family": "Yang",
"given": "Helen H"
},
{
"family": "Matsliah",
"given": "Arie"
},
{
"family": "Ajabi",
"given": "Zaki"
},
{
"family": "Perlman",
"given": "Eric"
},
{
"family": "Delgado",
"given": "Kevin M"
},
{
"family": "Osman",
"given": "Mohammed Abdal Monium"
},
{
"family": "Salmon",
"given": "Christopher K"
},
{
"family": "Gager",
"given": "Jay"
},
{
"family": "Silverman",
"given": "Benjamin"
},
{
"family": "Renauld",
"given": "Sophia"
},
{
"family": "Salman",
"given": "Farzaan"
},
{
"family": "Patel",
"given": "Janki"
},
{
"family": "Collie",
"given": "Matthew F"
},
{
"family": "Fan",
"given": "Jingxuan"
},
{
"family": "Pacheco",
"given": "Diego A"
},
{
"family": "Zhao",
"given": "Yunzhi"
},
{
"family": "Zhang",
"given": "Wenyi"
},
{
"family": "Serratosa Capdevila",
"given": "Laia"
},
{
"family": "Roberts",
"given": "Ruairí J V"
},
{
"family": "Munnelly",
"given": "Eva J"
},
{
"family": "Griggs",
"given": "Nina"
},
{
"family": "Langley",
"given": "Helen"
},
{
"family": "Moya-Llamas",
"given": "Borja"
},
{
"family": "Zhang",
"given": "Zuoyu"
},
{
"family": "Maloney",
"given": "Ryan T"
},
{
"family": "Yu",
"given": "Szi-chieh"
},
{
"family": "Sterling",
"given": "Amy R"
},
{
"family": "Sorek",
"given": "Marissa"
},
{
"family": "Kruk",
"given": "Krzysztof"
},
{
"family": "Serafetinidis",
"given": "Nikitas"
},
{
"family": "Dhawan",
"given": "Serene"
},
{
"family": "Klemm",
"given": "Finja"
},
{
"family": "Brooks",
"given": "Paul"
},
{
"family": "Lesser",
"given": "Ellen"
},
{
"family": "Jones",
"given": "Jessica M"
},
{
"family": "Pierce-Lundgren",
"given": "Sara E"
},
{
"family": "Lee",
"given": "Su-Yee"
},
{
"family": "Luo",
"given": "Yichen"
},
{
"family": "Cook",
"given": "Andrew P"
},
{
"family": "McKim",
"given": "Theresa H"
},
{
"family": "Giakoumas",
"given": "Dimitrios Stasi"
},
{
"family": "Gorko",
"given": "Benjamin"
},
{
"family": "Ellis-Joyce",
"given": "Justin"
},
{
"family": "Zhang",
"given": "Jiayi"
},
{
"family": "Kophs",
"given": "Emily C"
},
{
"family": "Falt",
"given": "Tjalda"
},
{
"family": "Negron-Morales",
"given": "Alexa M"
},
{
"family": "Burke",
"given": "Austin"
},
{
"family": "Hebditch",
"given": "James"
},
{
"family": "Willie",
"given": "Kyle P"
},
{
"family": "Willie",
"given": "Ryan"
},
{
"family": "Popovych",
"given": "Sergiy"
},
{
"family": "Kemnitz",
"given": "Nico"
},
{
"family": "Ih",
"given": "Dodam"
},
{
"family": "Lee",
"given": "Kisuk"
},
{
"family": "Lu",
"given": "Ran"
},
{
"family": "Halageri",
"given": "Akhilesh"
},
{
"family": "Bae",
"given": "J Alexander"
},
{
"family": "Jourdan",
"given": "Ben"
},
{
"family": "Schwartzman",
"given": "Gregory"
},
{
"family": "Demarest",
"given": "Damian D"
},
{
"family": "Behnke",
"given": "Emily"
},
{
"family": "Bland",
"given": "Doug"
},
{
"family": "Kristiansen",
"given": "Anne"
},
{
"family": "Skelton",
"given": "Jaime"
},
{
"family": "Stocks",
"given": "Tom"
},
{
"family": "Garner",
"given": "Dustin"
},
{
"family": "Hernandez",
"given": "Anthony"
},
{
"family": "Kumar",
"given": "Sandeep"
},
{
"literal": "The BANC-FlyWire Consortium"
},
{
"family": "Daly",
"given": "Kevin C"
},
{
"family": "Dorkenwald",
"given": "Sven"
},
{
"family": "Collman",
"given": "Forrest"
},
{
"family": "Suver",
"given": "Marie P"
},
{
"family": "Fenk",
"given": "Lisa M"
},
{
"family": "Pankratz",
"given": "Michael J"
},
{
"family": "Yao",
"given": "Zepeng"
},
{
"family": "Wang",
"given": "Fei"
},
{
"family": "Huston",
"given": "Stephen J"
},
{
"family": "Stürner",
"given": "Tomke"
},
{
"family": "Jefferis",
"given": "Gregory S X E"
},
{
"family": "Eichler",
"given": "Katharina"
},
{
"family": "Seeds",
"given": "Andrew M"
},
{
"family": "Hampel",
"given": "Stefanie"
},
{
"family": "Agrawal",
"given": "Sweta"
},
{
"family": "Okubo",
"given": "Tatsuo S"
},
{
"family": "Zandawala",
"given": "Meet"
},
{
"family": "Macrina",
"given": "Thomas"
},
{
"family": "Adjavon",
"given": "Diane-Yayra"
},
{
"family": "Funke",
"given": "Jan"
},
{
"family": "Tuthill",
"given": "John C"
},
{
"family": "Azevedo",
"given": "Anthony"
},
{
"family": "Seung",
"given": "H Sebastian"
},
{
"family": "de Bivort",
"given": "Benjamin L"
},
{
"family": "Murthy",
"given": "Mala"
},
{
"family": "Drugowitsch",
"given": "Jan"
},
{
"family": "Wilson",
"given": "Rachel I"
},
{
"family": "Lee",
"given": "Wei-Chung Allen"
}
],
"container-title-short": "Nature",
"volume": "656",
"issue": "8129",
"page": "957-970",
"DOI": "10.1038/s41586-026-10735-w",
"PMID": "42259917",
"PMCID": "PMC13518251",
"ISSN": "0028-0836",
"publisher": "Nature Portfolio",
"URL": "https://doi.org/10.1038/s41586-026-10735-w",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
8
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.7554/elife.96084 [code]
Organization of circuits linking descending input to motor output in the &lt;i&gt;Drosophila&lt;/i&gt; Male Adult Nerve Cord connectome.
Journal: eLife
In common: igraph, ggpubr, ggplot2, 1 other tool, drosophila, 40 references, 3 authors
[2] doi:10.3389/fnsys.2026.1822122 [code]
Convergence-divergence circuits for multimodal integration of innate and learned opponent valences.
Journal: Frontiers in systems neuroscience
In common: UMAP, igraph, NetworkX, 9 other tools, 39 references
[3] doi:10.1016/j.isci.2026.117359 [code]
Connectomic mapping of pharyngeal and gut sensory circuits in adult &lt;i&gt;Drosophila&lt;/i&gt;.
Journal: iScience
In common: Plotly, seaborn, tidyverse, 4 other tools, drosophila, 23 references, author Zepeng Yao
[4] doi:10.1038/s41467-026-72152-x [code]
Centralized brain networks controlling antennal grooming coordination.
Journal: Nature communications
In common: NetworkX, seaborn, scikit-learn, 4 other tools, drosophila, 26 references
[5] doi:10.1038/s41593-026-02388-9 [code]
Hippocampal CA3 connectomics reveals a gradient of mossy fiber inputs and selective feedforward inhibition onto pyramidal cells.
Journal: Nature neuroscience
In common: igraph, NetworkX, Plotly, 7 other tools, 7 references, 4 authors
[6] doi:10.1371/journal.pbio.3003959 [code]
Recurrent synapses between CO2-sensitive olfactory sensory neurons enable robust CO2 detection in Aedes aegypti mosquitoes.
Journal: PLoS biology
In common: seaborn, scikit-learn, pandas, 3 other tools, drosophila, 17 references, author Wei-Chung Allen Lee
[7] doi:10.1038/s41586-026-10797-w [code]
A global molecular code for birth order and neuronal identity in Drosophila.
Journal: Nature
In common: reticulate, igraph, data.table, 5 other tools, drosophila, 12 references, author Gregory S. X. E. Jefferis
[8] doi:10.1038/s42003-026-10957-8 [code]
Brain defence by the extracellular matrix protein Cochlin.
Journal: Communications biology
In common: caret, reticulate, UMAP, 20 other tools
[9] doi:10.1002/bies.70122 [code]
Imprecision in Vision: Lessons From Neural Circuits in the Fly.
Journal: BioEssays : news and reviews in molecular, cellular and developmental biology
In common: drosophila, 18 references
[10] doi:10.1093/bioinformatics/btag592 [code]
Network-based stratification of allele-specific expression reveals patient subgroups in Huntington's disease.
Journal: Bioinformatics (Oxford, England)
In common: reticulate, UMAP, igraph, 17 other tools

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.