Skip to content

Commit

Permalink
#216 admiral_0_11_update: update ADRS template
Browse files Browse the repository at this point in the history
  • Loading branch information
bundfussr committed Jun 1, 2023
1 parent f9875f5 commit 54dfe65
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
78 changes: 44 additions & 34 deletions inst/templates/ad_adrs.R
Expand Up @@ -91,17 +91,21 @@ adrs <- adrs %>%

# Progressive disease
adrs <- adrs %>%
derive_param_extreme_event(
dataset_adsl = adsl,
dataset_source = adrs,
filter_source = PARAMCD == "OVR" & AVALC == "PD" & ANL01FL == "Y",
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
filter_add = PARAMCD == "OVR" & AVALC == "PD" & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "first",
exist_flag = AVALC,
set_values_to = exprs(
PARAMCD = "PD",
PARAM = "Disease Progression by Investigator",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
Expand All @@ -126,6 +130,7 @@ adrs <- adrs %>%
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
Expand Down Expand Up @@ -153,6 +158,7 @@ adrs <- adrs %>%
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
Expand All @@ -172,23 +178,28 @@ adrs <- adrs %>%
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = aval_resp(AVALC),
ANL01FL = "Y"
)
)

# Best overall response of CR/PR
adrs <- adrs %>%
derive_param_extreme_event(
dataset_adsl = adsl,
dataset_source = adrs,
filter_source = PARAMCD == "BOR" & AVALC %in% c("CR", "PR") & ANL01FL == "Y",
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
filter_add = PARAMCD == "BOR" & AVALC %in% c("CR", "PR") & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "first",
exist_flag = AVALC,
set_values_to = exprs(
PARAMCD = "BCP",
PARAM = "Best Overall Response of CR/PR by Investigator (confirmation not required)",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
Expand All @@ -207,6 +218,7 @@ adrs <- adrs %>%
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
Expand All @@ -232,6 +244,7 @@ adrs <- adrs %>%
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
) %>%
Expand All @@ -249,20 +262,25 @@ adrs <- adrs %>%
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = aval_resp(AVALC),
ANL01FL = "Y"
)
) %>%
derive_param_extreme_event(
dataset_adsl = adsl,
dataset_source = adrs,
filter_source = PARAMCD == "CBOR" & AVALC %in% c("CR", "PR") & ANL01FL == "Y",
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
filter_add = PARAMCD == "CBOR" & AVALC %in% c("CR", "PR") & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "first",
exist_flag = AVALC,
set_values_to = exprs(
PARAMCD = "CBCP",
PARAM = "Best Confirmed Overall Response of CR/PR by Investigator",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
Expand All @@ -272,30 +290,32 @@ adsldth <- adsl %>%
select(STUDYID, USUBJID, DTHDT, !!!adsl_vars)

adrs <- adrs %>%
derive_param_extreme_event(
dataset_adsl = adsldth,
dataset_source = adsldth,
filter_source = !is.na(DTHDT),
derive_extreme_records(
dataset_ref = adsldth,
dataset_add = adsldth,
by_vars = exprs(STUDYID, USUBJID),
filter_add = !is.na(DTHDT),
exist_flag = AVALC,
set_values_to = exprs(
PARAMCD = "DEATH",
PARAM = "Death",
PARCAT1 = "Reference Event",
ANL01FL = "Y",
AVAL = yn_to_numeric(AVALC),
ADT = DTHDT
)
) %>%
select(-DTHDT)

# Last disease assessment
adrs <- adrs %>%
derive_param_extreme_event(
dataset_adsl = adsl,
dataset_source = adrs,
filter_source = PARAMCD == "OVR" & ANL01FL == "Y",
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
filter_add = PARAMCD == "OVR" & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "last",
# Use this approach to ensure AVALC is not overwritten with a Y
new_var = dummy,
set_values_to = exprs(
PARAMCD = "LSTA",
PARAM = "Last Disease Assessment by Investigator",
Expand All @@ -304,8 +324,7 @@ adrs <- adrs %>%
PARCAT3 = "Recist 1.1",
ANL01FL = "Y"
)
) %>%
select(-dummy)
)

# Measurable disease at baseline
adslmdis <- adsl %>%
Expand All @@ -323,20 +342,11 @@ adrs <- adrs %>%
PARAM = "Measurable Disease at Baseline by Investigator",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)

# Derive numeric analysis value for cases where AVALC has been derived for new parameters
adrs <- adrs %>%
mutate(
AVAL = case_when(
AVALC == "Y" ~ 1,
AVALC == "N" ~ 0,
TRUE ~ AVAL
)
)

# Derive analysis sequence
adrs <- adrs %>%
derive_var_obs_number(
Expand Down
1 change: 1 addition & 0 deletions vignettes/admiralonco.Rmd
Expand Up @@ -62,6 +62,7 @@ for the most common steps are provided by the following vignettes:

- [Creating ADRS](adrs.html)
- [Creating ADTTE](adtte.html)
- [Creating ADTR](adtr.html)

`{admiralonco}` also provides template R scripts as a starting point. They can be
created by calling `use_ad_template()` from {admiral}, e.g.,
Expand Down

0 comments on commit 54dfe65

Please sign in to comment.