plot_networks_by_group: Plot networks by group as a combined panel

View source: R/plot_networks_by_group.R

plot_networks_by_groupR Documentation

Plot networks by group as a combined panel

Description

Plot networks by group as a combined panel

Usage

plot_networks_by_group(
  networks_by_group,
  width = 7,
  height = 7,
  units = "in",
  res = 300,
  groups = list(Factor1 = 1:6, Factor2 = 7:12),
  labels = NULL,
  pie = NULL,
  legend.cex = 0.5,
  GLratio = 1.5,
  ncol = NULL,
  plot_margin = 20,
  title_spacing = 6,
  show_plot = TRUE,
  layoutScale = c(1, 1),
  vsize = 12,
  esize = 20,
  node.width = 1,
  edge.labels = TRUE,
  edge.label.cex = 1.5,
  curveAll = 2,
  minimum = 0.1,
  border.width = 2.5,
  label.cex = 1,
  title.cex = 1.6,
  palette = "ggplot2",
  color = NULL
)

Arguments

networks_by_group

A named list of network objects (one per group).

width

Plot width in inches.

height

Plot height in inches.

units

Units for width/height.

res

Plot resolution in DPI.

groups

Named list mapping factor names to node indices.

labels

Optional character vector of node labels.

pie

Optional named list of pie values per group.

legend.cex

Legend text size.

GLratio

Graph-to-legend ratio.

ncol

Number of columns for the panel layout.

plot_margin

Margin around each plot.

title_spacing

Spacing for titles.

show_plot

Logical; whether to print the plot.

layoutScale

Numeric vector of length 2 for layout scaling.

vsize

Node size.

esize

Edge size.

node.width

Node width.

edge.labels

Logical; show edge labels.

edge.label.cex

Edge label text size.

curveAll

Edge curvature.

minimum

Minimum edge weight to display.

border.width

Node border width.

label.cex

Node label text size.

title.cex

Title text size.

palette

Color palette name.

color

Optional vector of node colors per group.

Value

A combined ggplot (patchwork) object.

Examples

set.seed(123)
n <- 300
f1 <- rnorm(n)
f2 <- 0.3 * f1 + rnorm(n)
items <- data.frame(
  sapply(1:4, function(i) 0.7 * f1 + rnorm(n, 0, 0.7)),
  sapply(1:4, function(i) 0.7 * f2 + rnorm(n, 0, 0.7))
)
names(items) <- c(paste0("A", 1:4), paste0("B", 1:4))
items$sex <- rep(c("Female", "Male"), each = n / 2)

nets <- estimate_networks_by_group(items, group_var = "sex",
                                   columns = names(items)[1:8],
                                   default = "EBICglasso")
p <- plot_networks_by_group(nets, groups = list(A = 1:4, B = 5:8),
                            res = 100, show_plot = FALSE)
p

InterconectaR documentation built on Oct. 16, 2026, 1:06 a.m.