Extracts comprehensive metadata about a Monte Carlo module, including:
Module composition (raw vs combined modules)
Input data per expression
Keys for each variate (data row)
Global data keys
Value
A list with six elements:
- is_combined
Logical. TRUE if module is combined, FALSE if raw
- n_modules
Integer. Number of component modules (1 for raw, >1 for combined)
- module_names
Character vector. Names of all component modules (recursive)
- module_exp_data
Data frame with module and expression information, including data_name
- data_keys
Data frame with keys for each variate, including variate number and data_name
- global_keys
Character vector of global key names used across the module
Details
A raw module has a single expression in mcmodule$exp.
A combined module has multiple expressions in mcmodule$exp, each
representing a component module that was combined via combine_modules().
For combined modules, module names are recursively extracted up to one level deep. This allows identifying all base modules even in deeply nested combinations.
Examples
# Get comprehensive module information
info <- mcmodule_info(imports_mcmodule)
str(info)
#> List of 6
#> $ is_combined : logi FALSE
#> $ n_modules : int 1
#> $ module_names : chr "imports_mcmodule"
#> $ module_exp_data:'data.frame': 1 obs. of 3 variables:
#> ..$ module : chr "imports_mcmodule"
#> ..$ exp : chr "imports"
#> ..$ data_name: chr "imports_data"
#> $ data_keys :'data.frame': 6 obs. of 4 variables:
#> ..$ pathogen : chr [1:6] "a" "a" "a" "b" ...
#> ..$ origin : chr [1:6] "nord" "south" "east" "nord" ...
#> ..$ variate : int [1:6] 1 2 3 4 5 6
#> ..$ data_name: chr [1:6] "imports_data" "imports_data" "imports_data" "imports_data" ...
#> $ global_keys : chr [1:2] "pathogen" "origin"
# Access composition information
info$is_combined
#> [1] FALSE
info$n_modules
#> [1] 1
info$module_names
#> [1] "imports_mcmodule"
# Access index information
head(info$module_exp_data)
#> module exp data_name
#> 1 imports_mcmodule imports imports_data
head(info$data_keys)
#> pathogen origin variate data_name
#> 1 a nord 1 imports_data
#> 2 a south 2 imports_data
#> 3 a east 3 imports_data
#> 4 b nord 4 imports_data
#> 5 b south 5 imports_data
#> 6 b east 6 imports_data
info$global_keys
#> [1] "pathogen" "origin"
