Overview
Clinical data scientists programming CDISC Analysis Data Model (ADaM) datasets need specifications that are both human-readable and machine-readable. These specifications typically live in Excel spreadsheets that are hard to version-control, difficult to validate, and cannot be consumed by automation tooling. mighty.metadata replaces that workflow with YAML files.
The package loads YAML specifications, validates them against a JSON schema, and provides a pipe-friendly R interface for inspecting and modifying column, parameter, and row definitions. It works at two levels: a single ADaM domain (mighty_domain()) or an entire study (mighty_study()).
mighty.metadata is part of the mighty framework for automated ADaM programming. It is built on S7 and S7schema for robust validation and modern OOP.
Installation
# Install from CRAN:
install.packages("mighty.metadata")
# Install the development version from GitHub:
pak::pak("NovoNordisk-OpenSource/mighty.metadata")Usage
Load and inspect a single domain
mighty_domain() loads a YAML metadata file for a single ADaM dataset and validates it against the schema on load.
library(mighty.metadata)
advs <- mighty_domain(
file = system.file("examples", "advs.yml", package = "mighty.metadata")
)
advs
#> <mighty.metadata::mighty_domain>
#> ADVS: Vital Signs Analysis Dataset
#> Class: BASIC DATA STRUCTURE
#> Keys: USUBJID, PARAMCD, and AVISITNUse list_columns(), list_parameters(), and list_rows() to see what the specification contains.
list_columns(advs)
#> [1] "STUDYID" "USUBJID" "SAFFL" "TRTP" "VISITNUM" "AVISITN"
#> [7] "AVISIT" "PARAMCD" "PARAM" "AVAL" "AVALC"
list_parameters(advs)
#> [1] "BMI" "BMIGRP"
list_rows(advs)
#> [1] "BASELINE"Modify a domain
Each dimension (columns, parameters, rows) has a consistent set of verbs: list_*, add_*, remove_*, update_*, select_*, and move_*. These return a modified mighty_domain object and work naturally with the pipe.
# Add a new column
advs |>
add_column(id = "TRTA", label = "Actual Treatment", .pos = 3) |>
list_columns()
#> [1] "STUDYID" "USUBJID" "TRTA" "SAFFL" "TRTP" "VISITNUM"
#> [7] "AVISITN" "AVISIT" "PARAMCD" "PARAM" "AVAL" "AVALC"
# Remove columns
advs |>
remove_columns(c("VISITNUM", "AVALC")) |>
list_columns()
#> [1] "STUDYID" "USUBJID" "SAFFL" "TRTP" "AVISITN" "AVISIT" "PARAMCD"
#> [8] "PARAM" "AVAL"Work with a full study
mighty_study() loads every YAML file from a directory. Each file becomes a named mighty_domain. The optional _study.yml provides study-level properties as a study_config and _mighty.yml provides mighty framework configuration as a mighty_config.
study <- mighty_study(
path = system.file("examples", package = "mighty.metadata")
)
study
#> <mighty.metadata::mighty_study/list/S7_object>
#> @ mighty: <mighty.metadata::mighty_config>
#> @ study: <mighty.metadata::study_config>
#> $ ADAE: <mighty.metadata::mighty_domain>
#> $ ADSL: <mighty.metadata::mighty_domain>
#> $ ADVS: <mighty.metadata::mighty_domain>
names(study)
#> [1] "ADAE" "ADSL" "ADVS"
study@study
#> <mighty.metadata::study_config>
#> Study ID: example_study
#> Fields: `study_id`
study@mighty
#> <mighty.metadata::mighty_config>
#> External data: 3 sources (`DM`, `VS`, and `AE`)
#> Repos: 2 (`NovoNordisk-OpenSource/mighty.standards/components@main` and `.`)Useful links
-
vignette("mighty-metadata")– Getting started guide -
vignette("adam-schema")– Domain YAML schema reference -
vignette("study-schema")– Study YAML schema reference -
vignette("mighty-schema")– Mighty YAML schema reference - S7schema – Schema validation engine used by mighty.metadata
- Novo Nordisk Open Source R packages – Overview of R packages published by Novo Nordisk.
