This example is designed to introduce some of the basic features of the catmaid package and the NeuroAnatomy Toolbox (nat) on which it builds.

The sample data is from an EM connectomics study of the Drosophila first instar larva by Albert Cardona and colleagues as submitted to and visible at

Fetching neurons

Now lets fetch the peripheral olfactory sensory neurons, reading them into a neuronlist() object called orns.

orns=read.neurons.catmaid("name:ORN (left|right)")

We can also add some useful metadata.

orns[,'side']= factor(sub(".* ORN ", "", orns[,'name']))
orns[,'Or']= factor(sub(" ORN.*", "", orns[,'name']))

We calculate both the side of the brain and the odorant receptor expressed by the olfactory sensory neurons. These two variables are stored as columns in a table (i.e. data.frame()) that is an attribute of the orns neuronlist object.

The catmaid package builds on nat, a general purpose R neuroanatomy package. You may want to read the nat documentation to learn about how nat handles single neurons, collections of neurons (called neuronlists) and their associated metadata.

Now repeat for the the second order projection neuron (PN) partners. Note use of search by annotation. See catmaid_skids() documentation for details.

# searches for annotation "ORN PNs"
pns=read.neurons.catmaid("ORN PNs")
pns[,'Or']= factor(sub(" PN.*", "", pns[,'name']))
pns[,'side']= factor(sub(".*(left|right)", "\\1", pns[,'name']))

Plotting neurons

Now let’s plot both sets of neurons, colouring by odorant receptor.

Going further

Finding synaptic partners

Now we can directly identify the downstream partner neurons of the ORNs and plots them in 3D coloured by their synaptic strength. It then carries out morphological clustering with NBLAST and plots the partner neurons according to those clusters.

Let’s find all the ORN downstream partners with at least 2 synapses

Note that although we exclude the downstream PNs

plot3d(orns, col=Or)
plot3d(non_pn_downstream, col='grey', soma=1000)

NBLAST cluster

Now let’s cluster these other connected neurons morphologically. This is often an efficient way to group neurons that may have distinct functions.

Plot result of clustering as dendrogram, labelled by abbreviated neuron name (rather than id).

plot(non_pn_downstream.hc, label=abbreviate(non_pn_downstream[,'name'], minlength = 8))

Plot in 3d cutting into 2 clusters essentially left right

plot3d(non_pn_downstream.hc,db=non_pn_downstream, k=2, soma=1000)

Let’s just try for one half of the brain. First we compute the side of brain based on the neuron names.

non_pn_downstream[grepl("left", non_pn_downstream[,'name']),'side']='L'
non_pn_downstream[grepl("right", non_pn_downstream[,'name']),'side']='R'

Then we select and cluster just the neurons on the right hand side.

Finally here is the plot with 4 clusters coloured.

plot3d(non_pn_downstream.hcr,db=non_pn_downstream, k=4, soma=1000)