Skip to contents

This function builds a dataset out of the columns that just need to be pulled through. So any variable that has a derivation in the format of 'dataset.variable' will be pulled through to create the new dataset. When there are multiple datasets present, they will be joined by the shared key_seq variables. These columns are often called 'Predecessors' in ADaM, but this is not universal so that is optional to specify.

Usage

build_from_derived(
  metacore,
  ds_list,
  dataset_name = NULL,
  predecessor_only = TRUE,
  keep = FALSE
)

Arguments

metacore

metacore object that contains the specifications for the dataset of interest.

ds_list

Named list of datasets that are needed to build the from. If the list is unnamed,then it will use the names of the objects.

dataset_name

Optional string to specify the dataset that is being built. This is only needed if the metacore object provided hasn't already been subsetted.

predecessor_only

By default TRUE, so only variables with the origin of 'Predecessor' will be used. If FALSE any derivation matching the dataset.variable will be used.

keep

String to determine which columns from the original datasets should be kept - "FALSE" (default): only columns that are also present in the ADaM specification are kept in the output. - "ALL": all original columns are carried through to the ADaM, including those that have been renamed. e.g. if DM.ARM is a predecessor to DM.TRT01P, both ARM and TRT01P will be present as columns in the ADaM output. - "PREREQUISITE": columns are retained if they are required for future derivations in the specification. Additional prerequisite columns are identified as columns that appear in the 'derivation' column of the metacore object, but not as direct predecessors. Predecessors are defined as columns where the derivation is a 1:1 copy of a column in a source dataset.

e.g. derivation = "VS.VSTESTCD" is a predecessor, while derivation = "Value of VS.VSSTRESN where VS.VSTESTCD == 'Heart Rate'" contains both VS.VSTESTCD and VS.VSSTRESN as prerequisites, and these columns will be kept through to the ADaM.

Value

dataset

Examples

library(metacore)
library(haven)
library(magrittr)
load(metacore_example("pilot_ADaM.rda"))
spec <- metacore %>% select_dataset("ADSL")
ds_list <- list(DM = read_xpt(metatools_example("dm.xpt")))
build_from_derived(spec, ds_list, predecessor_only = FALSE)
#> # A tibble: 306 × 14
#>    STUDYID     USUBJID SUBJID SITEID ARM   TRT01P   AGE AGEU  RACE  SEX   ETHNIC
#>    <chr>       <chr>   <chr>  <chr>  <chr> <chr>  <dbl> <chr> <chr> <chr> <chr> 
#>  1 CDISCPILOT… 01-701… 1015   701    Plac… Place…    63 YEARS WHITE F     HISPA…
#>  2 CDISCPILOT… 01-701… 1023   701    Plac… Place…    64 YEARS WHITE M     HISPA…
#>  3 CDISCPILOT… 01-701… 1028   701    Xano… Xanom…    71 YEARS WHITE M     NOT H…
#>  4 CDISCPILOT… 01-701… 1033   701    Xano… Xanom…    74 YEARS WHITE M     NOT H…
#>  5 CDISCPILOT… 01-701… 1034   701    Xano… Xanom…    77 YEARS WHITE F     NOT H…
#>  6 CDISCPILOT… 01-701… 1047   701    Plac… Place…    85 YEARS WHITE F     NOT H…
#>  7 CDISCPILOT… 01-701… 1057   701    Scre… Scree…    59 YEARS WHITE F     HISPA…
#>  8 CDISCPILOT… 01-701… 1097   701    Xano… Xanom…    68 YEARS WHITE M     NOT H…
#>  9 CDISCPILOT… 01-701… 1111   701    Xano… Xanom…    81 YEARS WHITE F     NOT H…
#> 10 CDISCPILOT… 01-701… 1115   701    Xano… Xanom…    84 YEARS WHITE M     NOT H…
#> # ℹ 296 more rows
#> # ℹ 3 more variables: DTHFL <chr>, RFSTDTC <chr>, RFENDTC <chr>

# Building an ADaM (ADVS) from multiple input datasets, keeping columns
# needed for future transformations
library(metacore)
library(haven)
library(magrittr)
library(safetyData)
load(metacore_example("pilot_ADaM.rda"))
spec <- metacore %>% select_dataset("ADVS")
ds_list <- list("VS" = safetyData::sdtm_vs,"ADSL" = safetyData::adam_adsl)
build_from_derived(spec,
                   ds_list,
                   predecessor_only = FALSE,
                   keep = "PREREQUISITE"
)
#> # A tibble: 29,643 × 27
#>    STUDYID      SITEID USUBJID       AGE AGEGR1 AGEGR1N RACE  RACEN SEX   SAFFL
#>    <chr>        <chr>  <chr>       <dbl> <chr>    <dbl> <chr> <dbl> <chr> <chr>
#>  1 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#>  2 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#>  3 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#>  4 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#>  5 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#>  6 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#>  7 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#>  8 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#>  9 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#> 10 CDISCPILOT01 701    01-701-1015    63 <65          1 WHITE     1 F     Y    
#> # ℹ 29,633 more rows
#> # ℹ 17 more variables: TRTSDT <date>, TRTEDT <date>, TRTP <chr>, TRTPN <dbl>,
#> #   TRTA <dbl>, TRTAN <dbl>, PARAMCD <chr>, ADY <int>, ATPT <chr>, AVAL <dbl>,
#> #   BASETYPE <chr>, VISITNUM <dbl>, VISIT <chr>, VSSEQ <int>, ABLFL <chr>,
#> #   VSDTC <chr>, VSSTRESN <dbl>