Skip to contents

aedes_synapse_capture() ranks bodies (root ids) and reports what fraction of all synapses is captured as more bodies are included: on the presynaptic side, the postsynaptic side and on both sides (a connection between two captured bodies).

aedes_capture_summary() picks out the capture at the last body of each tier and at given ranks.

Usage

aedes_synapse_capture(
  syn,
  tiers = NULL,
  by = NULL,
  nmax = 500000L,
  rest = "other"
)

aedes_capture_summary(x, at = c(100000L, 500000L), digits = 3)

Arguments

syn

A lazy table of synapses with columns pre_root, post_root and any by columns, such as from aedes_synapse_data().

tiers

A data frame with columns root and tier, one row per root id, giving the tier of each body. NULL (the default) ranks bodies by synapse count alone.

by

Names of columns of syn to compute capture separately for.

nmax

The number of top ranked bodies to return per group.

rest

The tier label for bodies not in tiers.

x

A data frame from aedes_synapse_capture(), or a subset of its rows that keeps the last body of each tier.

at

Ranks to report the capture at, as well as at the end of each tier.

digits

The number of decimal places to round the fractions to.

Value

For aedes_synapse_capture(), a data frame with one row per ranked body per group: the by columns, rank, root, tier (a factor), n (the body's synapses), total (the group's synapses) and the cumulative fractions frac_pre, frac_post and frac_both.

For aedes_capture_summary(), a data frame with the grouping columns, point (e.g. "end of A"), rank and the three fractions.

Details

Bodies are ranked by tier (in the order of the levels of tiers$tier when it is a factor, otherwise sorted), with bodies not in tiers last, then by their number of synapses (pre plus post) within each tier. A connection is captured once both of its bodies are, i.e. at the larger of their two ranks. Synapses on root 0 (no body) are never captured but count in the totals, so fractions are of all synapses.

With by, bodies are ranked separately within each group, counting only the synapses in that group, and fractions are of the group's synapses. For example by = "region" with a column that labels each synapse by brain region gives one capture curve per region.

The work is done in the database behind syn, so it scales to the whole synapse table; only the nmax top ranked bodies per group are returned.

Examples

if (FALSE) { # \dontrun{
syn <- aedes_synapse_data()
good <- c("adequate", "SecondPass", "complete", "proofread")
meta <- aedes_meta(timestamp = aedes_use_snapshot(set = FALSE)$timestamp)
tiers <- data.frame(root = meta$root_id,
                    tier = ifelse(meta$status %in% good, "A", "B"))
# a root in both tiers counts as A
tiers <- tiers[order(tiers$tier), ]
tiers <- tiers[!duplicated(tiers$root), ]
cap <- aedes_synapse_capture(syn, tiers, rest = "C")
aedes_capture_summary(cap)
} # }