Plot network as directed graph
plot-network.RdThis function plots a network object as a directed graph using ggplot2. Nodes represent neurons, and directed edges represent connections between them. The plot can be customized by selecting which motif to display and how to color the edges.
Usage
plot.network(
network,
soma_mask = NULL,
arbor_idx = NULL,
threedim = FALSE,
title = NULL,
soma_density = 1.0,
arbor_density = 0.01,
arbor_cell_type = "all",
plot_motif = "all",
reconstruct_arbors = TRUE,
edge_color = "pre_type",
soma_color = "layer",
soma_size_factor = 3.0,
return_plot = FALSE,
return_cell_arbor_idx = FALSE
)Arguments
- network
Network object to plot.
- soma_mask
Logical vector of length equal to the number of neurons in the network, indicating which neurons to include in the plot (TRUE for included neurons, FALSE for excluded neurons). If NULL (default), a random sample of neurons will be selected based on the specified soma_density. Useful for reproducing the same cells across plots.
- arbor_idx
Integer vector giving the indices of neurons for which to plot arbors (i.e., axonal and dendritic processes). If NULL (default), a random sample of neurons will be selected based on the specified arbor_density and arbor_cell_type. Useful for reproducing the same cells across plots.
- threedim
Logical indicating whether to plot in 3D or to collapse the patch dimension and plot in 2D (default: FALSE).
- title
Title for the plot (default: "Cortex" or network name (if provided), plus plot motif name(s)).
- soma_density
Numeric value between 0 and 1 (inclusive) specifying what fraction of cell bodies are plotted (default: 1.0). Any value greater than 1 is treated as 1, any value less than or equal to 0 is treated as a call to plot a single cell body.
- arbor_density
Numeric value between 0 and 1 (inclusive) specifying what fraction of cells (left after soma_density and cell-type restrictions are applied) have their axonal and dendritic arbors plotted, or, if not plotting arbors, their edges (default: 0.01). Any value greater than 1 is treated as 1, any value less than or equal to 0 is treated as a call to plot arbors for a single cell. Note that plotting arbors can be computationally intensive, so it is advisable to set this to a low value (e.g., 0.01) unless plotting edges only.
- arbor_cell_type
Character string specifying which cell type(s) to include when selecting cells for arbor plotting; options include "all" for all cell types, or the name (or character vector of names) of a specific cell type (default: "all").
- plot_motif
Character string specifying which motif to plot (applies only if plotting edges; as arbors can be built from multiple motifs, cannot plot arbors by motif); options include "all" for all, "local connections" for local connections within each node, or the name of a long-range projection motif (default: "all").
- reconstruct_arbors
Logical indicating whether to reconstruct axonal and dendritic arbors for the neurons in the plot, or whether to instead show synaptic connections as straight edges (default: TRUE, but can be computationally intensive).
- edge_color
Character string specifying how to color the edges; options include "pre_type" to color by presynaptic neuron type, "post_type" to color by postsynaptic neuron type, "motif" to color by motif type, and "is_axon" to color by whether a reconstructed arbor is an axon or dendrite (default: "pre_type"). Cannot use "post_type" or "motif" when reconstructing arbors, as arbor edges can be defined by multiple postsynaptic neuron types and motifs. Cannot use "is_axon" when not reconstructing arbors, as edges are not defined by axonal vs. dendritic processes.
- soma_color
Character string specifying how to color the nodes; options include "layer" to color by layer index or "type" to color by neuron type (default: "layer").
- soma_size_factor
Numeric value controlling how cell size in the plot scales to the number of cells.
- return_plot
Logical indicating whether to return the ggplot object or print the plot directly (default: TRUE).
- return_cell_arbor_idx
Logical indicating whether to return the soma_mask and arbor_idx used for plotting or not (default: TRUE).