Joins subject-level exposure metrics to a response endpoint and derives the exposure quantile grouping that an exposure-response summary or plot is almost always stratified by.

make_ader(
  exposure,
  response,
  by = "USUBJID",
  exposure_var = "AUCLST",
  response_var = "AVAL",
  n_groups = 4
)

Arguments

exposure

Subject-level exposure metrics, one record per by group — typically the output of derive_exposure_metrics(), filtered to a single analyte.

response

Response endpoint data, one record per by group.

by

Character vector of join keys. Both inputs must be unique on it.

exposure_var

Name of the exposure metric column in exposure to group on.

response_var

Name of the response column in response.

n_groups

Number of exposure quantile groups.

Value

An eradam_ader object: a tibble::tibble with one record per by group.

Quantile grouping

Groups are cut at the sample quantiles of exposure_var (stats::quantile(), default type 7) with the lowest value included in the first group. EXPQN is the group number, 1 being the lowest exposure, and EXPQ is a label carrying the range of the group, for example "Q1 (6619-14800)", so a figure legend is self-describing. EXPQ is an ordered factor, so it plots and tabulates in exposure order rather than alphabetically.

There is no CDISC structure for an exposure-response dataset, so EXPPARM, EXPVAL, EXPQN and EXPQ are names chosen by this package. USUBJID, PARAMCD, PARAM and AVAL are standard ADaM names and keep their standard meanings, applied to the response endpoint.

Output structure

VariableMeaningSource
USUBJIDUnique subject identifier (or the by variables supplied)exposure / response
EXPANLTAnalyte the exposure metric was derived forexposure column PARAMCD, renamed
EXPPARMName of the exposure metric usedArgument exposure_var
EXPVALValue of the exposure metricexposure
EXPQNExposure quantile group number (1 = lowest exposure)Derived
EXPQExposure quantile group label, including the range of the groupDerived
PARAMCDResponse parameter coderesponse (kept when present)
PARAMResponse parameter descriptionresponse (kept when present)
AVALResponse valueresponse (argument response_var)
<other>Any remaining columns of exposure and responseexposure / response

Examples

pc <- eradam_example("pc")
ex <- eradam_example("ex")
resp <- eradam_example("resp")

expo <- derive_exposure_metrics(pc[pc$PARAMCD == "DRUGX", ], ex)
ader <- make_ader(expo, resp)
ader
#> 
#> ── eradam exposure-response dataset ────────────────────────────────────────────
#>  24 subject(s) | exposure: AUCLST | response: AVAL
#>  Q1 (6620-11800): n = 6, mean response = -17.89
#>  Q2 (11800-22300): n = 6, mean response = -27.94
#>  Q3 (22300-32000): n = 6, mean response = -32.54
#>  Q4 (32000-52700): n = 6, mean response = -41.66
#> # A tibble: 24 × 22
#>    USUBJID   EXPANLT EXPPARM EXPVAL EXPQN EXPQ  PARAMCD PARAM  AVAL  NOBS TFIRST
#>    <chr>     <chr>   <chr>    <dbl> <int> <ord> <chr>   <chr> <dbl> <int>  <dbl>
#>  1 ERADAM01… DRUGX   AUCLST   6619.     1 Q1 (… PCHGBIO Perc… -21.3    11  0.58 
#>  2 ERADAM01… DRUGX   AUCLST  11468.     1 Q1 (… PCHGBIO Perc… -19.1    11  0.499
#>  3 ERADAM01… DRUGX   AUCLST  11919.     2 Q2 (… PCHGBIO Perc… -26.4    11  0.504
#>  4 ERADAM01… DRUGX   AUCLST  10329.     1 Q1 (… PCHGBIO Perc… -18.8    11  0.506
#>  5 ERADAM01… DRUGX   AUCLST   6868.     1 Q1 (… PCHGBIO Perc… -10.9    11  0.538
#>  6 ERADAM01… DRUGX   AUCLST   6645.     1 Q1 (… PCHGBIO Perc… -18.7    11  0.494
#>  7 ERADAM01… DRUGX   AUCLST   8033.     1 Q1 (… PCHGBIO Perc… -18.5    11  0.509
#>  8 ERADAM01… DRUGX   AUCLST  12978.     2 Q2 (… PCHGBIO Perc… -30.4    11  0.521
#>  9 ERADAM01… DRUGX   AUCLST  19621.     2 Q2 (… PCHGBIO Perc… -34      11  0.547
#> 10 ERADAM01… DRUGX   AUCLST  30823.     3 Q3 (… PCHGBIO Perc… -32.7    11  0.48 
#> # ℹ 14 more rows
#> # ℹ 11 more variables: TLAST <dbl>, CMAX <dbl>, TMAX <dbl>, CMIN <dbl>,
#> #   CTROUGH <dbl>, AUCLST <dbl>, AUCMTH <chr>, DOSE <dbl>, AUCLSTD <dbl>,
#> #   STUDYID <chr>, AVALU <chr>

