Learn R Programming

cograph (version 2.7.2)

motif_census: Network Motif Analysis

Description

Analyze recurring subgraph patterns (motifs) in networks and test their statistical significance against null models.

Usage

motif_census(
  x,
  size = 3,
  n_random = 100,
  method = c("configuration", "gnm"),
  directed = NULL,
  seed = NULL
)

# S3 method for cograph_motifs print(x, ...)

Value

A cograph_motifs data frame with one row per motif class and columns:

motif

Motif class name (the 16 MAN codes for directed triads, the four undirected triad classes, or motif_<i> labels for size 4).

count

Observed number of that motif in the network.

null_mean, null_sd

Mean and standard deviation of the count across the n_random null graphs.

z_score

(count - null_mean) / null_sd; NA when the null is degenerate (null_sd = 0) and the observation differs from it.

p_value

Two-sided empirical (add-one corrected) permutation p-value, not a Gaussian approximation.

significant

Logical, p_value < 0.05.

The motif size ("size"), directed flag ("directed"), null-model method ("method"), and number of random networks ("n_random") are stored as attributes. Self-loops and multiple edges are removed before counting.

Arguments

x

A matrix, igraph object, or cograph_network

size

Motif size: 3 (triads) or 4 (tetrads). Default 3.

n_random

Number of random networks for the null model. Must be a whole number of at least 2. Default 100.

method

Null model method: "configuration" (preserves degree) or "gnm" (preserves edge count). Default "configuration".

directed

Logical. Treat as directed? Default auto-detected.

seed

Random seed for reproducibility. Default NULL. When supplied, the caller's RNG state is saved and restored.

...

Passed to methods; currently unused.

See Also

motifs() for the unified API, extract_motifs() for detailed triad extraction, plot.cograph_motifs() for plotting

Other motifs: extract_motifs(), extract_triads(), get_edge_list(), motifs(), plot.cograph_motif_analysis(), plot.cograph_motifs(), subgraphs(), triad_census()

Examples

Run this code
# Create a directed network
mat <- matrix(c(
  0, 1, 1, 0,
  0, 0, 1, 1,
  0, 0, 0, 1,
  1, 0, 0, 0
), 4, 4, byrow = TRUE)

# Analyze triadic motifs
m <- motif_census(mat)
print(m)
plot(m)

Run the code above in your browser using DataLab