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.
Arguments
- path
character(1)path to a directory containing YAML metadata files.- populate
logical(1)ifTRUE, callspopulate_core()thenpopulate_sparse()before returning. Default isFALSE.
Value
A mighty_study S7 object extending list:
- List elements
mighty_domain objects, named by their
idfield. Access via e.g.study$adsl.@studyA study_config object loaded from
_study.yml, orNULLif no properties file exists.@mightyA mighty_config object loaded from
_mighty.yml, orNULLif no configuration file exists.@documentsStudy-level document metadata from
_documents.yml, or an emptymighty_documentsif no documents file exists.@codelistsA mighty_codelists object loaded from
_codelists.yml, or an emptymighty_codelistsif no codelists file exists.@pathThe source directory path as
character(1).
Details
The function scans the directory for files matching *.yaml or *.yml:
Files named
_study.ymlor_study.yamlare treated as study propertiesFiles named
_mighty.ymlor_mighty.yamlare treated as mighty framework configFile named
_documents.ymlis treated as study documents metadataFile named
_codelists.ymlis treated as study codelists metadataAll other YAML files must follow ADaM naming conventions (starting with
adormd) and are loaded as mighty_domain objectsOnly one
_mighty.yml, one_study.yml, one_documents.ymland one_codelists.ymlfile is allowed per directory
Write Study Metadata
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.
Examples
# Load example study
study <- mighty_study(
path = system.file("examples", package = "mighty.metadata")
)
# List tables with metadata
names(study)
#> [1] "ADAE" "ADSL" "ADVS"
# Access ADVS
study$ADVS
#> <mighty.metadata::mighty_domain>
#> ADVS: Vital Signs Analysis Dataset
#> Class: BASIC DATA STRUCTURE
#> Keys: USUBJID, PARAMCD, and AVISITN
# Access study-level properties
study@study
#> <mighty.metadata::study_config>
#> Study ID: example_study
#> Fields: `study_id`, `standards`, and `terminology`
# Access mighty framework configuration
study@mighty
#> <mighty.metadata::mighty_config>
#> External data: 3 sources (`DM`, `VS`, and `AE`)
#> Repos: 2 (`NovoNordisk-OpenSource/mighty.standards/components@main` and `.`)
# Access study-level documents metadata
study@documents
#> <mighty.metadata::mighty_documents>
#> Documents: 2 entries
#> IDs: `SAP` and `DERIV_METHODS`
# 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)
