Summarise the synaptic partners of one or more Aedes neurons
Source:R/partners.R
aedes_partner_summary.RdTabulates the up- or downstream partners of a set of query neurons at a
chosen CAVE materialisation, returning one row per partner with the number
of connecting synapses. This is a thin Aedes-aware wrapper around
fafbseg::flywire_partner_summary(): it resolves the input via
aedes_ids(), points fafbseg at the Aedes segmentation, and updates root
ids to the requested version/timestamp before querying. When a local
synapse snapshot has been selected with aedes_use_snapshot() the
query is instead answered from that snapshot, updated to the requested time.
Arguments
- rootids
Query neurons in any form accepted by
aedes_ids()(root ids or a FlyTable query string).- partners
Whether to summarise
"outputs"(downstream partners, the default) or"inputs"(upstream partners).- threshold
Only return partners connected by more than
thresholdsynapses (default0, i.e. all partners).- version, timestamp
Optional CAVE materialisation selectors. When supplied, query ids are first updated to the corresponding version / timestamp with
fafbseg::flywire_latestid(), and the synapse query is run against that materialisation. Give at most one of the two.- synapse_table
CAVE synapse table to query. Defaults to the
coconatfly.aedes.synapsesoption ("synapses_v2").- method
Whether to query CAVE (
"cave"), a local synapse snapshot ("local", seeaedes_use_snapshot()) or choose automatically ("auto", the default; see details).- ...
Additional arguments passed on to
fafbseg::flywire_partner_summary(). Power-user options includeremove_autapses(setFALSEto keep self-connections; see examples) andcleft.threshold. Onlyremove_autapsesis supported by the local method.
Value
A data.frame with one row per partner neuron. query holds the
query neuron root id and weight the synapse count; the partner root id
is in post_id when partners = "outputs" and pre_id when
partners = "inputs". See fafbseg::flywire_partner_summary() for the
full column description.
Details
With method = "auto" (the default) the local snapshot is used
when one is selected, the requested time is not before the oldest snapshot
in the selected snapshot's folder, and ... contains nothing other than
remove_autapses; otherwise CAVE is queried. method = "local" gives an
error rather than falling back to CAVE.
The time of a local query is timestamp (or the time of version) when
given, otherwise that of the aedes.version option (see
aedes_set_version()), just as for CAVE queries. The query starts from
the newest snapshot in the selected snapshot's folder at or before that
time, which may be older or newer than the selected one.
Local queries after the snapshot time fetch only the changes made since
then from CAVE and look up the new root ids of the affected synapses'
supervoxels. These updates are kept for the rest of the R session, so the
first query after a long gap may take a while (seconds to a few minutes)
but later ones are quick. A query for "now" reuses the last update if it
is less than getOption("aedes.synapse_max_age", 60) seconds old. Small
queries may instead update just their own synapses when that is cheaper
(tuned by the aedes.synapse_head_ratio and aedes.synapse_head_min_sv
options).
The local and CAVE results should agree, apart from any cleft.threshold
filtering (CAVE only) and any root 0 (unassigned) partners, which the
local method drops. The local result has snapshot, timestamp (the time it is
valid for) and method attributes.
Examples
if (FALSE) { # \dontrun{
# downstream partners of the two MBON11 neurons, keeping only strong
# connections
mbon11 <- aedes_ids("type:MBON11")
aedes_partner_summary(mbon11, threshold = 4)
# inputs instead of outputs
aedes_partner_summary(mbon11, partners = "inputs")
# Power-user: query a specific CAVE materialisation rather than 'now'.
# Aedes materialisations expire (there is no long-term support version), so
# list those currently available with
# aedes_cave_client()$materialize$get_versions()
aedes_partner_summary(mbon11, version = "latest")
# CAVE timestamps must not pre-date the oldest available materialisation
aedes_partner_summary(mbon11, timestamp = Sys.time() - 7*24*3600)
# Power-user: include autapses (self-connections). MBON11 is strongly
# autaptic, so its own root id appears among its downstream partners when
# remove_autapses = FALSE (the fafbseg default drops these).
aedes_partner_summary(mbon11, remove_autapses = FALSE)
# answer from a local synapse snapshot
options(aedes.synapse_snapshot_root = "~/data/aedes/syn_snapshot")
aedes_use_snapshot()
aedes_partner_summary(mbon11, method = "local")
} # }