# mean response by exposure quartile
tapply(ader$AVAL, ader$EXPQ, mean)
#>  Q1 (6620-11800) Q2 (11800-22300) Q3 (22300-32000) Q4 (32000-52700) 
#>        -17.89000        -27.94167        -32.53667        -41.66333 

# tertiles of maximum concentration instead
make_ader(expo, resp, exposure_var = "CMAX", n_groups = 3)
#> 
#> ── eradam exposure-response dataset ────────────────────────────────────────────
#>  24 subject(s) | exposure: CMAX | response: AVAL
#>  Q1 (278-723): n = 8, mean response = -20.52
#>  Q2 (723-1170): n = 8, mean response = -30.57
#>  Q3 (1170-2280): n = 8, mean response = -38.94
#> # A tibble: 24 × 22
#>    USUBJID   EXPANLT EXPPARM EXPVAL EXPQN EXPQ  PARAMCD PARAM  AVAL  NOBS TFIRST
#>    <chr>     <chr>   <chr>    <dbl> <int> <ord> <chr>   <chr> <dbl> <int>  <dbl>
#>  1 ERADAM01… DRUGX   CMAX      378.     1 Q1 (… PCHGBIO Perc… -21.3    11  0.58 
#>  2 ERADAM01… DRUGX   CMAX      491.     1 Q1 (… PCHGBIO Perc… -19.1    11  0.499
#>  3 ERADAM01… DRUGX   CMAX      448.     1 Q1 (… PCHGBIO Perc… -26.4    11  0.504
#>  4 ERADAM01… DRUGX   CMAX      430.     1 Q1 (… PCHGBIO Perc… -18.8    11  0.506
#>  5 ERADAM01… DRUGX   CMAX      329.     1 Q1 (… PCHGBIO Perc… -10.9    11  0.538
#>  6 ERADAM01… DRUGX   CMAX      278.     1 Q1 (… PCHGBIO Perc… -18.7    11  0.494
#>  7 ERADAM01… DRUGX   CMAX      362.     1 Q1 (… PCHGBIO Perc… -18.5    11  0.509
#>  8 ERADAM01… DRUGX   CMAX      615.     1 Q1 (… PCHGBIO Perc… -30.4    11  0.521
#>  9 ERADAM01… DRUGX   CMAX      849.     2 Q2 (… PCHGBIO Perc… -34      11  0.547
#> 10 ERADAM01… DRUGX   CMAX     1185.     3 Q3 (… PCHGBIO Perc… -32.7    11  0.48 
#> # ℹ 14 more rows
#> # ℹ 11 more variables: TLAST <dbl>, CMAX <dbl>, TMAX <dbl>, CMIN <dbl>,
#> #   CTROUGH <dbl>, AUCLST <dbl>, AUCMTH <chr>, DOSE <dbl>, AUCLSTD <dbl>,
#> #   STUDYID <chr>, AVALU <chr>