Generates an interactive network visualisation using visNetwork library. The visualisation includes interactive features for exploring model structure and relationships.
By default, nodes are colored as:
inputs (light blue, #B0DFF9): Input datasets, data frames, files, and columns
in_node (blue, #6ABDEB): Input nodes and scalar values
out_node (green, #A4CF96): Output nodes
filter (light purple, #E8A5E5): Filtered nodes created with
mc_filter()compare (medium purple, #D88FD5): Comparison nodes created with
mc_compare()trials_info (light orange, #FAE4CB): Trial, subset, and related information nodes
total (orange, #F39200): Total nodes created with
at_least_one()agg_total (dark orange, #C17816): Aggregated total nodes created with
agg_variates()
Usage
mc_network(
mcmodule,
variate = 1,
color_pal = NULL,
color_by = NULL,
legend = FALSE,
inputs = FALSE,
percentages = TRUE
)Arguments
- mcmodule
(mcmodule object). Module containing network to visualise.
- variate
(positive integer). Variate (row) to visualise. The same row number is used across the module; this argument does not filter variates by key values. See
get_node_table(). Default: 1.- color_pal
(character vector, optional). Custom colour palette for nodes. Default: NULL.
- color_by
(character, optional). Column name to determine node colours. Default: NULL.
- legend
(logical). If TRUE, show colours legend. Default: FALSE.
- inputs
(logical). If TRUE, show non-node inputs. Default: FALSE.
- percentages
(logical). If TRUE, eligible stochastic nodes whose values do not exceed 1 are displayed as percentages. If FALSE, all stochastic nodes are displayed as numbers. Default: TRUE.
Value
An interactive visNetwork object with highlighting of connected nodes, node selection and filtering by module, directional arrows, hierarchical layout, and draggable nodes.
See also
get_node_table() and get_edge_table() for the underlying tables,
mc_filter() for selecting variates by conditions, and
visNetwork::visNetwork() for the underlying visualisation.
Examples
# \donttest{
network <- mc_network(mcmodule = imports_mcmodule)
# Select a variate by its key values rather than its original row number.
# The filtered node's first retained variate is displayed with variate = 1.
selected_module <- mc_filter(
imports_mcmodule,
"w_prev",
pathogen == "b",
origin == "south",
name = "w_prev_selected"
)
selected_network <- mc_network(selected_module, variate = 1)
# }
