Skip to contents

Introduction

This document describes creating a metadata specification using PHARMAVERSE workflow. The matadata-specs can be used to create analysis ready dataset (i.e., ADaM). The matadata-specs required standardized derived dataset, such as SDTM, as input. For illustration purpose, a metadata-specs for following selected analysis ready dataset will be created.

  • Subject-Level Analysis Dataset - ADSL
  • Adverse Events Analysis Dataset - ADAE
  • Analysis Dataset of Questionnaires - ADQS
  • Analysis Dataset of Clinical Classification - ADRS

metacore R package is used to create the metadata-specs.

Building Metadata Specification

# Based on manual codes
data_spec <- bind_rows(adsl_dic, adae_dic, adqs_dic, adrs_dic)

Dataset-Level Information

ds_spec_labels <- c(
  dataset = "Dataset Name",
  structure = "Value Structure",
  label = "Dataset Label"
)

ds_spec <- data_spec %>%
  select(dataset, structure, label = dataset.label) %>%
  distinct() %>%
  assert_non_missing(everything()) %>%
  labelled::set_variable_labels(.labels = ds_spec_labels, .strict = TRUE)

Dataset and Variable Information

ds_vars_labels <- c(
  dataset = "Dataset Name",
  variable = "Variable Name",
  key_seq = "Sequence Key",
  order = "Variable Order",
  keep = "Keep (Boolean)",
  core = "ADaM core (Expected, Required, Permissible)",
  supp_flag = "Supplemental Flag"
)
ds_vars <- data_spec %>%
  select(dataset, variable, key_seq, order, keep, core, supp_flag) %>%
  assert_non_missing(!key_seq) %>%
  labelled::set_variable_labels(.labels = ds_vars_labels, .strict = TRUE)

Variable-Level Information

var_spec_labels <- c(
  variable = "Variable Name",
  length = "Variable Length",
  label = "Variable Label",
  type = "Variable Class",
  common = "Common Across ADaM",
  format = "Variable Format"
)
var_spec <- data_spec %>%
  select(all_of(names(var_spec_labels))) %>%
  assert_non_missing(!format) %>%
  mutate(type = toupper(type)) %>%
  labelled::set_variable_labels(.labels = var_spec_labels, .strict = TRUE)

Value-Level Information

  • Assumed value-level information are similar to variable level information.
value_spec_labels <- c(
  dataset = "Dataset Name",
  variable = "Variable Name",
  type = "Value Type",
  origin = "Value Source",
  sig_dig = "Significant Digits for Numeric Value",
  code_id = "ID of the Code List",
  where = "Value of the Variable",
  derivation_id = "ID of Derivation"
)
value_spec <- data_spec %>%
  select(all_of(names(value_spec_labels))) %>%
  assert_non_missing(dataset, variable, origin) %>%
  labelled::set_variable_labels(.labels = value_spec_labels, .strict = FALSE)

Derivations

derivations_labels <- c(
  derivation_id = "ID of Derivation",
  derivation = "Derivation"
)
derivations <- data_spec %>%
  select(all_of(names(derivations_labels))) %>%
  assert_non_missing(derivation_id)

Code List

Metadata Specification

# Generate Metadata Specs -  R6 class wrapper object
METACORES <- metacore(
  ds_spec = ds_spec,
  ds_vars = ds_vars,
  var_spec = var_spec,
  value_spec = value_spec,
  derivations = derivations,
  codelist = codelist
)
#> 
#>  Metadata successfully imported
# Checking for mismatch labels
check_inconsistent_labels(METACORES) %>%
  is.null()
#> No mismatch labels detected
#> [1] TRUE
# Checking for mismatch format
check_inconsistent_formats(METACORES) %>%
  is.null()
#> No mismatch formats detected
#> [1] TRUE
# Checking for mismatch type
check_inconsistent_types(METACORES) %>%
  is.null()
#> No mismatch types detected
#> [1] TRUE

# Checking for mismatch common variables: user defined function
# Please see the source file for more information
check_inconsistent_common(METACORES) %>%
  is.null()
#> No mismatch common variables
#> [1] TRUE