#> → No `_documents.yml` file found
#> → No `_codelists.yml` file found
#> Error:
#> ! Specification validation errors found:
#>
#> [Overlapping component outputs]
#> ℹ ADLB - 'dtc_to_dt.mustache': ASTDT and ASTDTF would be derived with different
#> parameter values
#>
#> Suggestions:
#> • Ensure each use of the same component produces different output columns
#> • Use distinct @outputs (via template parameters) for each set of parameter
#> values
Overview
The specification format is defined by the mighty.metadata package, which also checks each file before mighty reads it. This article covers the fields mighty uses. Other fields are ignored by mighty.
General structure
Each ADaM domain is defined in its own YAML file with these main sections:
- Domain identifier - The ADaM domain name
- Primary keys - Unique identifiers for the dataset
- Label - Label of the ADaM dataset
- Class - CDISC class of the dataset
- Structure - Text description of the structure of the dataset
- Population - How to build the base table from SDTM domains
- Columns - Which columns to include and how to create them
- Rows - Operations that add, modify, or delete rows
- Parameters (BDS only) - Parameter-level derivations
Here is a complete specification, from the Get started example:
---
id: ADSL
label: Subject Level Analysis Dataset
class: SUBJECT LEVEL ANALYSIS DATASET
structure: One record per subject
keys: [USUBJID, STUDYID]
population:
base:
- domain: DM
depends:
- AGE
filter: "!is.na(AGE)"
global:
- filter: NA
depends:
- NA
columns:
- id: USUBJID
- id: STUDYID
- id: ARM
- id: PLANNED_ARM
method: ADSL.ARM
- id: AGE
- id: AGE_GRP1
component:
id: "age_group_01.R"Domain identifier
The domain identifier is specified at the top level of the YAML file.
A domain is one dataset (see Key terms).
Required Field
| Field | Description | Example |
|---|---|---|
id |
Name of the ADaM domain | ADLB |
Example
id: ADLBPrimary keys
Define the primary key variables that uniquely identify each row in your ADaM dataset.
Required Field
| Field | Description | Example |
|---|---|---|
keys |
Array of variable names forming the primary key | [USUBJID, PARAMCD] |
Example
keys: [USUBJID, PARAMCD, AVISIT]Label
A descriptive label for the ADaM domain.
Required Field
| Field | Description | Example |
|---|---|---|
label |
Human-readable domain description | Laboratory Analysis Dataset |
Example
label: Laboratory Analysis DatasetClass
The ADaM dataset class according to ADaM standards.
Required Field
| Field | Description | Example |
|---|---|---|
class |
ADaM class of the dataset | BASIC DATA STRUCTURE |
Common values
-
SUBJECT LEVEL ANALYSIS DATASET- For ADSL -
BASIC DATA STRUCTURE- For BDS datasets (ADLB, ADVS, etc.) -
OCCURRENCE DATA STRUCTURE- For OCCDS datasets (ADAE, ADCM, etc.)
Example
class: BASIC DATA STRUCTUREStructure
A description of the dataset structure that specifies the grain/level of the data.
Required Field
| Field | Description | Example |
|---|---|---|
structure |
Description of dataset granularity | One record per subject per parameter per analysis visit |
Example
structure: One record per subject per parameter per analysis visitPopulation
This section defines how to create the base population for your ADaM table from source SDTM domains and apply filters.
Structure
The population is built in two steps. First, mighty reads each domain listed under base, applies that domain’s own filter, and stacks the results into one dataset. Then the filters under global are applied to every row of that stacked dataset. A global filter can also use a column from a domain that isn’t in base. For example, when you build ADLB from LB, you can remove screen failures by filtering on ARMNRS (Reason Arm and/or Actual Arm is Null) from ADSL. To do this, list the column in depends with a domain prefix (ADSL.ARMNRS). mighty joins ADSL to the LB data first, then applies the filter.
The population section has two subsections:
| Field | Description |
|---|---|
base |
Required. Array of base SDTM domains with domain-specific filters |
global |
Optional. Array of filters applied to the combined dataset |
Filter execution order
Understanding when filters are applied is essential for writing correct specifications. The generated program filters in this order:
- Read data: the base domains, and any domains the filters use, are read.
- Combine: the base domains are stacked into one dataset.
-
Join: if a filter uses columns from another domain (e.g.
ADSL.SEX), that domain is joined by its keys. -
Apply domain-specific filters: each
base.filterremoves rows only from its own domain (tracked with a temporarySRC_column). -
Apply global filters: all
global.filterexpressions are applied together; a row must meet all of them. - Keep needed columns: columns the program doesn’t need are dropped.
- Continue with derivations: column and row operations proceed.
Domain-specific filters allow different inclusion criteria for different source domains, while global filters apply uniform criteria across the combined dataset.
Base domains
Each entry in the base array specifies a source domain:
| Field | Description | Notes |
|---|---|---|
domain |
SDTM domain name | Uppercase (e.g. LB) |
depends |
Columns needed for filtering this domain | Use NA for no dependency |
filter |
Filter specification. Must be an R expression that can be evaluated | Can be NA
|
mighty does not read the filter expression itself, so depends must list every column the filter uses. mighty uses this list to make those columns available in the generated program before the filter runs. Columns from another domain use a domain prefix (e.g. ADSL.ARMNRS), and mighty joins that domain first.
Domain-specific filtering
Domain-specific filters allow you to apply different inclusion criteria to different source domains before they are combined.
A domain’s filter only removes rows that came from that domain; rows from the other base domains are not affected. Each base domain has one filter string. To combine conditions, use & inside it. In the generated program you will see a temporary SRC_ column used for this; mighty adds and removes it automatically (see Internal components).
This is useful when:
- Different domains need different inclusion criteria
- You want to exclude specific records from one domain but keep all records from another
- Filtering logic depends on the source domain
Global filters
Global filters are applied after row-binding and domain-specific filtering.
| Field | Description | Notes |
|---|---|---|
depends |
Array of columns needed for global filtering | Include domain prefix (e.g., ADSL.SAFFL) when referencing a column of another domain. A column name without a prefix is a column of the ADaM domain being built |
filter |
Filter specification. Must be an R expression that can be evaluated | Applied to combined dataset. |
Using external domains in global filters
Global filters can reference columns from external ADaM or SDTM domains by:
- Listing required columns in
global.dependswith domain prefix (e.g.,ADSL.SAFFL) - Writing filter expressions that reference the columns without the prefix (e.g.,
SAFFL == "Y")
mighty joins the domain in automatically, using that domain’s keys: from its specification (keys:) if mighty builds it, such as ADSL, otherwise from external_data in _mighty.yml. The joined columns are used for the filter and dropped after it.
A column joined for a filter (global or base) can’t have the same name as a column the ADaM domain already has when the filter runs. These are the columns copied from the base domains, and the columns built by components that the filter needs. The same column name also can’t be joined from two other domains. The other domain’s primary keys are the exception. mighty stops with a validation error otherwise.
For example, a filter on SV.VISIT can’t be combined with a VISIT column copied from LB. Either copy VISIT from SV with method: SV.VISIT, or filter on the ADaM domain’s own VISIT by writing it without the prefix. LB’s and SV’s VISIT can hold different values, so check which one you mean.
Simple example
population:
base:
- domain: LB
filter: NA
depends: NAComplex example
population:
base:
- domain: LB
filter: NA
depends: NA
- domain: XL
filter: 'grepl("_CONV", TOPICCD)'
depends:
- TOPICCD
global:
- filter: 'LBCAT != "ANTIBODIES"'
depends:
- LBCAT
- filter: '!ARMNRS %in% c("SCREEN FAILURE")'
depends:
- ADSL.ARMNRSKey Points
- Multiple base domains are row-bound together
- Base filters apply to specific domains before combining
- Global filters apply to the combined dataset
- Column dependencies must include domain prefixes when from external domains (e.g.,
ADSL.ARMNRS)
Columns
Define which columns to include in your ADaM dataset and how to create them.
Column operations cannot modify the number of rows in the ADaM table. To modify rows, use the rows section (see below).
The columns section is an array where each element defines one or more columns.
Fields
Each column specification uses different fields depending on how the column is created:
| Field | Description | Notes |
|---|---|---|
id |
Name of the column in the final dataset | Required |
method |
Source location for simple operations, or a derivation description when component is set |
See The method field
|
component |
Component definition for derivations | Object with id and optional with
|
depends |
IDs of row or parameter operations that must complete first | Array of strings (e.g., rows.BASELINE_FLAG, parameters.BMI) |
The method field
method has two roles, which depend on whether the column also has a component:
-
Without
component:methodis the source of the column. It must be domain-qualified (e.g.,ADSL.SAFFL). mighty uses it to resolve the dependency. The column is also recorded as a copy of that source (origin “Predecessor”), so it inherits the source’s label and other metadata for define.xml. -
With
component: the component derives the column and supplies its dependencies.methodis free text that describes the derivation, for use in define.xml. mighty does not use it for dependency resolution.
columns:
- id: COMPLSFL
method: Completer flag derived per protocol section 4.2
component:
id: der_complsfl.RComponent object
When using component, it has these subfields:
| Field | Description | Notes |
|---|---|---|
id |
Component file name, with or without extension | Required |
with |
Parameters to pass to the component | Object of key-value pairs |
Examples
Simple column operations
Note: method used on columns with no component field always needs a domain prefix.
All examples below are from a fictional ADLB specification (id: ADLB), whose base domain is LB. ADLB is built from LB, so LB’s columns are already in ADLB. The domain prefix in method: decides where a column comes from:
| You write | Source | What mighty does | Examples |
|---|---|---|---|
- id: USUBJID (no method) |
Base domain (LB) | Keeps the column | 1 |
method: ADSL.SAFFL |
A different domain | Joins the column in, matching on that domain’s keys | 2, 3 |
method: ADLB.LBSTRESN |
The domain being built | No join; copies or renames the column already in ADLB | 4, 5 |
-
Adding a column from the base domain:
id: ADLB columns: - id: USUBJIDRetains the
USUBJIDvariable from your baseSDTMdomain (e.g.,LB.USUBJID). -
Adding a column from another ADaM domain
id: ADLB columns: - id: SAFFL method: ADSL.SAFFLJoins
SAFFLfrom ADSL onto ADLB, matching rows on ADSL’s keys (itskeys:). Those key columns must also be in ADLB. -
Adding a column from another ADaM domain and renaming it
id: ADLB columns: - id: ARM method: ADSL.PLANNED_ARMJoins
PLANNED_ARMfromADSLand renames it asARMin your table. -
Copying a column from the base domain with a new name
id: ADLB columns: - id: LBSTRESN - id: AVAL method: ADLB.LBSTRESN
Creates a new column AVAL with a copy of LBSTRESN. Because LBSTRESN is also listed under columns:, the dataset keeps both columns. If you do not list LBSTRESN, it is renamed instead (see example 5).
-
Renaming a column from the base domain
id: ADLB columns: - id: AVAL method: LB.LBSTRESNRenames
LBSTRESNfrom the base domain toAVAL. Unlike copying (example 4), the source columnLBSTRESNis not listed separately incolumns, so only the renamed columnAVALappears in the final dataset.
With one base domain, mighty treats LB.LBSTRESN as the column already in ADLB, so it works the same as ADLB.LBSTRESN. With more than one base domain (e.g. LB and XL), LB.LBSTRESN makes mighty join LB again on LB’s keys, and those keys must be in ADLB. To use the column already in ADLB, write ADLB.LBSTRESN.
Derived columns
Derived columns use code components to perform data transformations. A code component can be:
- Standard code component (Mustache template)
- Custom component (plain R script)
- Custom component (Mustache template)
The component id is a file name. mighty looks for it in the locations listed under repos in _mighty.yml, in order, and uses the first match. With an extension (arm_group_01.R), mighty looks for exactly that file; without one (arm_group_01), it looks for arm_group_01.mustache or arm_group_01.R. A .R file is plain R code; a .mustache file is a template whose placeholders are filled from with: (see example 10).
Examples (continued):
-
Adding a derived column using a component without any parameters
columns: - id: ARM_GRP1 component: id: arm_group_01Creates
ARM_GRP1using the code componentarm_group_01. The component’s metadata defines which columns it depends on. -
Adding a derived column using an
.Rcomponentcolumns: - id: ARM_GRP1 component: id: arm_group_01.R -
Adding a derived column using a Mustache template component
columns: - id: ARM_GRP1 component: id: arm_group_01.mustacheMustache template components allow parameterization (see example 10).
-
Adding multiple derived columns with a single code component
columns: - id: NEWFL01 component: id: newfl_01 - id: NEWREA01 component: id: newfl_01Adds both
NEWFL01andNEWREA01columns by calling the code componentnewfl_01. The component must be designed to output both variables. -
Adding a derived column using a parameterized code component
columns: - id: AGE_GRP1 component: id: age_group_01 with: cut_points: c(20, 45)Creates
AGE_GRP1usingage_group_01code component with custom parameters. Parameters can only be passed to Mustache templates, not to plain R script components. -
Adding multiple derived columns with a single, parameterized code component
columns: - id: A component: id: fn_AB with: param_1: 100 param_2: "This is a regular string" param_3: min(1, 100) - id: B component: id: fn_AB with: param_1: 100 param_2: "This is a regular string" param_3: min(1, 100)Adds columns
AandBusing the same parameterized code componentfn_AB. When one code component creates multiple columns, all columns must use identical parameter values. -
Adding a derived column that has a row dependency
columns: - id: BASETYPE component: id: basetype_derivation depends: - rows.BASELINE_FLAGCreates
BASETYPEusingbasetype_derivationcode component, but only after the row operationBASELINE_FLAGcompletes. Note therows.prefix for row dependencies.
Summary of column rules
- A single component can produce multiple columns in the ADaM dataset. All columns generated by that component must have an entry under
columns:. The number of columns a component produces is determined by the component’s code, not by the ADaM specification. - All parameters expected by the component need to be specified in the
withsection of the component specification. - Dependencies must use appropriate prefixes:
rows.for row operations (e.g.,rows.BASELINE_IMPUTATION) orparameters.for parameter-level operations in BDS datasets (e.g.,parameters.BMI).
Component reuse rules
Components can appear more than once in a domain’s columns section. There are two distinct scenarios.
One component, multiple output columns
A component with multiple @outputs appears under several column entries in the YAML. Because mighty calls the component once, all entries must use identical with: values. See examples 9 and 11 above for this pattern.
Same component, different parameters
The same mustache component can be invoked multiple times with different parameter values to produce different output columns. mighty calls the component once per unique parameter set. This is valid as long as each invocation produces disjoint output columns — no two invocations may share an output column.
Overlapping outputs cause an error
When two invocations with different parameters produce overlapping output columns, the derivation is ambiguous and mighty raises an error.
Consider a component that derives both a date and its imputation flag — it produces two output columns from one invocation:
If the same component is used twice with different parameters but both uses produce the same output columns, mighty cannot tell which parameter values should be used:
columns:
- id: USUBJID
- id: ASTDT
component:
id: dtc_to_dt.mustache
with:
dtc_var: LBDTC
dt_var: ASTDT
dtf_var: ASTDTF
- id: ASTDTF
component:
id: dtc_to_dt.mustache
with:
dtc_var: LBENDTC
dt_var: ASTDT
dtf_var: ASTDTFmighty will abort with an error:
The fix is to ensure that each invocation of the component (that is, with different parameters) produces a distinct set of output columns.
Cross-domain reuse
Cross-domain reuse is not affected by these rules. The same component can appear in different domains with different parameters even if the output column names overlap, because each domain is independent.
No intermediate columns
The YAML specification describes only columns that appear in the final ADaM dataset and in the define.xml. There is no mechanism to declare intermediate or temporary variables — columns used during derivation but excluded from the final output. This affects two situations:
Source columns not in the final dataset. A component may need a column from a source domain that does not belong in the output (e.g., LBDTC for deriving ADT). Declare these as @depends in the component’s metadata header. mighty ensures the column is read and available at execution time without it appearing in the specification. See Source columns not in the final dataset for details.
Intermediate derived values shared across final columns. In traditional ADaM programming, a temporary column might be calculated once, used by several downstream derivations, and then dropped. mighty does not support this pattern — there is no way to declare a column that exists only during execution. Instead, either group the final columns that share the intermediate calculation into a single component (using multiple @outputs), or recalculate the intermediate value within each component that needs it. Recalculating intermediate values across multiple components may reduce computational efficiency, but this is not a primary concern. The paramount goal of ADaM programs is clarity and transparency for regulatory review. Therefore, group derivations into shared components only when it improves the logical flow and understanding of the analysis, not simply to optimize performance.
Row operations
Row operations are specified in the rows section of the ADaM domain YAML as an array.
Like column derivations, row operations can use either R script or Mustache template components.
Row operations have an id field (user-specified identifier) and a component field. The id is needed because the same component can be used with different parameter values, and the id allows you to refer to a specific implementation when specifying dependencies.
Examples
-
Simple row operation
rows: - id: BASELINE_FLAG component: id: add_baseline_visitExecutes the
add_baseline_visitcode component. The specific actions depend on the code component’s implementation. -
Row operation with parameterized code component
rows: - id: BASELINE_FLAG component: id: add_baseline_visit with: first_treatment_visit: nSpecifies
add_baseline_visitand passes the parameterfirst_treatment_visit = n. -
Multiple row operations referencing the same code component
rows: - id: LOCF_IMPUTATION component: id: impute_values with: method: LOCF - id: NOCB_IMPUTATION component: id: impute_values with: method: NOCBUses the same code component
impute_valuestwice with different parameter values. Unlike column operations, row operations allow the same code component to be called multiple times with different parameters. -
Row operation depending on another row operation
rows: - id: BASELINE_FLAG component: id: add_baseline_visit - id: CHANGE_FROM_BASELINE component: id: calculate_chg depends: - rows.BASELINE_FLAGRuns
calculate_chgonly afterBASELINE_FLAGis executed. Use this when operations must happen in a specific order. Note therows.prefix in the dependency.
Parameters
The parameters section is used primarily in BDS (Basic Data Structure) datasets to define parameter-level operations. These operations create new parameter records (e.g., adding BMI as a new PARAMCD) by deriving values across existing parameters.
Parameters are specified as an array, similar to rows and columns.
Examples
-
Simple parameter operation
parameters: - id: BMI component: id: bds_bmiCreates a new parameter (BMI) using the
bds_bmicomponent. This typically derives BMI values from HEIGHT and WEIGHT parameters. -
Parameter operation with parameters
parameters: - id: BMI component: id: bds_bmi with: height: HEIGHT weight: WEIGHT by: [USUBJID, AVISITN]Creates BMI parameter with explicit specification of input parameters and grouping variables.
-
Parameter operation with dependencies
parameters: - id: BMI component: id: bds_bmi - id: BMI_CATEGORY component: id: bds_groups with: input: BMI output: BMIGRP bins: [0, 20, 25, 30, 100] labels: ["<20", "20-<25", "25-<30", "30+"] depends: - parameters.BMICreates a BMI category parameter that depends on the BMI parameter being derived first. Note the
parameters.prefix in the dependency. -
Multiple parameters using the same component
parameters: - id: PROTEIN component: id: add_lab_parameter with: test_name: Protein - id: ALBUMIN component: id: add_lab_parameter with: test_name: AlbuminUses the same component to add multiple lab parameters with different test names.
Row vs. parameter operations
The difference between row and parameter operations is entirely for the benefit of generating the define.xml document. In mighty both operate the same way and follow the same rules for the ADaM specifications.
