View source: R/plot_critical_edges.R
| plot_critical_edges | R Documentation |
Produces a multi-panel figure summarising the output of
identify_critical_links: one panel per population showing the
weighted central graph, plus a final panel that highlights the critical
edges on a chosen reference central graph. This is the canonical
visualization of the BrainNetTest workflow and replaces the manual
igraph plumbing required to build the same figure.
plot_critical_edges(
populations,
critical_links,
communities = NULL,
layout = NULL,
central_graphs = NULL,
reference = 1L,
threshold = 0.5,
edge_scale = 6,
critical_color = "red",
critical_width = 3,
background_color = "grey80",
background_width = 1,
vertex_size = 12,
vertex_label = TRUE,
panel_titles = NULL,
mfrow = NULL,
...
)
populations |
A named |
critical_links |
The object returned by
|
communities |
Optional integer (or factor) vector of length
|
layout |
Optional layout for the graphs. Either an
|
central_graphs |
Optional list of pre-computed central graphs (one per
population). If |
reference |
Either an integer index or a name selecting which
population's central graph is used as the background of the
critical-edges panel. Default |
threshold |
Numeric in |
edge_scale |
Numeric multiplier applied to the central-graph edge
weights to set |
critical_color, critical_width |
Color and line width used to draw
critical edges. Defaults |
background_color, background_width |
Color and line width used to draw
non-critical edges in the critical panel. Defaults |
vertex_size |
Vertex size passed to |
vertex_label |
Logical. If |
panel_titles |
Optional character vector of length
|
mfrow |
Optional integer vector of length 2 giving the
|
... |
Additional arguments forwarded to
|
The first length(populations) panels show the weighted
central graph of each population, with edge widths proportional to the
central-graph weights. The final panel binarises the chosen reference
central graph at threshold and overlays the critical edges
returned by identify_critical_links() in
critical_color. Critical edges that are absent from the binarised
reference graph are added so that they remain visible.
The graphics state (par(mfrow, mar, oma)) is restored on exit.
Invisibly returns NULL; called for its side effect of
producing the multi-panel plot.
identify_critical_links,
compute_central_graph,
get_critical_nodes.
set.seed(123)
community_sizes <- c(4, 2, 3, 3, 5)
control <- generate_category_graphs(
n_graphs = 50, n_nodes = 17, n_communities = 5,
community_sizes = community_sizes,
base_intra_prob = rep(0.70, 5), base_inter_prob = 0.05)
patient <- generate_category_graphs(
n_graphs = 50, n_nodes = 17, n_communities = 5,
community_sizes = community_sizes,
base_intra_prob = c(0.40, 0.70, 0.70, 0.70, 0.70),
base_inter_prob = 0.05)
populations <- list(Control = control, Patient = patient)
result <- identify_critical_links(populations, alpha = 0.05,
method = "fisher", n_permutations = 200, seed = 1)
communities <- rep(seq_along(community_sizes), times = community_sizes)
plot_critical_edges(populations, result, communities = communities)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.