Skip to contents

Creates a mighty_study object by loading all YAML metadata files from a directory. Each YAML file (except _mighty.yml,_study.yml and _documents.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, and optional _documents.yml provides study-level documents metadata.

Usage

mighty_study(path, populate = FALSE)

Arguments

path

character(1) path to a directory containing YAML metadata files.

populate

logical(1) if TRUE, calls populate_core() then populate_sparse() before returning. Default is FALSE.

Value

A mighty_study S7 object extending list:

List elements

mighty_domain objects, named by their id field. Access via e.g. study$adsl.

@study

A study_config object loaded from _study.yml, or NULL if no properties file exists.

@mighty

A mighty_config object loaded from _mighty.yml, or NULL if no configuration file exists.

@documents

Study-level document metadata from _documents.yml, or an empty mighty_documents if no documents file exists.

@path

The source directory path as character(1).

Details

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

  • 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 and one _documents.yml file 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. If path is NULL, files are written to x@path.

Examples

# Load example study
study <- mighty_study(
  path = system.file("examples", package = "mighty.metadata")
)
#> → No `_documents.yml` file found

# 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: 0 entries
#> IDs:

# Load and populate in one step
study <- mighty_study(
  path = system.file("examples", package = "mighty.metadata"),
  populate = TRUE
)
#> → No `_documents.yml` file found

# Write study back to YAML
tmp <- tempdir()
write_config(study, path = tmp)