The goal of fishr is to provide natverse access to the fish2 larval zebrafish whole-brain EM dataset. It follows the same general pattern as malecns and malevnc, providing dataset-specific helpers on top of the neuprintr package and a bridge to the broader natverse connectomics tooling for computational neuroanatomy.
The fish2 dataset is currently being proofread at Janelia Research Campus as part of a multi-institution collaboration including Harvard and Google Research.
The initial package focuses on:
- dataset selection helpers (
choose_fish(),with_fish()) - body id lookup (
fish_ids()) - neuprint metadata and connectivity queries (
fish_neuprint_meta(),fish_connection_table()) - DVID body annotations (
fish_dvid_annotations()) - neuroglancer meshes and skeletons (
read_fish_meshes(),read_fish_neurons()) - support for the coconat interface (
register_fish_coconat())
Installation
If you are new to R, we recommend installing the RStudio IDE and base R as detailed at https://posit.co/download/rstudio-desktop/#download.
To install the fishr package and its dependencies, in your R terminal do:
# install natmanager if needed
if (!requireNamespace("natmanager")) install.packages("natmanager")
natmanager::install(pkgs = "flyconnectome/fishr")You also need to make sure that you are authenticated to both clio and neuprint.
Authentication
Access to neuprint requires authentication. We recommend running:
in an interactive R session and following the prompts. This will help you record your token and offer to set the fish2 dataset/server as the default for all neuprint commands. See https://github.com/natverse/neuprintr#authentication to learn more about the relevant environment variables.
You need to authenticate with Clio API to interact with the Clio/DVID annotation system. You do this via a Google OAuth “dance” in your web browser which is automatically triggered by choose_fish() or functions that require Clio access. Note that the Clio and neuprint tokens look similar, but are not the same. Note also that the neuprint token appears to be indefinite while the Clio token currently lasts 3 weeks.
Example
This example shows some basic activities including finding ids by type, fetching metadata and connectivity information, and reading and plotting some retinal ganglion cell meshes.
library(fishr)
library(nat)
# you only have to run this once, but you can
fish_setup()
# find some RGCs
rgc10=fish_ids("RGC")[1:10]
# get metadata
fish_neuprint_meta(rgc10)
# connectivity query
fish_connection_table(rgc10, partners = "outputs")
# fetch some RGC meshes
rgcm <- read_fish_meshes(rgc10)
plot3d(rgcm)
# read and plot one fish skeleton
rgcn <- read_fish_neurons(rgc10[1])
plot3d(rgcn, col = "cyan")
# Get meshes for some ROIs. NB not all ROIs have meshes.
roi.meshes <- fish_roi_meshes(c("Midbrain", "Hindbrain"), .progress = "none")
wire3d(roi.meshes, col='grey')You can also set annotations programmatically. By default this will associate them with your email (and a timestamp) just like the Clio web interface. This can be very useful but be careful (and ask for help quickly on slack if you suspect an accident)!
anns=data.frame(bodyid=c(1001,1002), side='R', type='RGC_AF8')
fish_annotate(anns)
fish_annotate(anns, test=F)other useful packages
fishr has a set of core functions but there is a lot of useful functionality in other R packages for interacting with the FlyEM connectome data ecosystem, especially malevnc and neuprintr.
malevnc
malevnc is especially useful for interacting with the annotation and segmentation infrastructure (clio/DVID). You can use any function in the malevnc package after wrapping it in with_fish().
with_fish(malevnc::clio_fields())If you only ever use the fish dataset then doing choose_fish() once per session means that all subsequent malevnc functions will target the fish2 dataset.
choose_fish()
malevnc::clio_fields()
This already happens if you follow default prompts when you run fish_setup().
The key end user application for the malevnc package right now is probably setting clio annotations via malevnc::manc_annotate_body()
neuprintr
Similarly you can use all functions in the base neuprintr package. If you have followed the default prompts in fish_setup() and are not using other FlyEM datasets, then fish2 should be the default there too.
If you use other neuprint datasets then neuprintr uses the last (or only) neuprint connection made in a session and will target that dataset.
fc=fish_neuprint()
fc
neuprintr::neuprint_ROIs(conn = fc)coconatfly
You can also register fish2 as an extra dataset for coconatfly. Even if fish2 is not a fly this package provides a uniform approach to connectome analysis including connectivity clustering functions.
library(dplyr)
register_fish_coconat()
rgcmeta=coconatfly::cf_meta(coconatfly::cf_ids(fish2 = "RGC"))
rgcmetaAfter fetching metadata we can try connectivity clustering a subset of the neurons, in this case those from the right eye …
rgcmeta %>%
filter(side=="R") %>%
# nb we need group = F because the partner neurons aren't really typed yet
coconatfly::cf_cosine_plot(partners = 'o', group = FALSE)
hc = rgcmeta %>%
filter(side=="R") %>%
# nb we need group = F because the partner neurons aren't really typed yet
coconatfly::cf_cosine_plot(partners = 'o', group = FALSE, heatmap=F)
hcm = coconat::add_cluster_info(cf_meta(hc), hc, h = 1)