diff --git a/docs/authors.html b/docs/authors.html index 3d13fae..abf5d49 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -23,14 +23,17 @@ - + + - + + +
@@ -49,6 +52,12 @@This package provides access to the CATMAID API for R users. At present it provides low level functions for appropriately authenticated GET/POST requests, optionally parsing JSON responses. There are also intermediate level functions that retrieve skeleton (i.e. neuron) information, connectivity information for one or more neurons as well as a number of other API endpoints. Finally, there is a high level function to convert neurons to the representation of the nat (NeuroAnatomy Toolbox) R package, enabling a wide variety of analyses.
+ +This package provides access to the CATMAID API for R users. At present it provides low level functions for appropriately authenticated GET/POST requests, optionally parsing JSON responses. There are also intermediate level functions that retrieve skeleton (i.e. neuron) information, connectivity information for one or more neurons as well as a number of other API endpoints. Finally, there is a high level function to convert neurons to the representation of the nat (NeuroAnatomy Toolbox) R package, enabling a wide variety of analyses.
It is strongly recommended to read through the instructions below, the package overview documentation and then skim the reference documentation index , which groups the available functions into useful categories.
# install
if (!require("devtools")) install.packages("devtools")
# nb repo is rcatmaid, but R package name is catmaid
-devtools::install_github("jefferis/rcatmaid")
+devtools::install_github("jefferis/rcatmaid")
# use
library(catmaid)
@@ -67,7 +93,7 @@
This produces a 3D plot of the first and second order olfactory neurons coloured according to the peripheral odorant receptor.
# fetch olfactory receptor neurons
orns=read.neurons.catmaid("name:ORN (left|right)", .progress='text')
@@ -84,27 +110,27 @@
This follows on from the previous example. It identifies 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.
# find all the ORN downstream partners with at least 2 synapses
orn_partners=catmaid_query_connected(orns[,'skid'], minimum_synapses = 2)
# keep the ones not already in our set of PNs
# there are lots!
-non_pn_downstream_ids=setdiff(unique(orn_partners$outgoing$partner), pns[,'skid'])
+non_pn_downstream_ids=setdiff(unique(orn_partners$outgoing$partner), pns[,'skid'])
# download and plot those neurons
non_pn_downstream=read.neurons.catmaid(non_pn_downstream_ids, .progress='text')
plot3d(non_pn_downstream, col='grey', soma=1000)
# remove the last set of plotted neurons
-npop3d()
+npop3d()
## Plot, but colouring partners by number of synapses they receive from ORNs
# first collect those synapse numbers
library(dplyr)
totsyndf=orn_partners$outgoing %>%
- group_by(partner) %>%
- summarise(totsyn=sum(syn.count)) %>%
- arrange(desc(totsyn))
+ group_by(partner) %>%
+ summarise(totsyn=sum(syn.count)) %>%
+ arrange(desc(totsyn))
hist(totsyndf$totsyn)
# now do the plot
clear3d()
@@ -121,16 +147,16 @@
# Now let's cluster these other connected neurons
library(nat.nblast)
# convert to nblast-compatible format
-# nb also convert from nm to um, resample to 1µm spacing and use k=5
+# nb also convert from nm to um, resample to 1µm spacing and use k=5
# nearest neighbours of each point to define tangent vector
-non_pn_downstream.dps=dotprops(non_pn_downstream/1e3, k=5, resample=1, .progress='text')
+non_pn_downstream.dps=dotprops(non_pn_downstream/1e3, k=5, resample=1, .progress='text')
# now compute all x all NBLAST scores and cluster
-non_pn_downstream.aba=nblast_allbyall(non_pn_downstream.dps, .progress='text')
-non_pn_downstream.hc=nhclust(scoremat = non_pn_downstream.aba)
+non_pn_downstream.aba=nblast_allbyall(non_pn_downstream.dps, .progress='text')
+non_pn_downstream.hc=nhclust(scoremat = non_pn_downstream.aba)
# plot result of clusterting as dendrogram, labelled by neuron name (rather than id)
plot(non_pn_downstream.hc, label=non_pn_downstream[,'name'])
# open new window
-nopen3d()
+nopen3d()
# plot in 3d cutting into 2 clusters essentially left right
plot3d(non_pn_downstream.hc,db=non_pn_downstream, k=2, soma=1000)
clear3d()
@@ -139,82 +165,100 @@
You will obviously need to have the login details of a valid CATMAID instance to try this out.
-You will obviously need to have the login details of a valid CATMAID instance to try this out. As of December 2015 CATMAID is moving to token based authentication. For this you will need to get an API token when you are logged into the CATMAID web client in your browser. See http://catmaid.github.io/dev/api.html#api-token for details.
+Once you have the login information you can use the catmaid_login
function to authenticate. The minimal information is your server URL and your CATMAID token.
catmaid_login(server="https://mycatmaidserver.org/catmaidroot",
+ authname="Calvin",authpassword="hobbes",
+ token="9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b")
Note that the CATMAID servers that I am aware of require two layers of password protection, an outer HTTP auth type user/password combination as well as an inner CATMAID-specific token based login. The outer HTTP auth type user/password combination may be specific to you or generic to the project.
+It is recommended that you set these details by including code like this in in your .Rprofile file:
-options(catmaid.server="https://mycatmaidserver.org/catmaidroot",
- catmaid.authname="Calvin",catmaid.authpassword="hobbes",
- catmaid.username="calvin", catmaid.password="hobbesagain")
In this way authentication will happen transparently as required by all functions that interact with the specified CATMAID server. Note that the CATMAID servers that I am aware of require two layers of password protection, an outer HTTP auth type user/password combination as well as an inner CATMAID-specific password.
+Setting environment variables in your .Renviron file +It is recommended that you set your login details by including code like this in in your .Renviron file:
+catmaid.server="https://mycatmaidserver.org/catmaidroot"
+catmaid.token="9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"
+
+# additional security for mycatmaidserver.org/catmaidroot page
+catmaid.authname="Calvin"
+catmaid.authpassword="hobbes"
Be sure to leave one blank line at the end of the .Renviron file, or it will not work.
+In this way authentication will happen transparently as required by all functions that interact with the specified CATMAID server.
As of December 2015 CATMAID is moving to token based authentication. For this you will need to get an API token when you are logged into the CATMAID web client in your browser. See http://catmaid.github.io/dev/api.html#api-token for details.
-You would then set your .Rprofile
like this:
Alternatively you can set package options in your .Rprofile file, but the environment variable approach is now recommended as it handles a few edge cases where options are not read by R processes e.g. when building vignettes.
options(catmaid.server="https://mycatmaidserver.org/catmaidroot",
catmaid.authname="Calvin",catmaid.authpassword="hobbes",
catmaid.token="9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b")
Note that you will probably still need to specify you http username/password combination even if you are using an API token to authenticate to the CATMAID server.
+Once again, be sure to leave one blank line at the end of the .Rprofile file, or it will not work.
Whether you use options in your .Rprofile
as described above or you login explicitly at the start of a session by doing something like:
catmaid_login(server="https://mycatmaidserver.org/catmaidroot",
- authname="Calvin",authpassword="hobbes",
- token="9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b")
the access credentials will be cached for the rest of the session. You can still authenticate explicitly to a different CATMAID server (using catmaid_login
) if you wish.
Whether you use options in your .Renviron
as described above or you login explicitly at the start of a session using catmaid_login
the access credentials will be cached for the rest of the session. You can still authenticate explicitly to a different CATMAID server (using catmaid_login
) if you wish.
If you need to talk to more than one catmaid server in a single session then you must use catmaid_login
to login into each server
# log in to default server specified in .Rprofile
-conn1=catmaid_login()
+Multiple servers
+If you use more than one CATMAID server but always do so in different sessions or rmarkdown scripts then you can save an appropriate .Renviron
file in the project folder.
+If you need to talk to more than one CATMAID server in a single session then you must use catmaid_login
to login into each server
+# log in to default server specified in .Renviron/.Rprofile
+conn1=catmaid_login()
# log into another server, presumably with different credentials
-conn2=catmaid_login(server='https://my.otherserver.com', ...)
+conn2=catmaid_login(server='https://my.otherserver.com', ...)
and then use the returned connection objects with any calls you make e.g.
# fetch neuron from server 1
-n1=read.neuron(123, conn=conn1)
+n1=read.neuron(123, conn=conn1)
# fetch neuron from server 2
-n2=read.neuron(123, conn=conn2)
nb you must use connection objects to talk to both servers because if no connection object is specified, the last connection will be re-used.
+n2=read.neuron(123, conn=conn2)n.b. you must use connection objects to talk to both servers because if no connection object is specified, the last connection will be re-used.
Currently there isn’t a released version on CRAN but can use the devtools package to install the development version:
+Installation +Currently there isn’t a released version on CRAN but can use the devtools package to install the development version:
if (!require("devtools")) install.packages("devtools")
-devtools::install_github("jefferis/rcatmaid")
Note: Windows users need Rtools and devtools to install this way.
Based on python code presently visible at:
-by Albert Cardona and Philipp Schlegel. Released under the GPL-3 license.
+by Albert Cardona and Philipp Schlegel. Released under the GPL-3 license.
Convert a mesh to CATMAID format
-as.catmaidmesh(x, ...) +as.catmaidmesh(x, ...) # S3 method for hxsurf as.catmaidmesh(x, ...) @@ -90,36 +99,42 @@Convert a mesh to CATMAID format
as.catmaidmesh(x, title = NULL, comment = NULL, ...)Arguments
-
hxsurf
or
+ x | +A mesh object such as |
+
---|---|
... | +Additional fields for the CATMAID mesh object |
+
title | +The title of the object as it will appear in the catmaid volume manager |
+
comment | +An informative comment - e.g. how the mesh was generated. |
+
The CATMAID mesh format is documented in the reference below and - typically consists of a json encoded object with fields
title
mesh The mesh itself (a list of length 2)
comments (optional)
In R we hold this list in a list
object with class
catmaidmesh
. This can then be posted to the volume manager API.
https://github.com/catmaid/CATMAID/blob/master/sphinx-doc/source/volumes.rst
+https://github.com/catmaid/CATMAID/blob/master/sphinx-doc/source/volumes.rst
To use, first call catmaid_login
to authenticate to a catmaid
+
To use, first call catmaid_login
to authenticate to a catmaid
server. You can then use functions such as
catmaid_get_neuronnames
or
catmaid_get_compact_skeleton
to query the server. You can also
@@ -88,12 +97,12 @@
catmaid_login
unless a catmaid_connection
+ catmaid_login
unless a catmaid_connection
object is provided as an argument.
See catmaid_login
for details of the
+
See catmaid_login
for details of the
options that can be set to specify default login values. It may make sense
to set these in your .Rprofile
if you regularly use a specific
CATMAID server. Beware however that your R workspace will then include a
@@ -109,28 +118,28 @@
Based in large part on code visible at - https://github.com/schlegelp/CATMAID-to-Blender/blob/master/CATMAIDImport.py - See http://catmaid.org for further details about CATMAID and - https://github.com/acardona/CATMAID/blob/master/django/applications/catmaid/urls.py + https://github.com/schlegelp/CATMAID-to-Blender/blob/master/CATMAIDImport.py + See http://catmaid.org for further details about CATMAID and + https://github.com/acardona/CATMAID/blob/master/django/applications/catmaid/urls.py for a list of URLs that the web API accepts.
+## Not run: ------------------------------------ -# ## test package -# library(catmaid) -# library(testthat) -# test_package("catmaid") -# -# ## same but use appropriate login info -# conn=catmaid_login(server="https://myserver.com", user="calvin", password='hobbes') -# ## alternatively, login using an API token -# # see http://catmaid.github.io/dev/api.html#api-token for how to get one -# conn=catmaid_login(server="https://myserver.com", -# token = "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b") -# catmaid_connection_setenv(conn) -# test_package("catmaid") -## ---------------------------------------------
# NOT RUN { +## test package +library(catmaid) +library(testthat) +test_package("catmaid") + +## same but use appropriate login info +conn=catmaid_login(server="https://myserver.com", user="calvin", password='hobbes') +## alternatively, login using an API token +# see http://catmaid.github.io/dev/api.html#api-token for how to get one +conn=catmaid_login(server="https://myserver.com", + token = "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b") +catmaid_connection_setenv(conn) +test_package("catmaid") +# }
Add a 3D mesh surface to catmaid volume manager
-catmaid_add_volume(x, conn = NULL, pid = 1, ...)+
catmaid_add_volume(x, conn = NULL, pid = 1, ...)
as.catmaidmesh
catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ x | +A mesh object such as hxsurf or a list with raw vertices and indices
+that will be passed to |
+
---|---|
conn | +A as.catmaidmesh such
-as title, comments etc.catmaid_login . |
+
pid | +Project id (default 1) |
+
... | +Additional arguments passed to |
+
+## Not run: ------------------------------------ -# library(elmr) -# FAFBNP.surf=xform_brain(JFRC2NP.surf, sample=JFRC2, ref=FAFB12) -# for(r in FAFBNP.surf$RegionList){ -# comment="Transformed from JFRC2 space onto FAFB12" -# name=paste("V12", sep=".", r) -# catmaid_add_volume(subset(FAFBNP.surf, r), title=name, comment=comment) -# } -## ---------------------------------------------
# NOT RUN { +library(elmr) +FAFBNP.surf=xform_brain(JFRC2NP.surf, sample=JFRC2, ref=FAFB12) +for(r in FAFBNP.surf$RegionList){ + comment="Transformed from JFRC2 space onto FAFB12" + name=paste("V12", sep=".", r) + catmaid_add_volume(subset(FAFBNP.surf, r), title=name, comment=comment) +} +# }
catmaid_connection_setenv
sets environment variables based on a
-catmaid_connection
object.
catmaid_connection_getenv
fetches appropriately named environment
-variables and uses them to open a catmaid connection.
catmaid_connection_unsetenv
unsets the environment variables.
catmaid_connection
object.
- Fetch connection details from appropriate environment variables
+catmaid_connection_getenv
fetches appropriately named environment
+variables and returns them as named character vector.
- Unset catmaid connection environment variables
+catmaid_connection_unsetenv
unsets the environment variables.
+Fetch connection details from appropriate environment variables
+Unset catmaid connection environment variables
-catmaid_connection_setenv(conn = NULL, ...) +catmaid_connection_setenv(conn = NULL, ...) -catmaid_connection_getenv(...) +catmaid_connection_getenv() catmaid_connection_unsetenv()Arguments
-
catmaid_connection
object. The default value of NULL
-implies that the most recent cached open connection will be used.catmaid_login
conn | +A |
+
---|---|
... | +additional arguments passed to |
+
catmaid_login
Return the entity ids for one or more model ids
-catmaid_entities_from_models(skids, pid = 1, conn = NULL, ...)+
catmaid_entities_from_models(skids, pid = 1, conn = NULL, ...)
catmaid_skids
or examples for the syntax).catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ skids | +One or more numeric skeleton ids or a character vector defining
+a query (see |
+
---|---|
pid | +Project id (default 1) |
+
conn | +A catmaid_fetch
-functioncatmaid_login . |
+
... | +Additional arguments passed to the |
+
catmaid_fetch(path, body = NULL, conn = NULL, parse.json = TRUE, +catmaid_fetch(path, body = NULL, conn = NULL, parse.json = TRUE, include_headers = TRUE, simplifyVector = FALSE, ...)Arguments
-
path | +The path on the CATMAID server relative to the CATMAID root |
+
---|---|
body | +The (optional) body of the post request, usually in the form of a
named list. See the catmaid_connection objection returned by
-catmaid_login . If NULL (the default) a new connection
+details. |
+
conn | +A TRUE )catmaid_login . |
+
parse.json | +Whether or not to parse a JSON response to an R object
+(default |
+
include_headers | +Whether to include basic headers from the http request
as attributes on the parsed JSON object (default httr::GET or
-httr::POST functionparse.json=TRUE . |
+
simplifyVector | +Wheter to use jsonlite::simplifyVector |
+
... | +Additional arguments passed to the |
+
catmaid_login
, GET
,
+
+## Not run: ------------------------------------ -# ## Make a catmaid_connection object to use for these requests -# conn=catmaid_login() -# -# ## fetch a demo skeleton using a GET request -# # raw response -# skel.response=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) -# # list object -# skel=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) -# -# ## Get the names of two skeletons using a POST request -# # NB that the skids[n] elements are quoted when constructing the list since -# # they are not valid R names. -# catmaid_fetch("/1/skeleton/neuronnames", conn=conn, -# body=list(pid=1, 'skids[1]'=10418394, 'skids[2]'=4453485)) -# -# ## get all skeletons with more than 1000 nodes -# skids=as.integer(catmaid_fetch("/1/skeletons/?nodecount_gt=1000")) -# -# ## fetch user history since 1st April 2016 -# uh = catmaid_fetch('1/stats/history?start_date=2016-04-01', -# simplifyVector = T, include_headers = F) -# uh$date=as.Date(uh$date,"%Y%m%d") -# library(dplyr) -# # select top 10 users by nodes added -# top10=uh %>% -# group_by(name) %>% -# summarise(total=sum(count)) %>% -# arrange(desc(total)) %>% -# top_n(10) -# # plot cumulative nodes traced -# library(ggplot2) -# uh %>% -# group_by(name) %>% -# mutate(ccount = cumsum(count)) %>% -# filter(name %in% top10$name) %>% -# ggplot(aes(date, ccount, col = name)) + geom_line() -# -# ## demonstrate that bad urls will result in an error -# catmaid_fetch("/1/rhubarb/crumble") -## ---------------------------------------------
# NOT RUN { +## Make a catmaid_connection object to use for these requests +conn=catmaid_login() + +## fetch a demo skeleton using a GET request +# raw response +skel.response=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) +# list object +skel=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) + +## Get the names of two skeletons using a POST request +# NB that the skids[n] elements are quoted when constructing the list since +# they are not valid R names. +catmaid_fetch("/1/skeleton/neuronnames", conn=conn, + body=list(pid=1, 'skids[1]'=10418394, 'skids[2]'=4453485)) + +## get all skeletons with more than 1000 nodes +skids=as.integer(catmaid_fetch("/1/skeletons/?nodecount_gt=1000")) + +## fetch user history since 1st April 2016 +uh = catmaid_fetch('1/stats/history?start_date=2016-04-01', + simplifyVector = T, include_headers = F) +uh$date=as.Date(uh$date,"%Y%m%d") +library(dplyr) +# select top 10 users by nodes added +top10=uh %>% + group_by(name) %>% + summarise(total=sum(count)) %>% + arrange(desc(total)) %>% + top_n(10) +# plot cumulative nodes traced +library(ggplot2) +uh %>% + group_by(name) %>% + mutate(ccount = cumsum(count)) %>% + filter(name %in% top10$name) %>% + ggplot(aes(date, ccount, col = name)) + geom_line() + +## demonstrate that bad urls will result in an error +catmaid_fetch("/1/rhubarb/crumble") +# }
Get list of annotations (including user information) from CATMAID
-catmaid_get_annotationlist(pid = 1, conn = NULL, raw = FALSE, ...)+
catmaid_get_annotationlist(pid = 1, conn = NULL, raw = FALSE, ...)
catmaid_connection
objectTRUE
)
+ pid | +project id (default 1) |
+
---|---|
conn | +the |
+
raw | +Whether to return completely unprocessed data (when catmaid_fetch
-function.FALSE , the default) |
+
... | +Additional arguments passed to the |
+
+## Not run: ------------------------------------ -# al=catmaid_get_annotationlist(pid=1) -# # table of the number of users who have contributed to each annotation -# table(al$annotations$num_users_annotation) -## ---------------------------------------------
# NOT RUN { +al=catmaid_get_annotationlist(pid=1) +# table of the number of users who have contributed to each annotation +table(al$annotations$num_users_annotation) +# }
Pretty obviously: catmaid_get_annotations_for_skeletons
gets annotations from one or more neurons.
Pretty obviously: catmaid_set_annotations_for_skeletons
+
Pretty obviously: catmaid_set_annotations_for_skeletons
sets annotations for one or more neurons. Although adding annotations is
non-destructive, please use carefully since this will be making
changes on the server!
catmaid_get_annotations_for_skeletons(skids, pid = 1, conn = NULL, ...) +catmaid_get_annotations_for_skeletons(skids, pid = 1, conn = NULL, ...) catmaid_set_annotations_for_skeletons(skids, annotations, pid = 1, conn = NULL, ...) @@ -93,43 +101,53 @@Get or set annotations for neurons from CATMAID
pid = 1, conn = NULL, ...)Arguments
-
catmaid_skids
or examples for the syntax).catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ skids | +One or more numeric skeleton ids or a character vector defining
+a query (see |
+
---|---|
pid | +Project id (default 1) |
+
conn | +A catmaid_fetch
-functioncatmaid_login . |
+
... | +Additional arguments passed to the |
+
annotations | +Character vector of one or more named annotations to add +to the specified neurons. |
+
force | +Whether to force the catmaid server to remove multiple
annotations (default |
+
For catmaid_get_annotations_for_skeletons
a data.frame
- containing the following columns
For catmaid_set_annotations_for_skeletons
a list containing
+ containing the following columns
skid The skeleton id
annotation The annotation string
id The annotation id
uid The user id for the annotation
For catmaid_set_annotations_for_skeletons
a list containing
information about the annotations that have just been added.
For catmaid_remove_annotations_for_skeletons
a list containing
information about the annotations that have just been removed.
+## Not run: ------------------------------------ -# catmaid_get_annotations_for_skeletons(skids=c(10418394,4453485)) -# catmaid_get_annotations_for_skeletons("name:ORN (left|right)") -# catmaid_get_annotations_for_skeletons("annotation:ORN PNs$") -## --------------------------------------------- -## Not run: ------------------------------------ -# catmaid_set_annotations_for_skeletons(skids=c(10418394,4453485), 'myselection') -# catmaid_set_annotations_for_skeletons(skids="annotation:ORN PNs$", 'my pns') -## --------------------------------------------- -## Not run: ------------------------------------ -# nn=c(10418394,4453485) -# catmaid_set_annotations_for_skeletons(skids=nn, 'mytest') -# catmaid_remove_annotations_for_skeletons(nn, 'mytest') -## ---------------------------------------------
# NOT RUN { +catmaid_get_annotations_for_skeletons(skids=c(10418394,4453485)) +catmaid_get_annotations_for_skeletons("name:ORN (left|right)") +catmaid_get_annotations_for_skeletons("annotation:ORN PNs$") +# }# NOT RUN { +catmaid_set_annotations_for_skeletons(skids=c(10418394,4453485), 'myselection') +catmaid_set_annotations_for_skeletons(skids="annotation:ORN PNs$", 'my pns') +# }# NOT RUN { +nn=c(10418394,4453485) +catmaid_set_annotations_for_skeletons(skids=nn, 'mytest') +catmaid_remove_annotations_for_skeletons(nn, 'mytest') +# }
Return the raw data for a CATMAID neuronal skeleton
-catmaid_get_compact_skeleton(skid, pid = 1L, conn = NULL, +catmaid_get_compact_skeleton(skid, pid = 1L, conn = NULL, connectors = TRUE, tags = TRUE, raw = FALSE, ...)Arguments
-
catmaid_connection
objectTRUE
)
+ skid | +single skeleton id |
+
---|---|
pid | +project id (default 1) |
+
conn | +the |
+
connectors | +Whether to fetch connector information |
+
tags | +Whether to fetch tag information |
+
raw | +Whether to return completely unprocessed data (when catmaid_fetch
-function.FALSE , the default) |
+
... | +Additional arguments passed to the |
+
An R list object with three elements
nodes A data frame containing XYZ location, node identifiers etc for + each point in the neuron.
connectors A data frame containing the position and tree node + identifiers for the synaptic partners.
tags A list containing one vector for each named tag; the vectors
+ contain node ids that are also present in the nodes
element.
read.neuron.catmaid
to read as neuroanatomy toolbox
+
read.neuron.catmaid
to read as neuroanatomy toolbox
neuron that can be plotted directly. catmaid_fetch
.
+## Not run: ------------------------------------ -# ## ensure that you have done something like -# # conn=catmaid_login() -# # at least once this session to connect to the server -# skel=catmaid_get_compact_skeleton(10418394) -# # no connector (i.e. synapse) information -# skel=catmaid_get_compact_skeleton(10418394, connectors = FALSE) -# -## ---------------------------------------------
# NOT RUN { +## ensure that you have done something like +# conn=catmaid_login() +# at least once this session to connect to the server +skel=catmaid_get_compact_skeleton(10418394) +# no connector (i.e. synapse) information +skel=catmaid_get_compact_skeleton(10418394, connectors = FALSE) + +# }
Return connector table for a given neuron
-catmaid_get_connector_table(skids, direction = c("both", "incoming", +catmaid_get_connector_table(skids, direction = c("both", "incoming", "outgoing"), partner.skids = TRUE, pid = 1, conn = NULL, raw = FALSE, ...)Arguments
-
catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ skids | +Numeric skeleton ids |
+
---|---|
direction | +whether to find incoming or outgoing connections |
+
partner.skids | +Whether to include information about the skid of each +partner neuron (NB there may be multiple partners per connector) |
+
pid | +Project id (default 1) |
+
conn | +A TRUE )
+options as described in the help for catmaid_login . |
+
raw | +Whether to return completely unprocessed data (when catmaid_fetch
-functionFALSE , the default) |
+
... | +Additional arguments passed to the |
+
As of CATMAID v2016.10.18 this returns a data.frame with columns -
Prior to this it returned a data.frame with columns
As of CATMAID v2016.10.18 this returns a data.frame with columns
skid
connector_id
x
y
z
confidence
user_id
partner_treenode_id
last_modified
partner_skid
Prior to this it returned a data.frame with columns
connector_id
partner_skid
x
y
z
s
confidence
tags
nodes_in_partner
username
partner_treenode_id
last_modified
+## Not run: ------------------------------------ -# # fetch connector table for neuron 10418394 -# ct=catmaid_get_connector_table(10418394) -# # compare number of incoming and outgoing synapses -# table(ct$direction) -# -# ## Look at synapse location in 3d -# # plot the neuron skeleton in grey for context -# library(nat) -# nopen3d() -# plot3d(read.neurons.catmaid(10418394), col='grey') -# # note use of nat::xyzmatrix to get xyz positions from the ct data.frame -# # colour synapses by direction -# points3d(xyzmatrix(ct), col=as.integer(ct$direction)) -# -# ## plot connected neurons in context of brain -# nopen3d() -# # fetch and plot brain model -# models=catmaid_fetch("1/stack/5/models") -# vs=matrix(as.numeric(models$cns$vertices), ncol=3, byrow = TRUE) -# points3d(vs, col='grey', size=1.5) -# -# # fetch and plot neurons -# plot3d(read.neurons.catmaid(10418394), col='black', lwd=3) -# points3d(xyzmatrix(ct), col=as.integer(ct$direction)) -# -# partner_neuron_ids=unique(na.omit(as.integer(ct$partner_skid))) -# partner_neurons=read.neurons.catmaid(partner_neuron_ids, .progress='text', OmitFailures = TRUE) -# plot3d(partner_neurons) -## ---------------------------------------------
# NOT RUN { +# fetch connector table for neuron 10418394 +ct=catmaid_get_connector_table(10418394) +# compare number of incoming and outgoing synapses +table(ct$direction) + +## Look at synapse location in 3d +# plot the neuron skeleton in grey for context +library(nat) +nopen3d() +plot3d(read.neurons.catmaid(10418394), col='grey') +# note use of nat::xyzmatrix to get xyz positions from the ct data.frame +# colour synapses by direction +points3d(xyzmatrix(ct), col=as.integer(ct$direction)) + +## plot connected neurons in context of brain +nopen3d() +# fetch and plot brain model +models=catmaid_fetch("1/stack/5/models") +vs=matrix(as.numeric(models$cns$vertices), ncol=3, byrow = TRUE) +points3d(vs, col='grey', size=1.5) + +# fetch and plot neurons +plot3d(read.neurons.catmaid(10418394), col='black', lwd=3) +points3d(xyzmatrix(ct), col=as.integer(ct$direction)) + +partner_neuron_ids=unique(na.omit(as.integer(ct$partner_skid))) +partner_neurons=read.neurons.catmaid(partner_neuron_ids, .progress='text', OmitFailures = TRUE) +plot3d(partner_neurons) +# }
Return skeleton ids for pre/postsynaptic partners of a set of connector_ids
-catmaid_get_connectors(connector_ids, pid = 1, conn = NULL, raw = FALSE, +catmaid_get_connectors(connector_ids, pid = 1, conn = NULL, raw = FALSE, ...)Arguments
-
catmaid_connection
objectTRUE
)
+ connector_ids | +Numeric ids for each connector (synapse). |
+
---|---|
pid | +project id (default 1) |
+
conn | +the |
+
raw | +Whether to return completely unprocessed data (when catmaid_fetch
-function.FALSE , the default) |
+
... | +Additional arguments passed to the |
+
A data.frame with columns
A data.frame with columns
connector_id
pre
post
Return information about connectors joining sets of pre/postsynaptic skids
-catmaid_get_connectors_between(pre_skids = NULL, post_skids = NULL, +catmaid_get_connectors_between(pre_skids = NULL, post_skids = NULL, pid = 1, conn = NULL, raw = FALSE, ...)Arguments
-
catmaid_skids
or NULL
meaning no restriction.catmaid_connection
objectTRUE
)
+ pre_skids, post_skids | +Skeleton ids in any form understood by
+ |
+
---|---|
pid | +project id (default 1) |
+
conn | +the |
+
raw | +Whether to return completely unprocessed data (when catmaid_fetch
-function.FALSE , the default) |
+
... | +Additional arguments passed to the |
+
A data.frame with columns
A data.frame with columns
pre_skid
post_skid
connector_id
pre_node_id
post_node_id
connector_x
connector_y
connector_z
pre_node_x
pre_node_y
pre_node_z
post_node_x
post_node_y
post_node_z
pre_confidence
pre_user
post_confidence
post_user
If either the pre_skids
or post_skids
arguments are
not specified (taking the default NULL
value) then this implies
- there is no restriction on the pre- (or post-) synaptic partners.
Each row is a unique set of pre_synaptic node, post_synaptic node, + there is no restriction on the pre- (or post-) synaptic partners.
+Each row is a unique set of pre_synaptic node, post_synaptic node, connector_id. A rare (and usually erroneous) scenario is if the same pre_node and post_node are present with two different connector_ids - this would create two rows.
diff --git a/docs/reference/catmaid_get_contributor_stats.html b/docs/reference/catmaid_get_contributor_stats.html index 552c676..cae2ed8 100644 --- a/docs/reference/catmaid_get_contributor_stats.html +++ b/docs/reference/catmaid_get_contributor_stats.html @@ -23,14 +23,17 @@ - + + - + + + @@ -49,6 +52,12 @@Get contributor statistics for neurons from CATMAID
-catmaid_get_contributor_stats(skids, pid = 1, conn = NULL, ...)+
catmaid_get_contributor_stats(skids, pid = 1, conn = NULL, ...)
catmaid_skids
or examples for the syntax).catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ skids | +One or more numeric skeleton ids or a character vector defining
+a query (see |
+
---|---|
pid | +Project id (default 1) |
+
conn | +A catmaid_fetch
-functioncatmaid_login . |
+
... | +Additional arguments passed to the |
+
a list containing different statistics including construction and review times (aggregated across all the specified input neurons). There will also be 3 data.frames containing statistics for number of nodes and - pre/post-synaptic connectors broken down per user.
-pre_contributors number of pre-synaptic connectors contributed per + user.
node_contributors number of skeleton nodes contributed per user.
post_contributors number of post-synaptic connectors contributed per + user.
+## Not run: ------------------------------------ -# cs=catmaid_get_contributor_stats(skids=c(10418394,4453485)) -# # fetch user list -# ul=catmaid_get_user_list() -# # merge with list of node contributors and sort in descending order of -# # contributions -# library(dplyr) -# left_join(cs$node_contributors, ul) %>% -# select(id,n, full_name) %>% -# arrange(desc(n)) -## ---------------------------------------------
# NOT RUN { +cs=catmaid_get_contributor_stats(skids=c(10418394,4453485)) +# fetch user list +ul=catmaid_get_user_list() +# merge with list of node contributors and sort in descending order of +# contributions +library(dplyr) +left_join(cs$node_contributors, ul) %>% + select(id,n, full_name) %>% + arrange(desc(n)) +# }
Get statistics for all labels in a project from a CATMAID server
+ + +catmaid_get_label_stats(pid = 1, conn = NULL, ...)+ +
pid | +Project id (default 1) |
+
---|---|
conn | +A |
+
... | +Additional arguments passed to the |
+
+label_stats=catmaid_get_label_stats() +library(dplyr)#> +#> Attaching package: ‘dplyr’#> The following objects are masked from ‘package:nat’: +#> +#> intersect, setdiff, union#> The following objects are masked from ‘package:stats’: +#> +#> filter, lag#> The following objects are masked from ‘package:base’: +#> +#> intersect, setdiff, setequal, union# select soma labels +soma_labels=label_stats %>% + filter(labelName=='soma') %>% + group_by(skeletonID) + +# select skeleton ids for neurons with multiple cell bodies +multiple_soma=soma_labels %>% + count(skeletonID) %>% + filter(n>1) %>% + arrange(desc(n)) + +multiple_soma_info = soma_labels %>% + filter(skeletonID%in% multiple_soma$skeletonID)
Get names of neurons from CATMAID
-catmaid_get_neuronnames(skids, pid = 1, conn = NULL, ...)+
catmaid_get_neuronnames(skids, pid = 1, conn = NULL, ...)
catmaid_skids
or examples for the syntax).catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ skids | +One or more numeric skeleton ids or a character vector defining
+a query (see |
+
---|---|
pid | +Project id (default 1) |
+
conn | +A catmaid_fetch
-functioncatmaid_login . |
+
... | +Additional arguments passed to the |
+
+## Not run: ------------------------------------ -# catmaid_get_neuronnames(skids=c(10418394,4453485)) -# catmaid_get_neuronnames("name:ORN (left|right)") -# catmaid_get_neuronnames("annotation:ORN PNs$") -## ---------------------------------------------
# NOT RUN { +catmaid_get_neuronnames(skids=c(10418394,4453485)) +catmaid_get_neuronnames("name:ORN (left|right)") +catmaid_get_neuronnames("annotation:ORN PNs$") +# }
Get review status of neurons from CATMAID
-catmaid_get_review_status(skids, pid = 1, conn = NULL, ...)+
catmaid_get_review_status(skids, pid = 1, conn = NULL, ...)
catmaid_skids
or examples for the syntax).catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ skids | +One or more numeric skeleton ids or a character vector defining
+a query (see |
+
---|---|
pid | +Project id (default 1) |
+
conn | +A catmaid_fetch
-functioncatmaid_login . |
+
... | +Additional arguments passed to the |
+
+## Not run: ------------------------------------ -# catmaid_get_review_status(skids=c(10418394,4453485)) -## ---------------------------------------------
# NOT RUN { +catmaid_get_review_status(skids=c(10418394,4453485)) +# }
Return tree node table for a given neuron
-catmaid_get_treenode_table(skid, pid = 1, conn = NULL, raw = FALSE, ...)+
catmaid_get_treenode_table(skid, pid = 1, conn = NULL, raw = FALSE, ...)
catmaid_connection
objectTRUE
)
+ skid | +Numeric skeleton id |
+
---|---|
pid | +project id (default 1) |
+
conn | +the |
+
raw | +Whether to return completely unprocessed data (when catmaid_fetch
-function.FALSE , the default) |
+
... | +Additional arguments passed to the |
+
A data.frame with columns
In addition two data.frames will be included as attributes: reviews
,
+
A data.frame with columns
id
parent_id
confidence
x
y
z
r
user_id
last_modified
reviewer_id (character vector with comma separated reviewer ids)
In addition two data.frames will be included as attributes: reviews
,
tags
.
+## Not run: ------------------------------------ -# # get tree node table for neuron 10418394 -# tnt=catmaid_get_treenode_table(10418394) -# # show all leaf nodes -# subset(tnt, type=="L") -# # table of node types -# table(tnt$type) -# -# # look at tags data -# str(attr(tnt, 'tags')) -# # merge with main node table to get xyz position -# tags=merge(attr(tnt, 'tags'), tnt, by='id') -# # label up a 3d neuron plot -# n=read.neuron.catmaid(10418394) -# plot3d(n, WithNodes=F) -# text3d(xyzmatrix(tags), texts = tags$tag, cex=.7) -## ---------------------------------------------
# NOT RUN { +# get tree node table for neuron 10418394 +tnt=catmaid_get_treenode_table(10418394) +# show all leaf nodes +subset(tnt, type=="L") +# table of node types +table(tnt$type) + +# look at tags data +str(attr(tnt, 'tags')) +# merge with main node table to get xyz position +tags=merge(attr(tnt, 'tags'), tnt, by='id') +# label up a 3d neuron plot +n=read.neuron.catmaid(10418394) +plot3d(n, WithNodes=F) +text3d(xyzmatrix(tags), texts = tags$tag, cex=.7) +# }
Fetch list of catmaid users for current/specified connection/project
-catmaid_get_user_list(pid = 1, conn = NULL, ...)+
catmaid_get_user_list(pid = 1, conn = NULL, ...)
catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ pid | +Project id (default 1) |
+
---|---|
conn | +A catmaid_fetch
-functioncatmaid_login . |
+
... | +Additional arguments passed to the |
+
+## Not run: ------------------------------------ -# catmaid_get_user_list() -## ---------------------------------------------
# NOT RUN { +catmaid_get_user_list() +# }
catmaid_connection
object. If such an object is not
specified, then the last succesful connection in this R session is reused
if possible otherwise a new connection object is created using
- options
of the form "catmaid.*" (see details).
-
- The connection object returned by catmaid_login
(or cached when
+ options
of the form "catmaid.*" (see details).
The connection object returned by catmaid_login
(or cached when
Cache=TRUE
, the default) can then be used for future requests to the
- CATMAID server by get/query/fetch functions.
catmaid_connection
is a lower level function used by
+ catmaid_connection
is a lower level function used by
catmaid_login
to create a connection object. End users should not
need to call this directly, but it does document the arguments that can be
used to specify a connection to a CATMAID server.
catmaid_login(conn = NULL, ..., Cache = TRUE, Force = FALSE) +catmaid_login(conn = NULL, ..., Cache = TRUE, Force = FALSE) catmaid_connection(server, username = NULL, password = NULL, - authname = NULL, authpassword = NULL, token = NULL, - authtype = getOption("catmaid.authtype", default = "basic"))+ authname = NULL, authpassword = NULL, token = NULL, authtype = NULL)
catmaid_connection
connection object.FALSE
)conn | +An optional |
+
---|---|
... | +Additional arguments passed to catmaid_connection |
+
Cache | +Whether to cache open connections at login so that they can be +reused automatically. |
+
Force | +Whether to force a new login to the CATMAID server (default
+ |
+
server | +url of CATMAID server |
+
username, password | +Your CATMAID username and password. |
+
authname, authpassword | +The http username/password that optionally secures the CATMAID website. These are not the same as your CATMAID login -details. - authenticate for details. |
+
token | +An API token (A modern alternative to providing your CATMAID +username and password). See Token based authentication for details. |
+
authtype | +The http authentication scheme, see
+ |
+
catmaid_login
is called with enough information to indicate that the
same server is desired OR (when no information about the server is passed
to catmaid_login
) the last opened connection will be used.
- Note the difference between authname
/authpassword
and
+
Note the difference between authname
/authpassword
and
username
/password
. The former are for generic web
- authentication, which is sometimes used to protect a privae catmaid site
+ authentication, which is sometimes used to protect a private catmaid site
from being accessible to general web traffic. The latter are used to
authenticate to the CATMAID web application itself - for example the
username
is the one that will be associated with any tracing carried
@@ -150,45 +176,62 @@
CATMAID now offers token based
- authentication as an alternative to specifying you CATMAID username and
- password. See http://catmaid.github.io/dev/api.html#api-token for how
- to get an API token. You can then set the catmaid.token
package
- option, but no longer need to set the catmaid.username
and
- catmaid.password
options.
Note that you must NOT reveal this token e.g. by checking it into a +
CATMAID offers token based
+ authentication as the strongly preferred alternative to specifying you
+ CATMAID username and password. See
+ http://catmaid.github.io/dev/api.html#api-token for how to get an API
+ token. You can then set the catmaid.token
package option, but no
+ longer need to set the catmaid.username
and catmaid.password
+ options.
Note that you must NOT reveal this token e.g. by checking it into a version controlled script as it gives complete access to your CATMAID account.
-You will very likely want to set some of the following package options in
- your .Rprofile file (see Startup
for details)
catmaid.server
- catmaid.username
Your catmaid username (deprecated in favour
- of token)
- catmaid.password
Your catmaid password (deprecated in favour
- of token)
- catmaid.token
Preferred to using catmaid.username/password
- catmaid.authname
Optional username for basic http website
- authorisation
- catmaid.authpassword
Optional password for basic http website
- authorisation
- # see http://catmaid.github.io/dev/api.html#api-token # for details of
- obtaining an API token
- options(catmaid.server="https://mycatmaidserver.org/catmaidroot",
- catmaid.authname="Calvin",catmaid.authpassword="hobbes", catmaid.token =
- "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b")
You will very likely want to set the following environment variables in
+ your .Renviron
file (see Startup
for details). This
+ file is read by R on startup. In this way the catmaid package will
+ automatically login to your preferred CATMAID server. Note that environment
+ variables will also be inherited by child R sessions. This means for
+ example that they will be available when running knitr reports, tests or R
+ CMD Check from Rstudio.
catmaid.server
catmaid.token
Preferred to using catmaid.username/password
catmaid.authname
Optional username for basic http website
+ authorisation
catmaid.authpassword
Optional password for basic http website
+ authorisation
catmaid.username
Your catmaid username (deprecated in favour
+ of token)
catmaid.password
Your catmaid password (deprecated in favour
+ of token)
An example .Renviron
file might look like:
+catmaid.server="https://mycatmaidserver.org/catmaidroot" +catmaid.token="9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b" +catmaid.authname="Calvin" +catmaid.authpassword="hobbes" ++
and must finish with a return at the end of the last line. See + http://catmaid.github.io/dev/api.html#api-token for details of + obtaining an API token
+ +Although setting environment variables is now the recommended
+ approach, you can also set R startup options e.g. in your .Rprofile
+ to specify default CATMAID login options including your personal access
+ token. The startup options have the same names as the environment variables
+ listed above, so you can place code along the lines of:
options(catmaid.server="https://mycatmaidserver.org/catmaidroot",
+ catmaid.authname="Calvin",catmaid.authpassword="hobbes", catmaid.token =
+ "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b")
in your .Rprofile
(see Startup
for details). Note that
+ it is important to have a final return at the end of your .Rprofile
+ file.
+## Not run: ------------------------------------ -# ## example explicitly specifying connection options -# # using modern token based authentication -# conn = catmaid_login(server="https://mycatmaidserver.org/catmaidroot", -# authname="Calvin",authpassword="hobbes", -# token="9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b") -# -# # ... or using the old fashioned approach specifiy username/password -# conn = catmaid_login(server="https://mycatmaidserver.org/catmaidroot", -# authname="Calvin",authpassword="hobbes", -# username="calvin", password="hobbesagain") -# -# ## examples assuming that catmaid.* options have been set -# conn = catmaid_login() -# conn = catmaid_login(server='https://someotherserver.org/catmaidroot') -# -# ## now do stuff with the connection like -# skel=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) -# -# ## or for those who want to work at the lowest level -# skel2=GET("https://mycatmaidserver.org/catmaidroot/1/10418394/0/0/compact-skeleton", -# config=conn$config) -## ---------------------------------------------
# NOT RUN { +## example explicitly specifying connection options +# using modern token based authentication +conn = catmaid_login(server="https://mycatmaidserver.org/catmaidroot", + authname="Calvin",authpassword="hobbes", + token="9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b") + +# ... or using the old fashioned approach specifiy username/password +conn = catmaid_login(server="https://mycatmaidserver.org/catmaidroot", + authname="Calvin",authpassword="hobbes", + username="calvin", password="hobbesagain") + +## examples assuming that catmaid.* environment variables/options are set +conn = catmaid_login() +conn = catmaid_login(server='https://someotherserver.org/catmaidroot') + +## now do stuff with the connection like +skel=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) + +## or for those who want to work at the lowest level +skel2=GET("https://mycatmaidserver.org/catmaidroot/1/10418394/0/0/compact-skeleton", + config=conn$config) +# }
Parse a CATMAID URL to extract parameters including xyz location
-catmaid_parse_url(x)+
catmaid_parse_url(x)
x | +One or more catmaid urls |
+
---|
A data.frame
containing parsed parameters. The columns will be
- named according to CATMAID's convention except for the x, y and z location
+ named according to CATMAID's convention except for the x, y and z location
(named as such rather than xp, yp, zp as returned by CATMAID).
catmaid_query_by_annotation
). Note that 1) objects can
be tagged with multiple annotations and 2) annotation tags are recursive so
- one annotation can be tagged with a second annotation.
-
- The most common use will be to get a data.frames of neurons when you should
- use type="neuron"
. You can also return both neurons and annotations
+ one annotation can be tagged with a second annotation.
The most common use will be to get a data.frames of neurons when you should
+ use type="neuron"
. You can also return both neurons and annotations
(the default) and just annotations. See type
argument for details.
catmaid_query_by_name(query, pid = 1, maxresults = 500, type = c("neuron", +catmaid_query_by_name(query, pid = 1, maxresults = 500, type = c("neuron", "annotation"), raw = FALSE, ...) catmaid_query_by_annotation(query, pid = 1, maxresults = 500, type = c("neuron", "annotation"), raw = FALSE, conn = NULL, ...)Arguments
-
c("neuron",
-"annotation")
. Only relevant when raw=FALSE
.TRUE
)
+ query | +A query string (NB this is a regular expression) |
+
---|---|
pid | +project id (default 1) |
+
maxresults | +The maximum number of results to return |
+
type | +Type of results to return. Defaults to |
+
raw | +Whether to return completely unprocessed data (when catmaid_fetch
-function.catmaid_connection objectFALSE , the default) |
+
... | +Additional arguments passed to the |
+
conn | +the |
+
For catmaid_query_by_name
a data.frame containing the
- results with an attribute "annotations" containing the annotations as a
+ results with an attribute "annotations" containing the annotations as a
separate data.frame. For both functions the main data.frame has the
- following columns
For catmaid_query_by_annotation
a data.frame containing the
+ following columns
id
name
type (neuron or annotation)
skid (the main identfier for the neuron skeleton, catmaid often calls + this skeleton_id)
For catmaid_query_by_annotation
a data.frame containing the
results.
+## Not run: ------------------------------------ -# catmaid_query_by_name("ORN") -# # using regex functionality -# catmaid_query_by_name("ORN (left|right)") -# # fancier regex -# catmaid_query_by_name("^[0-9a-f &]+ PN (left|right)") -## --------------------------------------------- -## Not run: ------------------------------------ -# # query matches 3 specific annotations -# catmaid_query_by_annotation("ORN PNs") -# -# # what are those 3 annotations? -# al=catmaid_get_annotationlist() -# subset(al$annotations, grepl("ORN PNs", name)) -# -# # Insist on specific annotation by using regex start/finish symbols -# catmaid_query_by_annotation("^ORN PNs$") -## ---------------------------------------------
# NOT RUN { +catmaid_query_by_name("ORN") +# using regex functionality +catmaid_query_by_name("ORN (left|right)") +# fancier regex +catmaid_query_by_name("^[0-9a-f &]+ PN (left|right)") +# }# NOT RUN { +# query matches 3 specific annotations +catmaid_query_by_annotation("ORN PNs") + +# what are those 3 annotations? +al=catmaid_get_annotationlist() +subset(al$annotations, grepl("ORN PNs", name)) + +# Insist on specific annotation by using regex start/finish symbols +catmaid_query_by_annotation("^ORN PNs$") +# }
Find neurons connected to a starting neuron
-catmaid_query_connected(skids, minimum_synapses = 1, boolean_op = c("OR", +catmaid_query_connected(skids, minimum_synapses = 1, boolean_op = c("OR", "AND"), pid = 1, raw = FALSE, conn = NULL, ...)Arguments
-
catmaid_skids
or examples for the syntax).boolean_op="OR"
, the default) or must be connected
-to all the specified neurons (boolean_op="AND"
).TRUE
)
+ skids | +One or more numeric skeleton ids or a character vector defining
+a query (see |
+
---|---|
minimum_synapses | +Must be at least this number of synapses between +starter neuron and returned partners |
+
boolean_op | +Whether returned neurons can be connected to any
+character vector ( |
+
pid | +Project id (default 1) |
+
raw | +Whether to return completely unprocessed data (when catmaid_connection objection returned by
-catmaid_login . If NULL (the default) a new connection
+(when FALSE , the default) |
+
conn | +A catmaid_fetch
-functioncatmaid_login . |
+
... | +Additional arguments passed to the |
+
A list containing two data.frames (incoming, outgoing), each - data.frame having one row for each partner neuron and the following columns -
skid skeleton id of the query neuron
partner the skeleton id of the partner neuron
syn.count the number of synapses made with partner
num_nodes number of nodes in the partner neuron
catmaid_skids
. See
catmaid_get_review_status
to get information about the review
status of partners (as shown in the equivalent CATMAID report).
Other connectors: catmaid_get_connector_table
,
+
Other connectors: catmaid_get_connector_table
,
catmaid_get_connectors_between
,
catmaid_get_connectors
,
connectors
+## Not run: ------------------------------------ -# orn13a=catmaid_query_by_name("13a ORN left")$skid -# catmaid_query_connected(orn13a) -# -# # connected to either left OR right 13a ORNs -# orn13as=catmaid_query_by_name("13a ORN") -# catmaid_query_connected(orn13as) -# # connected to both left AND right 13a ORNs -# catmaid_query_connected(orn13as, boolean_op = 'AND') -## ---------------------------------------------
# NOT RUN { +orn13a=catmaid_query_by_name("13a ORN left")$skid +catmaid_query_connected(orn13a) + +# connected to either left OR right 13a ORNs +orn13as=catmaid_query_by_name("13a ORN") +catmaid_query_connected(orn13as) +# connected to both left AND right 13a ORNs +catmaid_query_connected(orn13as, boolean_op = 'AND') +# }
Rename (presently) a single neuron or other entity (e.g. annotation)
-catmaid_rename_neuron(skids = NULL, entityids = NULL, names, pid = 1, +catmaid_rename_neuron(skids = NULL, entityids = NULL, names, pid = 1, conn = NULL, ...)Arguments
-
catmaid_skids
or examples for the syntax).catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ skids | +One or more numeric skeleton ids or a character vector defining
+a query (see |
+
---|---|
entityids | +Generic entity ids |
+
names | +New names |
+
pid | +Project id (default 1) |
+
conn | +A catmaid_fetch
-functioncatmaid_login . |
+
... | +Additional arguments passed to the |
+
+## Not run: ------------------------------------ -# # Warning this will change data! -# n=get_neuron_name(27296) -# catmaid_rename_neuron(skids=27296, names=n) -## ---------------------------------------------
# NOT RUN { +# Warning this will change data! +n=get_neuron_name(27296) +catmaid_rename_neuron(skids=27296, names=n) +# }
catmaid_skids(x, several.ok = TRUE, conn = NULL, ...)+
catmaid_skids(x, several.ok = TRUE, conn = NULL, ...)
catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ x | +one or more skids or a query expression (see details) |
+
---|---|
several.ok | +Logical indicating whether we can allow multiple skids. |
+
conn | +A catmaid_query_by_annotation catmaid_login . |
+
... | +additional parameters passed to |
+
If the inputs are numeric or have length > 1 they are assumed
- already to be skids and are simply converted to integers. If the the input
- is a string starting with "name:" or "annotation:" they are used for a
- query by catmaid_query_by_name
or
+
If the inputs are numeric or have length > 1 they are assumed
+ already to be skids and are simply converted to integers. If the input is a
+ string starting with "name:" or "annotation:" they are used for a query by
+ catmaid_query_by_name
or
catmaid_query_by_annotation
, respectively.
+## Not run: ------------------------------------ -# # these are just passed through -# catmaid_skids(1:10) -# -# # nb these are all regex matches -# catmaid_skids("name:ORN") -# catmaid_skids("name:PN") -# # there will be multiple annotations that match this -# catmaid_skids("annotation:ORN") -# # but only one that matches this (see regex for details) -# catmaid_skids("annotation:^ORN$") -## ---------------------------------------------
# NOT RUN { +# these are just passed through +catmaid_skids(1:10) + +# nb these are all regex matches +catmaid_skids("name:ORN") +catmaid_skids("name:PN") +# there will be multiple annotations that match this +catmaid_skids("annotation:ORN") +# but only one that matches this (see regex for details) +catmaid_skids("annotation:^ORN$") +# }
Fetch user contribution history
-catmaid_user_history(from, to = Sys.Date(), pid = 1L, conn = NULL, ...)+
catmaid_user_history(from, to = Sys.Date(), pid = 1L, conn = NULL, ...)
catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ from | +Starting date for history |
+
---|---|
to | +End date for history (defaults to today's date) |
+
pid | +Project id (default 1) |
+
conn | +A catmaid_fetch
-functioncatmaid_login . |
+
... | +Additional arguments passed to the |
+
A data.frame with columns
A data.frame with columns
full_name
login
id
new_cable (in nm)
new_connectors
new_reviewed_nodes
date
+## Not run: ------------------------------------ -# catmaid_user_history(from="2016-01-01") -# # last 2 days -# catmaid_user_history(from = Sys.Date()-2) -## ---------------------------------------------
# NOT RUN { +catmaid_user_history(from="2016-01-01") +# last 2 days +catmaid_user_history(from = Sys.Date()-2) +# }
Return the CATMAID version running on the server
-catmaid_version(conn = NULL, cached = TRUE, numeric = FALSE, ...)+
catmaid_version(conn = NULL, cached = TRUE, numeric = FALSE, ...)
catmaid_connection
object. The default value of NULL
-implies that the most recent cached open connection will be used.numeric_version
object that can be used for comparisons.catmaid_fetch
conn | +A |
+
---|---|
cached | +Whether to use the cached version number for this connection +(see details) |
+
numeric | +Whether to parse the version string into an R
+ |
+
... | +Additional arguments passed to |
+
By default the version number for the current
catmaid_connection
is stored on the first request after a new
login and then the cached version number is reused. Setting
- cached=FALSE
will always force a request to the server.
CATMAID versions are now prduced by git describe and look like
+ cached=FALSE
will always force a request to the server.
CATMAID versions are now prduced by git describe and look like
YYYY.MM.DD-XX-gaaaaaaa where aaaaaaa is a short SHA1 hash and XX is an
integer number of revisions since the last base version. Setting
numeric=TRUE
trims off the SHA1 hash leaving a string that can be
@@ -117,10 +135,10 @@
+## Not run: ------------------------------------ -# # example of checking if server version is newer than required version -# catmaid_version(numeric=TRUE)>="2016.1.1-65" -## ---------------------------------------------
# NOT RUN { +# example of checking if server version is newer than required version +catmaid_version(numeric=TRUE)>="2016.1.1-65" +# }
neuron
or neuronlist
.
- connectors(x, ...) +connectors(x, ...) # S3 method for catmaidneuron connectors(x, ...) @@ -89,59 +98,60 @@Get data.frame of connector (synapse) information from a neuron or neuronlis connectors(x, subset = NULL, ...)
Arguments
-
nlapply
in
-the case of connectors)nlapply
for details)x | +Neuron or neuronlist |
+
---|---|
... | +Additional arguments passed to methods (and to |
+
subset, | +optional subset of neurons to keep (see
+ |
+
A data.frame with columns
0
) or
+ A data.frame with columns
treenode_id (NB this is the treenode id for the current skeleton)
connector_skid
prepost integer indicating whether connection is pre-(0
) or
post(1
)-synaptic with respect to the current neuron. In other words
- this field will be 0
(pre) for the output synapses of this neuron.
connectors.neuronlist
, the skid of the skeleton from
- which connector information was retrieved.
- 0
(pre) for the output synapses of this neuron.x Spatial Location
y
z
skid For connectors.neuronlist
, the skid of the skeleton from
+ which connector information was retrieved.
Other connectors: catmaid_get_connector_table
,
+
Other connectors: catmaid_get_connector_table
,
catmaid_get_connectors_between
,
catmaid_get_connectors
,
catmaid_query_connected
+## Not run: ------------------------------------ -# ornsl=read.neurons.catmaid("name:ORN left", OmitFailures = T, .progress='text') -# conndf=connectors(ornsl) -# summary(connectors(ornsl)) -# -# # plot points in 3d -# library(nat) -# nopen3d() -# points3d(xyzmatrix(conndf), col=c(pre='red', post='cyan')[conndf$prepost+1]) -## ---------------------------------------------
# NOT RUN { +ornsl=read.neurons.catmaid("name:ORN left", OmitFailures = T, .progress='text') +conndf=connectors(ornsl) +summary(connectors(ornsl)) + +# plot points in 3d +library(nat) +nopen3d() +points3d(xyzmatrix(conndf), col=c(pre='red', post='cyan')[conndf$prepost+1]) +# }
This function is intended primarily for developer use as a way + to copy over connector/tag information typically contained in CATMAID + neurons but lost when nat functions are applied to transform a neuron.
+ + +copy_tags_connectors(new, old, update_node_ids = TRUE)+ +
new, old | +information will be copied from old -> new |
+
---|---|
update_node_ids | +whether to update the node ids (default |
+
A new neuron containing tag and connector information from the old + neuron and having the same class as the old neuron.
+ +Both connectors and tag information contain node ids. These may need + to be mapped onto new node ids if these are not consistent between old and + new neurons.
+ + +Provides an overview of key functions and classes
- - -Programmatic access to the CATMAID API
- -Functions handling connections to a catmaid server
- - -Import/Export catmaid connection details to system variables (e.g. for tests)
- - -Connect/authenticate to a CATMAID server, returning a connection object
- -Fetching raw skeleton information
- - -Return the raw data for a CATMAID neuronal skeleton
- - -Get review status of neurons from CATMAID
- - -Return tree node table for a given neuron
- -Querying, fetching and setting neuron names and annotations
- - -Get list of annotations (including user information) from CATMAID
- - -Get or set annotations for neurons from CATMAID
-catmaid_get_annotations_for_skeletons
catmaid_remove_annotations_for_skeletons
catmaid_set_annotations_for_skeletons
Get names of neurons from CATMAID
- - -Get list of neurons/annotations querying by neuron/annotation name
- - -Rename (presently) a single neuron or other entity (e.g. annotation)
- - -Find skeleton ids (skids) for various inputs including textual queries
-catmaid_skids
Querying and fetching neuronal connectivity information
- - -Return connector table for a given neuron
- - -Return information about connectors joining sets of pre/postsynaptic skids
- - -Return skeleton ids for pre/postsynaptic partners of a set of connector_ids
- - -Find neurons connected to a starting neuron
- -Fetching and using catmaid skeletons for use with the NeuroAnatomy Toolbox (nat) package.
+
+ Package Help+Provides an overview of key functions and classes + |
+ |
---|---|
+ + | +Programmatic access to the CATMAID API |
+
+ Catmaid Login+Functions handling connections to a catmaid server + |
+ |
+ + | +Connect/authenticate to a CATMAID server, returning a connection object |
+
+
|
+ Import/Export catmaid connection details to system variables (e.g. for tests) |
+
+ CATMAID skeleton functions+Fetching raw skeleton information + |
+ |
+ + | +Return the raw data for a CATMAID neuronal skeleton |
+
+ + | +Return tree node table for a given neuron |
+
+ + | +Get review status of neurons from CATMAID |
+
+ Names and Annotations+Querying, fetching and setting neuron names and annotations + |
+ |
+ + | +Get list of neurons/annotations querying by neuron/annotation name |
+
+ + | +Get names of neurons from CATMAID |
+
+ + | +Rename (presently) a single neuron or other entity (e.g. annotation) |
+
+ + | +Find skeleton ids (skids) for various inputs including textual queries |
+
+
|
+ Get or set annotations for neurons from CATMAID |
+
+ + | +Get list of annotations (including user information) from CATMAID |
+
+ + | +Get statistics for all labels in a project from a CATMAID server |
+
+ Synaptic Connections+Querying and fetching neuronal connectivity information + |
+ |
+ + | +Find neurons connected to a starting neuron |
+
+ + | +Return connector table for a given neuron |
+
+ + | +Return information about connectors joining sets of pre/postsynaptic skids |
+
+ + | +Return skeleton ids for pre/postsynaptic partners of a set of connector_ids |
+
+ Interfacing with Nat+Fetching and using catmaid skeletons for use with the NeuroAnatomy Toolbox (nat) package. + |
+ |
+ + | +Read neuron(s) from CATMAID server into NeuroAnatomy Toolbox (nat) format |
+
+ + | +Plot skeleton and connectors for neuron retrieved from CATMAID |
+
+ + | +Get data.frame of connector (synapse) information from a neuron or neuronlist |
+
+ Handling volume meshes+Adding / converting volume meshes to CATMAID from regular R mesh representations + |
+ |
+ + | +Convert a mesh to CATMAID format |
+
+ + | +Add a 3D mesh surface to catmaid volume manager |
+
+ CATMAID statistics and users+Neuron and user lists and statistics + |
+ |
+ + | +Get contributor statistics for neurons from CATMAID |
+
+ + | +Fetch list of catmaid users for current/specified connection/project |
+
+ + | +Fetch user contribution history |
+
+ CATMAID URLs+Working with the URLs or json files used to save and exchange CATMAID state + |
+ |
+ + | +Parse a CATMAID URL to extract parameters including xyz location |
+
+ Low level functions+Functions primarily intended for developer use + |
+ |
+ + | +Send http GET or POST request to a CATMAID server |
+
+ + | +Copy the tag / connector info from a catmaid neuron to a new neuron |
+
+ + | +Return the entity ids for one or more model ids |
+
+ + | +Return the CATMAID version running on the server |
+
Plot skeleton and connectors for neuron retrieved from CATMAID
-# S3 method for catmaidneuron +# S3 method for catmaidneuron plot3d(x, WithConnectors = FALSE, WithNodes = FALSE, - ...)+ soma = FALSE, ...)
FALSE
since they will obscure the synapses).plot3d.neuron
-(synapses). Default: TRUE
.x | +A neuron to plot |
+
---|---|
WithConnectors | +logical indicating whether or not to plot connectors
+(defaults to |
+
WithNodes | +logical indicating whether to plot branch/end points
+(defaults to |
+
soma | +Whether to plot a sphere at neuron's origin representing the
+soma. Either a logical value or a numeric indicating the radius (default
+ |
+
... | +additional arguments passed to |
+
+## Not run: ------------------------------------ -# nl=read.neurons.catmaid(c(10418394,4453485)) -# plot3d(nl) -# -# # now with connectors (i.e. synapses) -# plot3d(nl, WithConnectors=TRUE) -## ---------------------------------------------
# NOT RUN { +nl=read.neurons.catmaid(c(10418394,4453485)) +plot3d(nl) + +# now with connectors (i.e. synapses) +plot3d(nl, WithConnectors=TRUE) +# }
read.neuron.catmaid(skid, pid = 1L, conn = NULL, ...) +read.neuron.catmaid(skid, pid = 1L, conn = NULL, ...) read.neurons.catmaid(skids, pid = 1L, conn = NULL, OmitFailures = NA, df = NULL, ...)Arguments
-
catmaid_connection
objection returned by
-catmaid_login
. If NULL
(the default) a new connection
+ skid | +A numeric skeleton id |
+
---|---|
pid | +Project id (default 1) |
+
conn | +A catmaid_fetch
-functioncatmaid_skids or examples for the syntax).FUN gives an
+options as described in the help for catmaid_login . |
+
... | +Additional arguments passed to the |
+
skids | +One or more numeric skeleton ids or a character vector defining
+a query (see |
+
OmitFailures | +Whether to omit neurons for which |
+
df | +Optional data frame containing information about each neuron |
+
These functions provide a bridge between CATMAID and the - neuronanatomy toolbox R package (https://github.com/jefferis/nat), + neuronanatomy toolbox R package (https://github.com/jefferis/nat), which provides extensive functionality for analysing and plotting neurons - within the context of temaplate brains.
-Note that the soma is set by inspecting CATMAID tags that
- (case-insensitively) match the regex "(cell body|soma)"
. Where >1
+ within the context of temaplate brains.
Note that the soma is set by inspecting CATMAID tags that
+ (case-insensitively) match the regex "(cell body|soma)"
. Where >1
tag exists the one that tags an endpoint is preferred.
When OmitFailures
is not NA
, FUN
will be
+
When OmitFailures
is not NA
, FUN
will be
wrapped in a call to try
to ensure that failure for any single
neuron does not abort the nlapply/nmapply call. When
OmitFailures=TRUE
the resultant neuronlist will be subsetted down to
return values for which FUN
evaluated successfully. When
- OmitFailures=FALSE
, "try-error" objects will be left in place. In
+ OmitFailures=FALSE
, "try-error" objects will be left in place. In
either of the last 2 cases error messages will not be printed because the
- call is wrapped as try(expr, silent=TRUE)
.
The optional dataframe (df
) detailing each neuron should have
+ call is wrapped as try(expr, silent=TRUE)
.
The optional dataframe (df
) detailing each neuron should have
rownames
that match the names of each neuron. It would also make
sense if the same key was present in a column of the data frame. If the
dataframe contains more rows than neurons, the superfluous rows are dropped
@@ -148,53 +172,53 @@
plot3d.catmaidneuron
, read.neuron
,
connectors
to extract connector information from a
- catmaid.neuron
catmaid.neuron
+ catmaid_skids
+## Not run: ------------------------------------ -# library(nat) -# nl=read.neurons.catmaid(c(10418394,4453485)) -# plot3d(nl) -# -# ## Full worked example looking at Olfactory Receptor Neurons -# # read in ORNs (using a regex to match their name) -# # note that use a progress bar drop any failures -# orns=read.neurons.catmaid("name:ORN (left|right)", OmitFailures = T, .progress='text') -# -# # Add two extra columns to the attached data.frame -# # for the Odorant receptor genes and the side of brain -# orns[,'side']=factor(ifelse(grepl("left", orns[,'name']), "L", "R")) -# orns[,'Or']= factor(sub(" ORN.*", "", orns[,'name'])) -# -# # check what we have -# # see ?head.neuronlist and ?with.neuronlist for details of how this works -# head(orns) -# with(orns, ftable(side~Or)) -# -# # now some plots -# open3d() -# # colour by side of brain -# plot3d(orns, col=side) -# clear3d() -# # colour by Odorant Receptor -# # note similar position of axon terminals for same ORN class on left and right -# plot3d(orns, col=Or) -# -# ## Additional example using Olfactory Projection Neurons -# pns=read.neurons.catmaid("annotation:ORN PNs$", .progress='text') -# pns[,'side']=factor(ifelse(grepl("left", pns[,'name']), "L", "R")) -# pns[,'Or']= factor(sub(" PN.*", "", pns[,'name'])) -# -# # check that we have the same levels for the Odorant Receptor (Or) factor -# # for ORNs and PNs -# stopifnot(levels(pns[,'Or'])==levels(orns[,'Or'])) -# -# # Ok, let's plot the PNs - they will be in matching colours -# plot3d(pns, col=Or) -# -## ---------------------------------------------
# NOT RUN { +library(nat) +nl=read.neurons.catmaid(c(10418394,4453485)) +plot3d(nl) + +## Full worked example looking at Olfactory Receptor Neurons +# read in ORNs (using a regex to match their name) +# note that use a progress bar drop any failures +orns=read.neurons.catmaid("name:ORN (left|right)", OmitFailures = T, .progress='text') + +# Add two extra columns to the attached data.frame +# for the Odorant receptor genes and the side of brain +orns[,'side']=factor(ifelse(grepl("left", orns[,'name']), "L", "R")) +orns[,'Or']= factor(sub(" ORN.*", "", orns[,'name'])) + +# check what we have +# see ?head.neuronlist and ?with.neuronlist for details of how this works +head(orns) +with(orns, ftable(side~Or)) + +# now some plots +open3d() +# colour by side of brain +plot3d(orns, col=side) +clear3d() +# colour by Odorant Receptor +# note similar position of axon terminals for same ORN class on left and right +plot3d(orns, col=Or) + +## Additional example using Olfactory Projection Neurons +pns=read.neurons.catmaid("annotation:ORN PNs$", .progress='text') +pns[,'side']=factor(ifelse(grepl("left", pns[,'name']), "L", "R")) +pns[,'Or']= factor(sub(" PN.*", "", pns[,'name'])) + +# check that we have the same levels for the Odorant Receptor (Or) factor +# for ORNs and PNs +stopifnot(levels(pns[,'Or'])==levels(orns[,'Or'])) + +# Ok, let's plot the PNs - they will be in matching colours +plot3d(pns, col=Or) + +# }