graph_from_metadata: Build a Dependency Graph Directly from a Metadata Table

View source: R/graph-build-auto.R

graph_from_metadataR Documentation

Build a Dependency Graph Directly from a Metadata Table

Description

One-shot convenience builder that auto-detects canonical columns in a metadata table, creates the corresponding node and edge sets, optionally derives timepoint ordering from time_index, and assembles a dependency_graph. Columns that are absent or entirely missing are silently skipped.

Usage

graph_from_metadata(
  meta,
  columns = NULL,
  dataset_name = NULL,
  graph_name = NULL,
  outcome_scope = c("sample", "subject"),
  time_precedence = TRUE,
  validate = TRUE,
  validation_overrides = list()
)

Arguments

meta

A data.frame containing one row per sample and optional canonical columns: sample_id (required), subject_id, batch_id, study_id, timepoint_id, time_index, assay_id, featureset_id, outcome_id, or outcome_value.

columns

Optional named character vector passed to ingest_metadata() to rename user columns to canonical names.

dataset_name, graph_name

Optional metadata labels.

outcome_scope

Either "sample" (default) or "subject". Controls whether outcome edges attach to samples or subjects.

time_precedence

If TRUE and time_index is present, derive timepoint_precedes edges from the ordering of time_index.

validate

Forwarded to build_dependency_graph().

validation_overrides

Forwarded to build_dependency_graph().

Value

A validated dependency_graph.

Examples

meta <- data.frame(
  sample_id  = c("S1", "S2", "S3", "S4"),
  subject_id = c("P1", "P1", "P2", "P2"),
  batch_id   = c("B1", "B2", "B1", "B2"),
  timepoint_id = c("T1", "T2", "T1", "T2"),
  time_index = c(1, 2, 1, 2),
  outcome_id = c("ctrl", "case", "ctrl", "case")
)

g <- graph_from_metadata(meta, graph_name = "demo")
g

splitGraph documentation built on July 3, 2026, 5:06 p.m.