| Title: | Manage 'CDISC' 'ADaM' Dataset Specifications in 'YAML' Format |
|---|---|
| Description: | Load, validate, and manipulate Clinical Data Interchange Standards Consortium ('CDISC') Analysis Data Model ('ADaM') dataset metadata stored as 'YAML' files. Metadata files are validated against a JSON schema. Provides functions to inspect and modify columns, parameters, and row-level operations within and across 'ADaM' domains. Designed for use with the 'mighty' framework. |
| Authors: | Aksel Thomsen [aut, cre], Ari Siggaard Knoph [aut], Matthew Phelps [aut], Giulia Pais [aut], Novo Nordisk A/S [cph] |
| Maintainer: | Aksel Thomsen <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.1.0 |
| Built: | 2026-05-15 22:03:57 UTC |
| Source: | https://github.com/cran/mighty.metadata |
Functions to list, select, remove, add, update, and move columns in
your mighty_domain() objects.
list_columns(x) remove_columns(x, id) add_column(x, id, ..., .pos = length(x[["columns"]]) + 1L) move_column(x, id, .pos = length(x[["columns"]])) select_column(x, id) update_column(x, id, ...)list_columns(x) remove_columns(x, id) add_column(x, id, ..., .pos = length(x[["columns"]]) + 1L) move_column(x, id, .pos = length(x[["columns"]])) select_column(x, id) update_column(x, id, ...)
x |
|
id |
|
... |
Additional properties to add/update for the column, e.g. a |
.pos |
|
invisible(x)
# Load example configuration x <- mighty_domain( file = system.file("examples", "advs.yml", package = "mighty.metadata") ) # List all columns defined list_columns(x) # Remove the STUDYID and USUBJID columns x |> remove_columns(c("STUDYID", "USUBJID")) |> list_columns() # Add a new column x |> add_column(id = "NEW") |> list_columns() # Add new column with label and as the first column y <- x |> add_column(id = "NEW", label = "My label", .pos = 1) list_columns(y) y[["columns"]][[1]] |> str() # Move the STUDYID column to the 3rd position x |> move_column(id = "STUDYID", .pos = 3) |> list_columns() # Update an existing column x |> update_column(id = "STUDYID", label = "Updated Label") |> select_column(id = "STUDYID") |> str() # Select a specific column select_column(x, id = "STUDYID") |> str()# Load example configuration x <- mighty_domain( file = system.file("examples", "advs.yml", package = "mighty.metadata") ) # List all columns defined list_columns(x) # Remove the STUDYID and USUBJID columns x |> remove_columns(c("STUDYID", "USUBJID")) |> list_columns() # Add a new column x |> add_column(id = "NEW") |> list_columns() # Add new column with label and as the first column y <- x |> add_column(id = "NEW", label = "My label", .pos = 1) list_columns(y) y[["columns"]][[1]] |> str() # Move the STUDYID column to the 3rd position x |> move_column(id = "STUDYID", .pos = 3) |> list_columns() # Update an existing column x |> update_column(id = "STUDYID", label = "Updated Label") |> select_column(id = "STUDYID") |> str() # Select a specific column select_column(x, id = "STUDYID") |> str()
Converts a mighty_study or mighty_domain object into a flat dataframe of column definitions.
create_md_col(x)create_md_col(x)
x |
A mighty_study or mighty_domain object. |
A tibble with one row per column containing:
Table identifier
Table label/description
Column order within table
Column name
Column label
Origin type (e.g., "Predecessor", "Derived")
Logical, whether column is a key
Logical, whether column is a core variable
String, whether a column is Req, Cond or Perm
Derivation method
Codelist reference
Data type ("C" or "N")
Maximum length
Display format
Comment
mighty_study, populate_sparse(), populate_core()
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) mdcol <- create_md_col(study)study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) mdcol <- create_md_col(study)
mighty_domain() provides a robust way of working with ADaM metadata in the {mighty} framework.
A new object is initialized by supplying an existing yaml metadata file. This package provides helpers to update column, parameter, and row entries. See the references below for help:
help("columns")
help("parameters")
help("rows")
mighty_domain() inherits from S7schema::S7schema() and the yaml file is
automatically validated when loaded. The helper functions above also always validates
the new configuration before returning.
You can at anytime validate an object by calling validate() and use
write_config() to save it as a yaml file again.
mighty_domain(file)mighty_domain(file)
file |
|
A mighty_domain S7 object extending S7schema::S7schema.
The underlying list contains the parsed and validated YAML metadata
including id, label, class, keys, columns, parameters,
and rows.
x <- mighty_domain( file = system.file("examples", "advs.yml", package = "mighty.metadata") ) # Custom print method gives a small overview print(x) # Underlying object is a `list` str(x)x <- mighty_domain( file = system.file("examples", "advs.yml", package = "mighty.metadata") ) # Custom print method gives a small overview print(x) # Underlying object is a `list` str(x)
Creates a mighty_study object by loading all YAML metadata files from a
directory. Each YAML file (except _mighty.yml and _study.yml) is parsed
as a mighty_domain object. The optional _study.yml file provides
study-level properties and the optional _mighty.yml file provides
mighty framework configuration.
mighty_study(path, populate = FALSE)mighty_study(path, populate = FALSE)
path |
|
populate |
|
The function scans the directory for files matching *.yaml or *.yml:
Files named _study.yml or _study.yaml are treated as study properties
Files named _mighty.yml or _mighty.yaml are treated as mighty framework config
All other YAML files are loaded as mighty_domain objects
Only one _mighty.yml and one _study.yml file is allowed per directory
A mighty_study S7 object extending list:
mighty_domain objects, named by their id field.
Access via e.g. study$adsl.
@studyStudy-level properties from _study.yml, or empty list
if no properties file exists.
@mightyMighty framework configuration from _mighty.yml, or empty list
if no configuration file exists.
@pathThe source directory path as character(1).
Use write_config() to serialize a mighty_study() object back to YAML
files. Each domain is written as a separate file, plus
_mighty.yml and _study.yml when non-empty.
If path is NULL (default), files are written to x@path.
mighty_domain, write_config(), populate_sparse(),
populate_core(), create_md_col()
# Load example study study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # List tables with metadata names(study) # Access ADVS study$ADVS # Access study-level properties study@study # Access mighty framework configuration study@mighty # Load and populate in one step study <- mighty_study( path = system.file("examples", package = "mighty.metadata"), populate = TRUE ) # Write study back to YAML tmp <- tempdir() write_config(study, path = tmp)# Load example study study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # List tables with metadata names(study) # Access ADVS study$ADVS # Access study-level properties study@study # Access mighty framework configuration study@mighty # Load and populate in one step study <- mighty_study( path = system.file("examples", package = "mighty.metadata"), populate = TRUE ) # Write study back to YAML tmp <- tempdir() write_config(study, path = tmp)
Verbosity level for functions in mighty.metadata. See zephyr::verbosity_level for details.
Default: NA_character_
Option: mighty.metadata.verbosity_level
Environment: R_MIGHTY.METADATA_VERBOSITY_LEVEL
Functions to list, select, remove, add, update, and move parameters in
your mighty_domain() objects.
list_parameters(x) remove_parameters(x, id) add_parameter( x, id, label, columns, ..., .pos = length(x[["parameters"]]) + 1L ) move_parameter(x, id, .pos = length(x[["parameters"]])) update_parameter(x, id, ...) select_parameter(x, id)list_parameters(x) remove_parameters(x, id) add_parameter( x, id, label, columns, ..., .pos = length(x[["parameters"]]) + 1L ) move_parameter(x, id, .pos = length(x[["parameters"]])) update_parameter(x, id, ...) select_parameter(x, id)
x |
|
id |
|
label |
|
columns |
|
... |
Additional properties to add for the parameter, e.g. a component reference. |
.pos |
|
invisible(x)
# Load example configuration x <- mighty_domain( file = system.file("examples", "advs.yml", package = "mighty.metadata") ) # List all parameters defined list_parameters(x) # Remove the BMIGRP parameter x |> remove_parameters("BMIGRP") |> list_parameters() # Add a new parameter x |> add_parameter( id = "NEW", label = "My new parameter", columns = list(list(id = "AVAL")) ) |> list_parameters() # Move the BMIGRP parameter to the 1st position x |> move_parameter(id = "BMIGRP", .pos = 1) |> list_parameters() # Update an existing parameter x |> update_parameter(id = "BMI", label = "Updated BMI Label") |> select_parameter(id = "BMI") |> str() # Select a specific parameter select_parameter(x, id = "BMI") |> str()# Load example configuration x <- mighty_domain( file = system.file("examples", "advs.yml", package = "mighty.metadata") ) # List all parameters defined list_parameters(x) # Remove the BMIGRP parameter x |> remove_parameters("BMIGRP") |> list_parameters() # Add a new parameter x |> add_parameter( id = "NEW", label = "My new parameter", columns = list(list(id = "AVAL")) ) |> list_parameters() # Move the BMIGRP parameter to the 1st position x |> move_parameter(id = "BMIGRP", .pos = 1) |> list_parameters() # Update an existing parameter x |> update_parameter(id = "BMI", label = "Updated BMI Label") |> select_parameter(id = "BMI") |> str() # Select a specific parameter select_parameter(x, id = "BMI") |> str()
Adds core variables from supplier datasets as predecessor columns to
datasets that use them (marked with usecore = TRUE).
Note: Currently only accepts core variables from ADSL.
populate_core(x, ...)populate_core(x, ...)
x |
A mighty_study or mighty_domain object. |
... |
Additional arguments passed to methods. |
A modified mighty_study or mighty_domain with core variables added as predecessor columns.
mighty_study, populate_sparse(), create_md_col()
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) study <- populate_core(study)study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) study <- populate_core(study)
Populates column metadata from predecessor references. Columns with a
method in the format domain.column (e.g., ADSL.USUBJID) inherit
metadata from the referenced predecessor.
populate_sparse(x, ...)populate_sparse(x, ...)
x |
A mighty_study or mighty_domain object. |
... |
Additional arguments passed to methods. |
A modified mighty_study or mighty_domain with predecessor column metadata populated.
mighty_study, populate_core(), create_md_col()
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) study <- populate_sparse(study)study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) study <- populate_sparse(study)
Evaluates include fields on metadata items (domains, columns, rows, parameters)
and removes items where the condition evaluates to FALSE.
resolve_includes(x, info = list())resolve_includes(x, info = list())
x |
A mighty_study or mighty_domain object. |
info |
|
Include conditions are R expressions with {glue} syntax for variable
substitution and evaluation. The info list provides the values used
to do this.
The input object with conditional items resolved.
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # Add a conditional column study$ADVS <- update_column( study$ADVS, id = "STUDYID", include = "{study_id == 'my_study'}" ) # Condition TRUE: column kept (study_id is "my_study" in @study) study |> resolve_includes() |> getElement("ADVS") |> list_columns() # Condition FALSE: column removed study |> resolve_includes(info = list(study_id = "other")) |> getElement("ADVS") |> list_columns()study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # Add a conditional column study$ADVS <- update_column( study$ADVS, id = "STUDYID", include = "{study_id == 'my_study'}" ) # Condition TRUE: column kept (study_id is "my_study" in @study) study |> resolve_includes() |> getElement("ADVS") |> list_columns() # Condition FALSE: column removed study |> resolve_includes(info = list(study_id = "other")) |> getElement("ADVS") |> list_columns()
Functions to list, select, remove, add, update, and move row operations in
your mighty_domain() objects.
list_rows(x) remove_rows(x, id) add_row(x, id, ..., .pos = length(x[["rows"]]) + 1L) move_row(x, id, .pos = length(x[["rows"]])) update_row(x, id, ...) select_row(x, id)list_rows(x) remove_rows(x, id) add_row(x, id, ..., .pos = length(x[["rows"]]) + 1L) move_row(x, id, .pos = length(x[["rows"]])) update_row(x, id, ...) select_row(x, id)
x |
|
id |
|
... |
Additional properties to add for the row, e.g. a |
.pos |
|
invisible(x)
# Load example configuration x <- mighty_domain( file = system.file("examples", "advs.yml", package = "mighty.metadata") ) # List all rows defined list_rows(x) # Add a new row y <- x |> add_row(id = "NEW") list_rows(y) # Remove the new row again y |> remove_rows("NEW") |> list_rows() # Update an existing row x |> update_row(id = "BASELINE", method = "Updated method") |> select_row(id = "BASELINE") |> str() # Select a specific row select_row(x, id = "BASELINE") |> str()# Load example configuration x <- mighty_domain( file = system.file("examples", "advs.yml", package = "mighty.metadata") ) # List all rows defined list_rows(x) # Add a new row y <- x |> add_row(id = "NEW") list_rows(y) # Remove the new row again y |> remove_rows("NEW") |> list_rows() # Update an existing row x |> update_row(id = "BASELINE", method = "Updated method") |> select_row(id = "BASELINE") |> str() # Select a specific row select_row(x, id = "BASELINE") |> str()