navis.interfaces.r.nblast¶
- navis.interfaces.r.nblast(query, target=None, scores='forward', n_cores=0, normalized=True, use_alpha=False, k=5, resample=None)[source]¶
NBLAST using R’s
nat.nblast::nblast
.Please note that NBLAST is optimized for units in microns.
- Parameters:
query (TreeNeuron | NeuronList | Dotprops | nat.neuron) – Query neuron(s) to NBLAST against the targets.
target (TreeNeuron | NeuronList | Dotprops | nat.neuron | str) –
Neuron(s) to run the query against. If a str, must be either:
the name of a file in
'flycircuit.datadir'
a path (e.g.
'.../gmrdps.rds'
)an R file object (e.g.
robjects.r("load('.../gmrdps.rds')")
)a URL to load the list from (e.g.
'http://.../gmrdps.rds'
)”flycircuit”
scores ('forward' | 'mean' | 'min' | 'max') –
Determines the final scores:
’forward’ (default) returns query->target scores
’mean’ returns the mean of query->target and target->query scores
’min’ returns the minium between query->target and target->query scores
’max’ returns the maximum between query->target and target->query scores
n_cores (int, optional) – Number of cores to use for nblasting. Default is
os.cpu_count() - 2
.use_alpha (bool, optional) – Emphasizes neurons’ straight parts (backbone) over parts that have lots of branches.
normalized (bool, optional) – Whether to return normalized NBLAST scores.
k (int, optional) – Number of nearest neighbors to use for dotprops generation. Only relevant if input data is not already
Dotprops
.resample (int | bool, optional) – Resampling during dotprops generation. A good value is
1
which means if data is in microns (which it should!) it will be resampled to 1 tangent vector per micron. Only relevant if input data is not alreadyDotprops
.
- Returns:
scores – Matrix with NBLAST scores. Rows are query neurons, columns are targets.
- Return type:
pandas.DataFrame
Examples
NBLAST example neurons against flycircuit DB
>>> import navis >>> from navis.interfaces import r >>> nl = navis.example_neurons(n=5) >>> nl.units array([8, 8, 8, 8, 8]) <Unit('nanometer')> >>> # Convert to microns >>> nl_um = nl / 1000 >>> # Run the nblast >>> scores = r.nblast(nl_um)