Skip to contents

Creates a Graphviz DOT script that visualizes the two-layer structure of a symmetric NMF model (\(Y \approx X C X^\top\)).

The resulting diagram displays:

  • outer nodes: the original network nodes (rows/columns of Y),

  • inner nodes: the latent basis/group nodes (columns of X),

  • directed edges from basis to node: membership weights from X,

  • undirected edges between basis nodes: inter-group interactions from C matrix (for tri-symmetric models only).

Usage

nmfkc.net.DOT(
  result,
  threshold = 0.01,
  sig.level = 0.1,
  weight_scale = 5,
  weight_scale_xy = 1,
  weight_scale_xx = weight_scale,
  rankdir = "TB",
  fill = TRUE,
  hide.isolated = TRUE,
  Y.label = NULL,
  X.label = NULL,
  Y.title = "Nodes (Y)",
  X.title = "Basis (X)",
  show.theta = NULL,
  signed = inherits(result, "nmfkc.net.signed"),
  cluster.box = c("none", "normal", "faint", "invisible"),
  layout = c("fdp", "dot", "neato", "circo", "twopi"),
  X.color = NULL,
  Y.cluster = c("soft", "hard")
)

Arguments

result

A list returned by nmfkc() with Y.symmetric = "bi" or "tri", or the newer nmfkc.net with type = "bi" or "tri". If inference results are present (from nmfkc.net.inference), C edges are decorated with significance stars.

threshold

Minimum coefficient value to display an edge.

sig.level

Significance level for filtering C edges (if inference results are present). Set to NULL to show all edges above threshold.

weight_scale

Base scaling factor for edge widths.

weight_scale_xy

Scaling factor for X edges (basis -> node).

weight_scale_xx

Scaling factor for C edges (basis <-> basis).

rankdir

Graphviz rank direction ("TB" or "LR").

fill

Logical; whether nodes are filled with color.

hide.isolated

Logical; if TRUE, omit outer nodes with no X edge above threshold.

Y.label

Character vector of labels for outer nodes.

X.label

Character vector of labels for basis nodes.

Y.title

Cluster title for outer nodes.

X.title

Cluster title for basis nodes.

show.theta

Logical or NULL. Whether to draw C edges between basis nodes. NULL = auto-detect (TRUE for tri, FALSE for bi).

signed

Logical. If TRUE, \(C\) is treated as a signed matrix: positive entries rendered as solid edges and negative as dashed, with edge visibility threshold on \(|C|\). Default is inherits(result, "nmfkc.net.signed") so that results from nmfkc.net are auto-detected.

cluster.box

Style of cluster box: "none", "normal", "faint", "invisible".

layout

Graphviz layout engine: "fdp", "dot", "neato", "circo", "twopi".

X.color

Color palette for basis nodes (length Q).

Y.cluster

Coloring mode for outer nodes: "soft" (weighted mix) or "hard" (most probable basis color).

Value

A character string of class c("nmfkc.net.DOT", "nmfkc.DOT") representing a valid Graphviz DOT script. Use plot() to render (requires DiagrammeR).

Lifecycle

This function is experimental. The interface may change in future versions; details are to be described in an upcoming paper.

Examples

# \donttest{
library(nmfkc)
Y <- matrix(c(0,1,1,0,0,0,
              1,0,1,0,0,0,
              1,1,0,1,0,0,
              0,0,1,0,1,1,
              0,0,0,1,0,1,
              0,0,0,1,1,0), 6, 6)
res <- nmfkc.net(Y, rank = 2, type = "tri", nstart = 20)
dot <- nmfkc.net.DOT(res)
plot(dot)
# }