Visualizes multiple network clusters with summary edges between clusters and individual edges within clusters. Each cluster is displayed as a shell shape containing its nodes.
plot_mtna(
x,
cluster_list = NULL,
community = NULL,
layout = "circle",
spacing = 4,
shape_size = 1.8,
node_spacing = 0.5,
colors = NULL,
shapes = NULL,
edge_colors = NULL,
bundle_edges = TRUE,
bundle_strength = 0.8,
summary_edges = TRUE,
aggregation = c("sum", "mean", "max", "min", "median", "density"),
within_edges = TRUE,
show_border = TRUE,
legend = TRUE,
legend_position = "topright",
curvature = 0.3,
node_size = 3,
layout_margin = 0.15,
scale = 1,
show_labels = FALSE,
nodes = NULL,
label_size = NULL,
label_abbrev = NULL,
cluster_shape = NULL,
...
)mtna(
x,
cluster_list = NULL,
community = NULL,
layout = "circle",
spacing = 4,
shape_size = 1.8,
node_spacing = 0.5,
colors = NULL,
shapes = NULL,
edge_colors = NULL,
bundle_edges = TRUE,
bundle_strength = 0.8,
summary_edges = TRUE,
aggregation = c("sum", "mean", "max", "min", "median", "density"),
within_edges = TRUE,
show_border = TRUE,
legend = TRUE,
legend_position = "topright",
curvature = 0.3,
node_size = 3,
layout_margin = 0.15,
scale = 1,
show_labels = FALSE,
nodes = NULL,
label_size = NULL,
label_abbrev = NULL,
cluster_shape = NULL,
...
)
Invisibly returns a cluster_summary object when
summary_edges = TRUE, and otherwise the
plot_tna() result (a cograph_network object).
See plot_mtna.
A tna object, weight matrix, or cograph_network.
Clusters can be specified as:
A list of character vectors (node names per cluster)
A string column name from nodes data (e.g., "groups")
NULL with community specified for auto-detection
NULL with a cograph_network that has a common cluster/group column
Community detection method to use for auto-clustering.
If specified, overrides cluster_list. See detect_communities
for available methods.
How to arrange the clusters: "circle" (default), "grid", "horizontal", "vertical".
Distance between cluster centers. Default 4.
Size of each cluster shape (shell radius). Default 1.8.
Radius for node placement within shapes (0-1 relative to shape_size). Default 0.5.
Vector of colors for each cluster. Default auto-generated.
Vector of shapes for each cluster. Defaults cycle through "circle", "square", "diamond", "triangle", "pentagon", "hexagon", "star", and "cross"; summary shells draw non-shell shapes with the circular fallback.
Vector of edge colors by source cluster. Default auto-generated.
Logical. Bundle inter-cluster edges through channels. Default TRUE.
How tightly to bundle edges (0-1). Default 0.8.
Logical. Show aggregated summary edges between clusters instead of individual node edges. Default TRUE.
Method for aggregating edge weights between clusters: "sum" (total flow), "mean" (average strength), "max" (strongest link), "min" (weakest link), "median", or "density" (normalized by possible edges). Default "sum". Only used when summary_edges = TRUE.
Logical. When summary_edges is TRUE, also show individual edges within each cluster. Default TRUE.
Logical. Draw a border around each cluster. Default TRUE.
Logical. Whether to show legend. Default TRUE.
Position for legend. Default "topright".
Edge curvature. Default 0.3.
Size of nodes inside shapes. Default 3.
Margin around the layout as fraction of range. Default 0.15.
Scaling factor for high-resolution output. Values greater than
1 reduce node, edge, label, and legend sizes by sqrt(scale) while
leaving cluster spacing and shape_size unchanged. Default 1.
Logical. Show node labels inside clusters. Default FALSE.
Node metadata. Can be:
NULL (default): Use existing nodes data from cograph_network
Data frame: Must have label column for matching; if labels
column exists, uses it for display text
Display priority: labels column > label column (identifiers).
Label text size. Default NULL (auto-scaled).
Label abbreviation: NULL (none), integer (max chars), or "auto" (adaptive based on node count).
Accepted for compatibility; currently unused. Use
shapes to control cluster shell shapes.
Additional parameters passed to plot_tna().
csum, plot_mcml
set.seed(42)
nodes <- paste0("N", 1:20)
m <- matrix(runif(400, 0, 0.3), 20, 20); diag(m) <- 0
colnames(m) <- rownames(m) <- nodes
clusters <- list(N = nodes[1:5], E = nodes[6:10],
S = nodes[11:15], W = nodes[16:20])
plot_mtna(m, clusters, summary_edges = TRUE)
set.seed(1)
nodes <- paste0("N", 1:12)
m <- matrix(runif(144, 0, 0.3), 12, 12); diag(m) <- 0
colnames(m) <- rownames(m) <- nodes
clusters <- list(C1 = nodes[1:4], C2 = nodes[5:8], C3 = nodes[9:12])
mtna(m, clusters)
Run the code above in your browser using DataLab