Learn R Programming

nat.nblast (version 1.5)

nblast: Calculate similarity score for neuron morphologies

Description

Uses the NBLAST algorithm that compares the morphology of two neurons. For more control over the parameters of the algorithm, see the arguments of NeuriteBlast.

Usage

nblast(query, target = getOption("nat.default.neuronlist"), smat = NULL,
  sd = 3, version = c(2, 1), normalised = FALSE, UseAlpha = FALSE,
  OmitFailures = NA, ...)

Arguments

query
the query neuron.
target
a neuronlist to compare neuron against. Defaults to options("nat.default.neuronlist"). See nat-package.
smat
the scoring matrix to use (see details)
sd
Standard deviation to use in distance dependence of nblast v1 algorithm. Ignored when version=2.
version
the version of the algorithm to use (the default, 2, is the latest).
normalised
whether to divide scores by the self-match score of the query
UseAlpha
whether to consider local directions in the similarity calculation (default: FALSE).
OmitFailures
Whether to omit neurons for which FUN gives an error. The default value (NA) will result in nblast stopping with an error message the moment there is an eror. For other values, see details.
...
Additional arguments passed to NeuriteBlast or the function used to compute scores from distances/dot products. (expert use only).

Value

  • Named list of similarity scores.

Details

when smat=NULL options("nat.nblast.defaultsmat") will be checked and if NULL, then smat.fcwb or smat_alpha.fcwb will be used depending on the value of UseAlpha.

When OmitFailures is not NA, individual nblast calls will be wrapped in try to ensure that failure for any single neuron does not abort the whole nblast call. When OmitFailures=FALSE, missing values will be left as NA. OmitFailures=TRUE is not (yet) implemented. If you want to drop scores for neurons that failed you will need to set OmitFailures=FALSE and then use na.omit or similar to post-process the scores.

Note thatn when OmitFailures=FALSE error messages will not be printed because the call is wrapped as try(expr, silent=TRUE).

Internally, the plyr package is used to provide options for parallelising NBLASTs and displaying progress. To display a progress bar as the scores are computed, add .progress="text" to the arguments (non-text progress bars are available -- see create_progress_bar). To parallelise, add .parallel=TRUE to the arguments. In order to make use of parallel calculation, you must register a parallel backend that will distribute the computations. There are several possible backends, the simplest of which is the multicore option made available by doMC, which spreads the load across cores of the same machine. Before using this, the backend must be registered using registerDoMC (see example below).

See Also

nat-package

Examples

Run this code
# load sample Kenyon cell data from nat package
data(kcs20, package='nat')
# search one neuron against all neurons
scores=nblast(kcs20[['GadMARCM-F000142_seg002']], kcs20)
# scores from best to worst, top hit is of course same neuron
sort(scores, decreasing = TRUE)
hist(scores, breaks=25, col='grey')
abline(v=1500, col='red')

# plot query neuron
open3d()
# plot top 3 hits (including self match with thicker lines)
plot3d(kcs20[which(sort(scores, decreasing = TRUE)>1500)], lwd=c(3,1,1))
rest=names(which(scores<1500))
plot3d(rest, db=kcs20, col='grey', lwd=0.5)

# normalised scores (i.e. self match = 1) of all neurons vs each other
# note use of progress bar
scores.norm=nblast(kcs20, kcs20, normalised = TRUE, .progress="text")
hist(scores.norm, breaks=25, col='grey')
# produce a heatmap from normalised scores
jet.colors <- colorRampPalette( c("blue", "green", "yellow", "red") )
heatmap(scores.norm, labCol = with(kcs20,type), col=jet.colors(20), symm = TRUE)

# Parallelise NBLASTing across 4 cores using doMC package
library(doMC)
registerDoMC(4)
scores.norm2=nblast(kcs20, kcs20, normalised=TRUE, .parallel=TRUE)
stopifnot(all.equal(scores.norm2, scores.norm))

Run the code above in your browser using DataLab