| motifs | R Documentation |
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 class 'cograph_motif_result'
print(x, ...)
## S3 method for class 'cograph_motif_result'
plot(
x,
type = c("triads", "types", "significance", "patterns"),
n = 15,
ncol = 5,
colors = c("#2166AC", "#B2182B"),
node_size = 5,
label_size = 11,
title_size = 12,
stats_size = 13,
legend_size = 13,
legend = TRUE,
motif_color = "#800020",
spacing = 1,
base_size = 12,
combined = TRUE,
...
)
x |
Input data: a tna object, cograph_network, matrix, igraph, or data.frame (edge list). |
named_nodes |
Logical. If FALSE (default), performs census (type-level
counts). If TRUE, extracts specific node triples (instance-level).
|
actor |
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. |
window |
Numeric. Window size for windowed analysis. Splits each actor's transitions into windows of this size. NULL (default) means no windowing. |
window_type |
Character. Window type: "rolling" (default) or "tumbling".
Only used when |
pattern |
Which MAN triad types to include in the analysis:
|
include |
Character vector of MAN types to include exclusively.
Overrides |
exclude |
Character vector of MAN types to exclude. Applied after
|
significance |
Logical. Run permutation significance test? Default TRUE. |
n_perm |
Number of permutations for significance. Default 1000. |
min_count |
Inclusive minimum count to keep a row — rows with
|
edge_method |
Method for determining edge presence: "any" (default), "expected", or "percent". |
edge_threshold |
Threshold for "expected" or "percent" methods. Default 1.5. |
min_transitions |
Minimum total transitions for a unit to be included. Default 5. |
top |
Return only the top N results. NULL returns all. |
seed |
Random seed for reproducibility. |
... |
Additional arguments passed to internal plot helpers. |
type |
Plot type:
|
n |
Maximum number of items to plot. Default 15. |
ncol |
Number of columns in the triad/pattern grid. Default 5. |
colors |
Two-element color vector mapped to a three-tone
significance scale (used by |
node_size |
Triad node radius (relative). Default 5.
( |
label_size |
Triad node-label font size in points. Default 11. |
title_size |
Per-panel title font size in points. Default 12. |
stats_size |
Per-panel statistics caption font size in points
(e.g., |
legend_size |
Bottom legend font size in points. Default 13. |
legend |
Logical. Show the abbreviation legend strip below the
triad grid. Default |
motif_color |
Color of triad nodes/edges/labels. Default
|
spacing |
Triangle spread inside each panel; |
base_size |
Base font size for the |
combined |
Logical: when TRUE (default) and |
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.
A cograph_motif_result object (a list) with:
Data frame of results. Census mode
(named_nodes = FALSE): one row per MAN type with columns
type, count, and when significance = TRUE also
expected, z, p, sig. Instance mode
(named_nodes = TRUE): one row per concrete node triple with
columns triad, type, observed, and when
significance = TRUE also expected, z, p,
sig.
Named table of MAN-type counts. In census
mode the values come from the count column; in instance
mode they come from table(results$type) and describe how
many concrete node-triples fall under each MAN type. Sorted
descending so plot(., type = "patterns") draws the most
frequent types first.
Analysis level: "individual" when the input
carried per-subject sequence data (tna with $data,
edge list with an actor column, Nestimate netobject built
from build_tna()/similar), otherwise "aggregate"
(a single transition matrix).
Logical mirror of the named_nodes argument.
Plot helpers gate per-type significance decoration on this so the
instance-mode case (multiple triples per MAN type) doesn't get
silently aggregated.
Number of subjects/units. 1 at aggregate level,
nrow of the input sequence data at individual level.
List of the call's parameters (pattern,
edge_method, edge_threshold, significance,
n_perm, min_count, labels, n_states,
and the window settings if any). Read by print() and the
plot() dispatcher.
Invisibly returns the input x for "triads" and
"patterns", or the underlying ggplot for "types" and
"significance".
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()
# Census from a matrix (no significance test -- fastest path)
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)
## Not run:
# With a minimal significance test (set n_perm >= 500 in practice)
motifs(mat, n_perm = 10L, seed = 1)
## End(Not run)
## Not run:
Mod <- tna::tna(tna::group_regulation)
motifs(Mod, n_perm = 10L, seed = 1)
subgraphs(Mod, n_perm = 10L, seed = 1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.