| 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], Katarzyna Graczyk [aut], Michael Hedegaard Thomsen [aut], Novo Nordisk A/S [cph] |
| Maintainer: | Aksel Thomsen <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.1.0.9018 |
| Built: | 2026-10-16 12:48:05 UTC |
| Source: | https://github.com/NovoNordisk-OpenSource/mighty.metadata |
mighty_codelists() creates an S7 object for storing codelist metadata.
The class represents the contents of _codelists.yml as a list of codelist
entries. Each codelist is referenced from column metadata via its id
(the codelist field of a column).
A codelist can contain the following operation groups:
values: values of a sponsor-defined (non-standard) codelist,
subset: values kept from a standard controlled terminology codelist,
restore: SDTM controlled terminology values included in the ADaM
codelist even when they are not used in the SDTM define.xml,
extend: values added to an extensible codelist.
values is meant for codelists that are not part of standard controlled
terminology, while subset, restore and extend modify a standard
codelist retrieved from an external source.
The object is validated on creation and after every modification. Validation includes:
schema compliance with inst/schema/codelists.json,
uniqueness of codelist identifiers (id),
uniqueness of code within a codelist across all operation groups,
values being mutually exclusive with subset and restore,
consistent use of decode within an operation group (all or none).
Codelists do not have to be referenced by a column. Use
check_codelist_references() to check that every codelist in a
mighty_study() is used.
mighty_codelists(file, .data) list_codelists(x) select_codelist(x, id) add_codelist(x, id, label, description, datatype, code, decode = NULL) remove_codelist(x, id) update_codelist(x, id, ...) add_codelist_values(x, id, code, decode = NULL) extend_codelist_values(x, id, code, decode = NULL) restore_codelist_values(x, id, code) subset_codelist_values(x, id, code) remove_codelist_value(x, id, code) move_codelist_value(x, id, code, .pos) update_codelist_value(x, id, code, decode) check_codelist_references(study)mighty_codelists(file, .data) list_codelists(x) select_codelist(x, id) add_codelist(x, id, label, description, datatype, code, decode = NULL) remove_codelist(x, id) update_codelist(x, id, ...) add_codelist_values(x, id, code, decode = NULL) extend_codelist_values(x, id, code, decode = NULL) restore_codelist_values(x, id, code) subset_codelist_values(x, id, code) remove_codelist_value(x, id, code) move_codelist_value(x, id, code, .pos) update_codelist_value(x, id, code, decode) check_codelist_references(study)
file |
|
.data |
|
x |
A |
id |
|
label |
|
description |
|
datatype |
|
code |
|
decode |
|
... |
Codelist-level fields to update ( |
.pos |
|
study |
A |
Functions to list, select, add, remove, and update codelists and their
values in your mighty_codelists() object or directly on a
mighty_study() object.
Codelist level:
add_codelist() adds a new sponsor-defined codelist with values.
remove_codelist() removes codelist(s) and all their contents.
update_codelist() updates label, description and datatype.
select_codelist() returns a single codelist entry as a list.
Value level:
add_codelist_values() adds values to an existing codelist.
remove_codelist_value() removes value(s) from whichever operation group
they belong to. Empty groups are dropped, and a codelist left without any
values is removed.
move_codelist_value() moves a value within its operation group.
update_codelist_value() updates the decode of a values or extend
entry.
Reuse of external codelists:
Most codelists come from an external source of controlled terminology
(e.g. CDISC CT), retrieved by downstream tooling such as mighty.toolbox.
Instead of redefining these codelists, the functions below record how the
study changes them. Support for reusing external codelists is still
maturing. Each function creates the codelist entry if it does not exist.
subset_codelist_values() keeps only the given codes from the external
codelist (subset).
restore_codelist_values() includes SDTM controlled terminology codes
that would otherwise be excluded from the ADaM define.xml (restore).
extend_codelist_values() adds sponsor-defined codes to an extensible
external codelist (extend).
subset and restore cannot be combined with values on the same
codelist, as values defines a sponsor-defined codelist.
Study level:
check_codelist_references() checks that every codelist in a
mighty_study() is referenced by at least one column (codelist field),
including columns in parameters. It returns study invisibly or errors.
The check is not run automatically, so codelists can be added before
they are used by any column.
mighty_codelists(): an object of class mighty_codelists.
list_codelists(): character() vector with codelist ids.
select_codelist(): selected codelist entry as a list.
All other functions: the modified object.
cl <- mighty_codelists( .data = list( list( id = "REGION", label = "Region", description = "Geographical regions", datatype = "text", values = list(list(code = "EUROPE", decode = "Europe")) ), list( id = "AGEU", subset = list(list(code = "YEARS")), restore = list(list(code = "MONTHS")) ) ) ) print(cl) cl <- mighty_codelists() |> add_codelist( id = "REGION", label = "Region", description = "Geographical regions used in the study", datatype = "text", code = c("EUROPE", "NORTH AMERICA"), decode = c("Europe", "North America") ) |> subset_codelist_values(id = "AGEU", code = c("MONTHS", "YEARS")) |> restore_codelist_values(id = "AGEU", code = "DAYS") |> extend_codelist_values( id = "LOC", code = "MY CUSTOM LOCATION", decode = "My Custom Location" ) list_codelists(cl) select_codelist(cl, id = "AGEU") cl <- cl |> update_codelist(id = "REGION", description = "Regions used in the trial") |> update_codelist_value(id = "REGION", code = "EUROPE", decode = "EU") |> move_codelist_value(id = "AGEU", code = "YEARS", .pos = 1) |> remove_codelist_value(id = "AGEU", code = "MONTHS") |> remove_codelist(id = "LOC") # Check that all codelists in a study are referenced by a column study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) |> extend_codelist_values("UNUSED", code = "A") try(check_codelist_references(study))cl <- mighty_codelists( .data = list( list( id = "REGION", label = "Region", description = "Geographical regions", datatype = "text", values = list(list(code = "EUROPE", decode = "Europe")) ), list( id = "AGEU", subset = list(list(code = "YEARS")), restore = list(list(code = "MONTHS")) ) ) ) print(cl) cl <- mighty_codelists() |> add_codelist( id = "REGION", label = "Region", description = "Geographical regions used in the study", datatype = "text", code = c("EUROPE", "NORTH AMERICA"), decode = c("Europe", "North America") ) |> subset_codelist_values(id = "AGEU", code = c("MONTHS", "YEARS")) |> restore_codelist_values(id = "AGEU", code = "DAYS") |> extend_codelist_values( id = "LOC", code = "MY CUSTOM LOCATION", decode = "My Custom Location" ) list_codelists(cl) select_codelist(cl, id = "AGEU") cl <- cl |> update_codelist(id = "REGION", description = "Regions used in the trial") |> update_codelist_value(id = "REGION", code = "EUROPE", decode = "EU") |> move_codelist_value(id = "AGEU", code = "YEARS", .pos = 1) |> remove_codelist_value(id = "AGEU", code = "MONTHS") |> remove_codelist(id = "LOC") # Check that all codelists in a study are referenced by a column study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) |> extend_codelist_values("UNUSED", code = "A") try(check_codelist_references(study))
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 all four metadata
data sets at once, as a convenience wrapper around create_md_table(),
create_md_col(), create_md_param() and create_md_values().
create_md(x)create_md(x)
x |
A mighty_study or mighty_domain object. |
A named list of tibbles:
Table definitions, see create_md_table()
Column definitions, see create_md_col()
BDS parameter definitions, see create_md_param()
Value level definitions, see create_md_values()
mighty_study, create_md_table(), create_md_col(),
create_md_param(), create_md_values()
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md(study)study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md(study)
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(),
create_md(), create_md_table(), create_md_param(),
create_md_values()
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md_col(study)study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md_col(study)
Converts a mighty_study or mighty_domain object into a flat dataframe of BDS parameter definitions.
Only the parameters themselves are returned. Use create_md_values() to
get the column definitions nested inside each parameter.
create_md_param(x)create_md_param(x)
x |
A mighty_study or mighty_domain object. |
A tibble with one row per parameter containing:
Table identifier
Table label/description
Parameter order within table
Parameter code (PARAMCD)
Parameter label (PARAM)
mighty_study, create_md(), create_md_table(),
create_md_col(), create_md_values()
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md_param(study)study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md_param(study)
Converts a mighty_study or mighty_domain object into a flat dataframe of table (dataset) definitions.
create_md_table(x)create_md_table(x)
x |
A mighty_study or mighty_domain object. |
A tibble with one row per table containing:
Table order within the study, NA for a single domain
Table identifier
Table label/description
CDISC class of the dataset
CDISC subclass of the dataset
Description of the structure of the dataset
List column of key variables
Comment
mighty_study, create_md(), create_md_col(),
create_md_param(), create_md_values()
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md_table(study)study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md_table(study)
Converts a mighty_study or mighty_domain object into a flat dataframe of value level definitions, i.e. the columns defined inside each BDS parameter.
Parameters without any columns entry contribute no rows. Use
create_md_param() for the full list of parameters.
create_md_values(x)create_md_values(x)
x |
A mighty_study or mighty_domain object. |
A tibble with one row per parameter column containing:
Table identifier
Table label/description
Parameter order within table
Parameter code (PARAMCD)
Parameter label (PARAM)
Column order within parameter
Column name
Column label
Origin type (e.g., "Predecessor", "Derived")
Derivation method
Codelist reference
Data type
Maximum length
Display format
Comment
mighty_study, create_md(), create_md_table(),
create_md_col(), create_md_param()
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md_values(study)study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) create_md_values(study)
mighty_documents() creates an S7 object for storing document metadata.
The class inherits from S7::class_list and represents the contents of
_documents.yml as a list of document entries.
The object is validated on creation and when validate() is called.
Validation includes:
schema compliance with inst/schema/documents.json,
uniqueness of document identifiers (id).
Writing to YAML is done via write_config() on a mighty_study() object,
where documents are saved to _documents.yml.
Functions to list, select, remove, add, and update documents in
your mighty_documents() object (or through mighty_study@documents).
mighty_documents(file, .data) list_documents(x) select_document(x, id) remove_documents(x, id) add_document( x, id, title, doctype, href, .pos = length(list_documents(x)) + 1L ) update_document(x, id, ...)mighty_documents(file, .data) list_documents(x) select_document(x, id) remove_documents(x, id) add_document( x, id, title, doctype, href, .pos = length(list_documents(x)) + 1L ) update_document(x, id, ...)
file |
|
.data |
|
x |
A |
id |
|
title |
|
doctype |
|
href |
|
.pos |
|
... |
Additional document properties to update. |
An object of class mighty_documents.
list_documents(): character() vector with document ids.
select_document(): selected document entry as a list.
add_document(), update_document(), remove_documents(): modified object (invisible(x)).
docs <- mighty_documents( .data = list( list( id = "DOC001", title = "Statistical Analysis Plan", doctype = "suppdoc", href = "./docs/sap.pdf" ) ) ) # Custom print method gives a small overview print(docs) # Write _documents.yml through mighty_study study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) study@documents <- docs # Load study config s <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # Add a document s <- s |> add_document( id = "SAP", title = "Statistical Analysis Plan", doctype = "suppdoc", href = "./docs/sap.pdf" ) # List and select documents list_documents(s) select_document(s, id = "SAP") # Update existing document s <- s |> update_document( id = "SAP", title = "Statistical Analysis Plan v2" ) # Remove one or more documents s <- s |> remove_documents(id = "SAP") # Work directly on mighty_documents docs <- mighty_documents() docs <- docs |> add_document( id = "CSR", title = "Clinical Study Report", doctype = "suppdoc", href = "./docs/csr.pdf" ) list_documents(docs)docs <- mighty_documents( .data = list( list( id = "DOC001", title = "Statistical Analysis Plan", doctype = "suppdoc", href = "./docs/sap.pdf" ) ) ) # Custom print method gives a small overview print(docs) # Write _documents.yml through mighty_study study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) study@documents <- docs # Load study config s <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # Add a document s <- s |> add_document( id = "SAP", title = "Statistical Analysis Plan", doctype = "suppdoc", href = "./docs/sap.pdf" ) # List and select documents list_documents(s) select_document(s, id = "SAP") # Update existing document s <- s |> update_document( id = "SAP", title = "Statistical Analysis Plan v2" ) # Remove one or more documents s <- s |> remove_documents(id = "SAP") # Work directly on mighty_documents docs <- mighty_documents() docs <- docs |> add_document( id = "CSR", title = "Clinical Study Report", doctype = "suppdoc", href = "./docs/csr.pdf" ) list_documents(docs)
Returns a mighty_study object containing only domains whose names start
with the given prefix(es).
filter_domains(x, prefix = "AD")filter_domains(x, prefix = "AD")
x |
|
prefix |
|
A mighty_study object.
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # Keep only ADaM domains (default) study |> filter_domains()study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # Keep only ADaM domains (default) study |> filter_domains()
mighty_config() provides a robust way of working with the _mighty.yml
configuration file in the {mighty} framework.
A new object is initialized by supplying either the path to a _mighty.yml
file or an in-memory list of the same content. Both are automatically
validated against the mighty.json schema.
mighty_config() inherits from S7schema::S7schema(). You can validate
an object at any time by calling validate() and use write_config() to
save it back as a yaml file.
mighty_config(file, .data)mighty_config(file, .data)
file |
|
.data |
|
The _mighty.yml file is validated against the mighty.json schema on
load. The file must contain an external_data array declaring the primary
keys of any datasets external to the ADaM study (e.g. SDTM or reference
datasets) that ADaM domain specifications may depend on.
The required repos field specifies where mighty.component should look
for shared components. Each entry is either a local path (e.g. ".") or a
GitHub reference in owner/repo/subdir@ref format (e.g.
"NovoNordisk-OpenSource/mighty.standards/components@main").
A mighty_config S7 object extending S7schema::S7schema.
external_dataA list of external data source specifications,
each with an id and keys field.
reposA character vector of component repository locations.
Use write_config() to serialize a mighty_config() object back to a
_mighty.yml file. Supply path to write to a specific file; defaults to
the file the object was loaded from.
mighty_study, study_config, mighty_domain, write_config()
x <- mighty_config( file = system.file("examples", "_mighty.yml", package = "mighty.metadata") ) # Custom print method gives a small overview print(x) # Underlying object is a `list` str(x) # Write back to a file tmp <- tempfile(fileext = ".yml") write_config(x, path = tmp) # Or build one in memory mighty_config( .data = list( external_data = list(list(id = "DM", keys = "USUBJID")), repos = "." ) )x <- mighty_config( file = system.file("examples", "_mighty.yml", package = "mighty.metadata") ) # Custom print method gives a small overview print(x) # Underlying object is a `list` str(x) # Write back to a file tmp <- tempfile(fileext = ".yml") write_config(x, path = tmp) # Or build one in memory mighty_config( .data = list( external_data = list(list(id = "DM", keys = "USUBJID")), repos = "." ) )
mighty_domain() provides a robust way of working with ADaM metadata
in the {mighty} framework.
A new object is initialized by supplying either an existing yaml metadata
file or an in-memory list of the same content.
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, .data)mighty_domain(file, .data)
file |
|
.data |
|
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) # Or build one in memory mighty_domain( .data = list( id = "ADVS", label = "Vital Signs Analysis Dataset", class = "BASIC DATA STRUCTURE", structure = "One record per parameter, per visit, per subject", keys = c("USUBJID", "PARAMCD"), columns = list( list(id = "USUBJID", label = "Unique Subject Identifier") ) ) )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) # Or build one in memory mighty_domain( .data = list( id = "ADVS", label = "Vital Signs Analysis Dataset", class = "BASIC DATA STRUCTURE", structure = "One record per parameter, per visit, per subject", keys = c("USUBJID", "PARAMCD"), columns = list( list(id = "USUBJID", label = "Unique Subject Identifier") ) ) )
Creates a mighty_study object by loading all YAML metadata files from a
directory. Each YAML file (except _mighty.yml, _study.yml, _documents.yml
and _codelists.yml) is parsed as a mighty_domain object. The optional
_study.yml file provides study-level properties, the optional _mighty.yml
file provides mighty framework configuration, the optional _documents.yml
provides study-level documents metadata, and the optional _codelists.yml
provides study-level codelists metadata.
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
File named _documents.yml is treated as study documents metadata
File named _codelists.yml is treated as study codelists metadata
All other YAML files must follow ADaM naming conventions (starting with
ad or md) and are loaded as mighty_domain objects
Only one _mighty.yml, one _study.yml, one _documents.yml and one
_codelists.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.
@studyA study_config object loaded from _study.yml, or
NULL if no properties file exists.
@mightyA mighty_config object loaded from _mighty.yml, or
NULL if no configuration file exists.
@documentsStudy-level document metadata from _documents.yml,
or an empty mighty_documents if no documents file exists.
@codelistsA mighty_codelists object loaded from
_codelists.yml, or an empty mighty_codelists if no codelists 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 @mighty and @study are not NULL, and
_documents.yml and _codelists.yml when @documents and @codelists
are not empty. If path is NULL, files are written to x@path.
mighty_domain, mighty_config, study_config,
write_config(), populate_sparse(), populate_core(),
create_md_table(), create_md_col(), create_md_param(),
create_md_values()
# 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 # Access study-level documents metadata study@documents # 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 # Access study-level documents metadata study@documents # 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()
Rewrites row actions that carry a subset field into equivalent component
actions that operate on a filtered subset of the source domain. The subset
field is removed after resolution.
resolve_subsets(x)resolve_subsets(x)
x |
A mighty_study or mighty_domain object. |
The row's component.with.domain is rewritten to
.mighty_subset(<domain>, "<subset>"), a marker call that
mighty.component::mighty_component$render() recognizes and expands into
code that applies the action only to rows matching the R expression given
in subset. A component with a with.domain entry is required.
The input object with row subsets resolved.
study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # Add a row action restricted to a subset of source rows study$ADAE <- add_row( study$ADAE, id = "TRTEMFL_STUDY1", component = list( id = "STUDY1_COMPONENT", with = list(domain = "ADAE") ), subset = "STUDYID == 'STUDY1'" ) # `subset` is folded into `component.with.domain` as a `.mighty_subset()` marker call study |> resolve_subsets() |> getElement("ADAE") |> select_row("TRTEMFL_STUDY1") |> str()study <- mighty_study( path = system.file("examples", package = "mighty.metadata") ) # Add a row action restricted to a subset of source rows study$ADAE <- add_row( study$ADAE, id = "TRTEMFL_STUDY1", component = list( id = "STUDY1_COMPONENT", with = list(domain = "ADAE") ), subset = "STUDYID == 'STUDY1'" ) # `subset` is folded into `component.with.domain` as a `.mighty_subset()` marker call study |> resolve_subsets() |> getElement("ADAE") |> select_row("TRTEMFL_STUDY1") |> str()
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()
study_config() provides a robust way of working with the _study.yml
configuration file in the {mighty} framework.
A new object is initialized by supplying either the path to a _study.yml
file or an in-memory list of the same content. Both are automatically
validated against the study.json schema.
study_config() inherits from S7schema::S7schema(). You can validate
an object at any time by calling validate() and use write_config() to
save it back as a yaml file.
study_config(file, .data)study_config(file, .data)
file |
|
.data |
|
The _study.yml file is validated against the study.json schema on load.
The file must contain a study_id field. Additional study-level properties
are allowed and are kept as-is.
The optional standards and terminology fields describe the standards and
controlled terminologies applied in the study; see
vignette("study-schema").
Study-level properties are used by resolve_includes() to evaluate the
include conditions of domains, columns, parameters, and rows.
A study_config S7 object extending S7schema::S7schema.
study_idUnique identifier of the study.
study_descriptionOptional description of the study.
standardsOptional list of standards, each with id and
version.
terminologyOptional list of controlled terminologies, each with
id and version.
Use write_config() to serialize a study_config() object back to a
_study.yml file. Supply path to write to a specific file; defaults to
the file the object was loaded from.
mighty_study, mighty_config, mighty_domain, write_config()
x <- study_config( file = system.file("examples", "_study.yml", package = "mighty.metadata") ) # Custom print method gives a small overview print(x) # Underlying object is a `list` str(x) # Write back to a file tmp <- tempfile(fileext = ".yml") write_config(x, path = tmp) # Or build one in memory study_config( .data = list(study_id = "example_study", study_description = "A study") )x <- study_config( file = system.file("examples", "_study.yml", package = "mighty.metadata") ) # Custom print method gives a small overview print(x) # Underlying object is a `list` str(x) # Write back to a file tmp <- tempfile(fileext = ".yml") write_config(x, path = tmp) # Or build one in memory study_config( .data = list(study_id = "example_study", study_description = "A study") )
Serializes mighty_config, study_config, and mighty_study objects back
to YAML files. mighty_config and study_config inherit the
S7schema::write_config() method of their parent class; mighty_study adds
a method that writes every domain plus _mighty.yml and _study.yml.
write_config(x, path = NULL) ## S7 method for class <mighty.metadata::mighty_study> write_config(x, path = NULL)write_config(x, path = NULL) ## S7 method for class <mighty.metadata::mighty_study> write_config(x, path = NULL)
x |
A mighty_config, study_config, or mighty_study object. |
path |
Destination to write to. A file for mighty_config and
study_config, a directory for mighty_study. If |
Invisibly returns x.
mighty_config, study_config, mighty_study