Two modes of motif analysis for networks:
Census (named_nodes = FALSE, default): Counts MAN type
frequencies with significance testing. Nodes are exchangeable.
Instances (named_nodes = TRUE, or use subgraphs()):
Lists specific node triples forming each pattern. Nodes are NOT
exchangeable.
motifs(
x,
named_nodes = FALSE,
actor = NULL,
window = NULL,
window_type = c("rolling", "tumbling"),
pattern = c("triangle", "network", "closed", "all"),
include = NULL,
exclude = NULL,
significance = TRUE,
n_perm = 1000L,
min_count = if (named_nodes) 5L else NULL,
edge_method = c("any", "expected", "percent"),
edge_threshold = 1.5,
min_transitions = 5,
top = NULL,
seed = NULL
)# S3 method for cograph_motif_result
plot(
x,
type = c("triads", "types", "significance", "patterns"),
n = 15,
ncol = 5,
colors = c("#2166AC", "#B2182B"),
...
)
A cograph_motif_result object with:
Data frame of results. Census: type, count, (z, p, sig). Instances: triad, type, observed, (z, p, sig).
Named counts by MAN type
Analysis level: "individual" or "aggregate"
Whether nodes are identified (TRUE) or exchangeable (FALSE)
Number of units analyzed
List of parameters used
Input data: a tna object, cograph_network, matrix, igraph, or data.frame (edge list).
Logical. If FALSE (default), performs census (type-level
counts). If TRUE, extracts specific node triples (instance-level).
subgraphs() is a convenience wrapper that sets this to TRUE.
Character. Column name in the edge list metadata to group by. If NULL (default), auto-detects standard column names (session_id, session, actor, user, participant). If no grouping column found, performs aggregate analysis.
Numeric. Window size for windowed analysis. Splits each actor's transitions into windows of this size. NULL (default) means no windowing.
Character. Window type: "rolling" (default) or "tumbling".
Only used when window is set.
Pattern filter: "triangle" (default), "network", "closed", "all".
Character vector of MAN types to include exclusively.
Overrides pattern.
Character vector of MAN types to exclude. Applied after
pattern filter.
Logical. Run permutation significance test? Default TRUE.
Number of permutations for significance. Default 1000.
Minimum observed count to include a triad (instance mode only). Default 5 for instances, NULL for census.
Method for determining edge presence: "any" (default), "expected", or "percent".
Threshold for "expected" or "percent" methods. Default 1.5.
Minimum total transitions for a unit to be included. Default 5.
Return only the top N results. NULL returns all.
Random seed for reproducibility.
Plot type: "triads" (network diagrams), "types" (bar chart), "significance" (z-score plot), "patterns" (abstract MAN diagrams).
Number of items to plot. Default 15.
Number of columns in triad grid. Default 5.
Colors for visualization. Default blue/red.
Additional arguments passed to plot helpers.
Detects input type and analysis level automatically. For inputs with individual/group data (tna objects, cograph networks from edge lists with metadata), performs per-group analysis. For aggregate inputs (matrices, igraph), analyzes the single network.
subgraphs(), motif_census(), extract_motifs()
Other motifs:
extract_motifs(),
extract_triads(),
get_edge_list(),
motif_census(),
plot.cograph_motif_analysis(),
plot.cograph_motifs(),
subgraphs(),
triad_census()
if (FALSE) {
# Census from a matrix
mat <- matrix(c(0,3,2,0, 0,0,5,1, 0,0,0,4, 2,0,0,0), 4, 4, byrow = TRUE)
rownames(mat) <- colnames(mat) <- c("Plan","Execute","Monitor","Adapt")
motifs(mat, significance = FALSE)
if (requireNamespace("tna", quietly = TRUE)) {
# Census from tna object
Mod <- tna::tna(tna::group_regulation)
motifs(Mod)
# Instances: specific node triples
subgraphs(Mod)
}
}
Run the code above in your browser using DataLab