Skip to contents

Create an InfluenceCalculator object using the Python library from the r-reticulate environment. From v0.2.0 of ConnectomeInfluenceCalculator the Python library accepts data frames and several on-disk formats directly, so no temporary SQLite database needs to be written when you pass edgelist_simple / meta.

Usage

influence_calculator_py(
  filename = NULL,
  edgelist_simple = NULL,
  meta = NULL,
  signed = FALSE,
  count_thresh = 0,
  syn_weight_measure = c("norm", "count"),
  inhibitory_nts = NULL,
  excluded_nts = NULL,
  lambda_max = 0.99
)

Arguments

filename

Character. Path to a connectome data file. The format is detected from the file extension: .sqlite/.db use the original SQLite constructor, .csv uses from_csv, .parquet uses from_parquet, and .feather/.arrow use from_feather. If the extension is unrecognised the original SQLite path is tried (matching pre-v0.2.0 behaviour).

edgelist_simple

Data frame with edge list containing columns 'pre', 'post', and either 'count' (raw synapse count) or 'weight' (pre-normalised). 'norm' is optional and recomputed from 'count' if absent. Used when filename is NULL.

meta

Data frame with metadata containing at least 'root_id' column. Must also contain 'top_nt' when signed = TRUE or excluded_nts is supplied. Used when filename is NULL.

signed

Logical. Whether to use signed connectivity matrix (default: FALSE). When TRUE, inhibitory_nts must be supplied.

count_thresh

Numeric. Minimum threshold count for postsynaptic connections (default: 0, i.e. no filtering — make any silent filtering visible to the caller).

syn_weight_measure

Character, one of "norm" (default) or "count". Which edge column populates the connectivity matrix W: "count" is the raw synapse count, "norm" is the per-postsynaptic input fraction (count / sum(count) per post). The package default "norm" matches influence_calculator_r(), so the R and Python backends agree; note the upstream Python library's own default is "count". For signed = TRUE, "count" is the more natural choice: negating "norm" weights breaks the column-sum-to-1 property and loses the input-normalisation interpretation.

inhibitory_nts

Character vector of top_nt values whose pre-neurons should receive negative weights when signed = TRUE. The Python library has no per-organism default; you must supply this set explicitly when signed = TRUE.

excluded_nts

Character vector of top_nt values whose pre-neurons should contribute nothing to W. Independent of signed. Use for transmitter classes whose sign at a given target depends on the receptor mix and so cannot be assigned a single sign safely.

lambda_max

Numeric in (0, 1). Target spectral radius of the rescaled connectivity matrix W~ (default 0.99). Sets the leading-mode gain to 1/(1 - lambda_max). Lower values (e.g. 0.5) are more appropriate for small graphs like C. elegans; the default is calibrated for whole-CNS Drosophila (BANC-scale) graphs. See influence_calculator_r() for the full discussion.

Value

InfluenceCalculator Python object

Examples

if (FALSE) { # \dontrun{
# SQLite (legacy)
ic <- influence_calculator_py("connectome.sqlite")

# Feather (e.g. the BANC edge list on the lab's GCS bucket)
ic <- influence_calculator_py("banc_888_edgelist_simple_v2.feather", meta = banc_meta)

# Data frames (no temp file written)
ic <- influence_calculator_py(edgelist_simple = my_edges, meta = my_meta,
                               signed = TRUE,
                               inhibitory_nts = c("glutamate", "gaba",
                                                  "serotonin", "octopamine"),
                               lambda_max = 0.99)
} # }