fafbseg.flywire.synapses.get_adjacency¶
- fafbseg.flywire.synapses.get_adjacency(sources, targets=None, square=True, materialization='auto', neuropils=False, filtered=True, min_score=None, batch_size=1000, *, dataset=None, progress=True)[source]¶
Fetch adjacency matrix.
Notes
As of May 2023, CAVE provides “views” of materialized tables. This includes a view with neuron edges (as opposed to individual synaptic connections) which can be much faster to query. We will automatically use this view _if_:
filtered=True (default is True)
min_score=None or min_score=50 (default is None)
neuropils=None (default is None)
mat!=’live’ (default is “auto” which can end up as “live”)
- Parameters:
sources (int | list of int | Neuron/List | NeuronCriteria) – Either FlyWire segment ID (i.e. root ID), a list thereof or a Neuron/List. For neurons, the
.id
is assumed to be the root ID. If you have a neuron (in FlyWire space) but don’t know its ID, usefafbseg.flywire.neuron_to_segments()
first.targets (int | list of int | Neuron/List | NeuronCriteria, optional) – Either FlyWire segment ID (i.e. root ID), a list thereof or a Neuron/List. For neurons, the
.id
is assumed to be the root ID. If you have a neuron (in FlyWire space) but don’t know its ID, usefafbseg.flywire.neuron_to_segments()
first. IfNone
, will assume`targets = sources
.square (bool, optional) – Whether to return a square matrix. If False, will return a DataFrame with sources as rows and targets as columns.
neuropils (bool | str | list of str, optional) –
if True, will return neuropils. This requires square=False!
a neuropil name (e.g.
'AL_R'
) or list thereof (e.g.['AL_R', 'AL_L']
) to filter connectivity to these ROIs.prefix neuropils with a tilde (e.g.
~AL_R
) to exclude them.
filtered (bool) – Whether to use the filtered synapse table. Briefly, this filter removes redundant and low confidence (<= 50 cleft score) synapses. See also https://tinyurl.com/4j9v7t86 (links to CAVE website).
min_score (int) – Minimum “cleft score”. Buhmann et al. used a threshold of 30 in their paper. However, for FlyWire analyses that threshold was raised to 50 (see also filtered).
batch_size (int) – Number of IDs to query per batch. Too large batches can lead to truncated tables: currently individual queries do not return more than 200_000 connections. If you see a warning that this limit has been exceeded, decrease the batch size!
materialization (int | str, optional) –
- Which materialization to query:
’auto’ (default) tries to find the most recent materialization version at which all the query IDs existed
’latest’ uses the latest materialized table
’live’ queries against the live data - this will be much slower!
pass an integer (e.g. 447) to use a specific materialization version
dataset ("public" | "production" | "sandbox", optional) – Against which FlyWire dataset to query. If
None
will fall back to the default dataset (seeset_default_dataset()
).
- Returns:
adjacency – Adjacency matrix. Rows (sources) and columns (targets) are in the same order as input.
- Return type:
pd.DataFrame
See also
get_connectivity()
Use this function to fetch all up- and/or downstream partners for a set of neurons.
Examples
Get connections between given root IDs:
>>> from fafbseg import flywire >>> adj = flywire.get_adjacency(sources=720575940631406673, ... targets=720575940603231916) Using materialization version 783. >>> adj target 720575940603231916 source 720575940631406673 5