Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ADPC #282

Merged
merged 16 commits into from
Jul 13, 2023
Merged
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# random.cdisc.data 0.3.13.9062

### Enhancements
* Refactor `adpc` and `adab` following the new CDISC standard.

* Refactor `abab` parameters and visits to align with `adpc`.

### Breaking changes
Expand Down
3 changes: 2 additions & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ utils::globalVariables(c(
"VSSTRESC", "WEIGHT", "WORS01FL", "ada_bl", "any_pos_postbl", "any_pos_postbl_nab",
"changeind", "comp_count", "first_date", "inc_postbl", "inc_postbl_nab", "ka", "ke",
"last_ada", "n_pos", "nab_bl", "onset_ada", "pos_bl", "pos_bl_nab", "pos_last_postbl",
"publication_name", "row_check"
"publication_name", "row_check", "AFRLT", "ARRLT", "NFRLT", "NRRLT",
"eortc_qlq_c30", "expect", "gdsr_param_adqlqc"
))
26 changes: 13 additions & 13 deletions R/radab.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ radab <- function(adsl,
ARM,
ACTARM,
VISITDY,
ARELTM1,
NRELTM1,
ARELTM2,
NRELTM2,
AFRLT,
NFRLT,
ARRLT,
NRRLT,
RELTMU
) %>%
unique(),
Expand All @@ -139,7 +139,7 @@ radab <- function(adsl,
rename(ISTPT = PCTPT)

# mutate time from dose variables from adpc to convert into Days
adab_visit <- adab_visit %>% dplyr::mutate_at(c("ARELTM1", "NRELTM1", "ARELTM2", "NRELTM2"), ~ . / 24)
adab_visit <- adab_visit %>% dplyr::mutate_at(c("AFRLT", "NFRLT", "ARRLT", "NRRLT"), ~ . / 24)



Expand Down Expand Up @@ -230,12 +230,12 @@ radab <- function(adsl,
adab <- adab %>%
dplyr::mutate(
RELTMU = "day",
ABLFL = ifelse(!is.na(NRELTM1) & NRELTM1 == 0, "Y", NA) # Baseline Record Flag
ABLFL = ifelse(!is.na(NFRLT) & NFRLT == 0, "Y", NA) # Baseline Record Flag
,
ADABLPFL = ifelse(PARAMCD == "RESULT1" & !is.na(NRELTM1) & NRELTM1 == 0, "Y", NA)
ADABLPFL = ifelse(PARAMCD == "RESULT1" & !is.na(NFRLT) & NFRLT == 0, "Y", NA)
# Baseline ADA Eval. Param-Level Flag, only populate for ADA, not for NAB
,
ADPBLPFL = ifelse(PARAMCD == "RESULT1" & !is.na(NRELTM1) & NRELTM1 > 0 & !is.na(AVAL), "Y", NA)
ADPBLPFL = ifelse(PARAMCD == "RESULT1" & !is.na(NFRLT) & NFRLT > 0 & !is.na(AVAL), "Y", NA)
# Post-Baseline ADA Eval. Param-Level Flag, only populate for ADA, not for NAB
) %>%
dplyr::group_by(USUBJID) %>%
Expand All @@ -254,7 +254,7 @@ radab <- function(adsl,
any_pos_postbl_nab = any(PARAM == "NAB interpreted per sample result" &
is.na(ABLFL) & AVALC == "POSITIVE"),
pos_last_postbl = any(PARAM == "ADA interpreted per sample result" &
NRELTM1 == max(NRELTM1) & AVALC == "POSITIVE"),
NFRLT == max(NFRLT) & AVALC == "POSITIVE"),
ada_bl = AVAL[PARAM == "Antibody titer units" & !is.na(ABLFL)],
nab_bl = AVAL[PARAM == "Neutralizing Antibody titer units" & !is.na(ABLFL)]
)
Expand All @@ -267,13 +267,13 @@ radab <- function(adsl,
is.na(ABLFL) & (AVAL - nab_bl) > 0.60),
onset_ada = if (any(PARAM == "ADA interpreted per sample result" &
AVALC == "POSITIVE")) {
min(NRELTM1[PARAM == "ADA interpreted per sample result" & AVALC == "POSITIVE"])
min(NFRLT[PARAM == "ADA interpreted per sample result" & AVALC == "POSITIVE"])
} else {
NA
},
last_ada = if (any(PARAM == "ADA interpreted per sample result" &
AVALC == "POSITIVE")) {
max(NRELTM1[PARAM == "ADA interpreted per sample result" & AVALC == "POSITIVE"])
max(NFRLT[PARAM == "ADA interpreted per sample result" & AVALC == "POSITIVE"])
} else {
NA
}
Expand All @@ -282,7 +282,7 @@ radab <- function(adsl,
dplyr::left_join(pos_tots, by = "USUBJID") %>%
dplyr::select(
USUBJID,
NRELTM1,
NFRLT,
pos_bl,
pos_bl_nab,
any_pos_postbl,
Expand All @@ -298,7 +298,7 @@ radab <- function(adsl,

# add flags to ADAB dataset
adab <- adab %>%
dplyr::left_join(adab_subj, by = c("USUBJID", "NRELTM1"))
dplyr::left_join(adab_subj, by = c("USUBJID", "NFRLT"))

# derive subject-level variables
adab[!(adab$PARAM %in% visit_lvl_params), ] <- adab %>%
Expand Down
10 changes: 10 additions & 0 deletions R/radpc.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,15 @@ radpc <- function(adsl,
adpc <- mutate_na(ds = adpc, na_vars = na_vars, na_percentage = na_percentage)
}

adpc <- adpc %>%
rename(
AVALCAT1 = AVALC,
NFRLT = NRELTM1,
AFRLT = ARELTM1,
NRRLT = NRELTM2,
ARRLT = ARELTM2
) %>%
mutate(ANL02FL = "Y")

adpc <- apply_metadata(adpc, "metadata/ADPC.yml")
}
4 changes: 3 additions & 1 deletion R/radqlqc.R
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ get_qs_data <- function(adsl,
QSORRES = c(1234, 0.2),
QSSTRESC = c(1234, 0.2)
)) {
load(system.file("sysdata.rda", package = "random.cdisc.data"))
checkmate::assert_string(visit_format)
checkmate::assert_integer(n_assessments, len = 1, any.missing = FALSE)
checkmate::assert_integer(n_days, len = 1, any.missing = FALSE)
Expand Down Expand Up @@ -656,6 +657,7 @@ prep_adqlqc <- function(df) {
TRUE ~ QSTESTCD
)
)
load(system.file("sysdata.rda", package = "random.cdisc.data"))
adqlqc1 <- dplyr::left_join(
adqlqc,
gdsr_param_adqlqc,
Expand All @@ -679,7 +681,7 @@ calc_scales <- function(adqlqc1) {
# parcat2 = scales or global health status
# global health status/scales data
# QSTESTCD: EOR0131 to EOR0145 (global health status and scales)

load(system.file("sysdata.rda", package = "random.cdisc.data"))
eortc_qlq_c30_sub <- filter(
eortc_qlq_c30,
!(as.numeric(str_extract(QSTESTCD, "\\d+$")) >= 101 &
Expand Down
Binary file modified data/cadab.RData
Binary file not shown.
Binary file modified data/cadae.RData
Binary file not shown.
Binary file modified data/cadaette.RData
Binary file not shown.
Binary file modified data/cadcm.RData
Binary file not shown.
Binary file modified data/caddv.RData
Binary file not shown.
Binary file modified data/cadeg.RData
Binary file not shown.
Binary file modified data/cadex.RData
Binary file not shown.
Binary file modified data/cadhy.RData
Binary file not shown.
Binary file modified data/cadlb.RData
Binary file not shown.
Binary file modified data/cadmh.RData
Binary file not shown.
Binary file modified data/cadpc.RData
Binary file not shown.
Binary file modified data/cadpp.RData
Binary file not shown.
Binary file modified data/cadqlqc.RData
Binary file not shown.
Binary file modified data/cadqs.RData
Binary file not shown.
Binary file modified data/cadrs.RData
Binary file not shown.
Binary file modified data/cadsl.RData
Binary file not shown.
Binary file modified data/cadsub.RData
Binary file not shown.
Binary file modified data/cadtr.RData
Binary file not shown.
Binary file modified data/cadtte.RData
Binary file not shown.
Binary file modified data/cadvs.RData
Binary file not shown.
16 changes: 8 additions & 8 deletions inst/metadata/ADAB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ variables:
RELTMU:
label: Relative Actual/Nominal Time Units
type: factor
NRELTM1:
label: Nominal Relative Time from First Dose
NFRLT:
label: Nom. Rel. Time from Analyte First Dose
type: numeric
ARELTM1:
label: Analysis Rel. Actual Time from First Dose
AFRLT:
label: Act. Rel. Time from Analyte First Dose
type: numeric
NRELTM2:
label: Nominal Relative Time from Most Recent Dose
NRRLT:
label: Nominal Rel. Time from Ref. Dose
type: numeric
ARELTM2:
label: Analysis Rel. Actual Time from Most Recent Dose
ARRLT:
label: Actual Rel. Time from Ref. Dose
type: numeric
23 changes: 13 additions & 10 deletions inst/metadata/ADPC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ domain:
label: Pharmacokinetic Analysis Dataset

variables:
NRELTM1:
label: Nominal Relative Time from First Dose
NFRLT:
label: Nom. Rel. Time from Analyte First Dose
type: numeric
ARELTM1:
label: Analysis Rel. Actual Time from First Dose
AFRLT:
label: Act. Rel. Time from Analyte First Dose
type: numeric
NRELTM2:
label: Nominal Relative Time from Most Recent Dose
NRRLT:
label: Nominal Rel. Time from Ref. Dose
type: numeric
ARELTM2:
label: Analysis Rel. Actual Time from Most Recent Dose
ARRLT:
label: Actual Rel. Time from Ref. Dose
type: numeric
PCTPTNUM:
label: Planned Time Point Number
Expand All @@ -30,8 +30,8 @@ variables:
AVAL:
label: Analysis Value
type: numeric
AVALC:
label: Analysis Value (C)
AVALCAT1:
label: Analysis Value Category 1
type: character
AVALU:
label: Analysis Value Unit
Expand All @@ -51,3 +51,6 @@ variables:
VISITDY:
label: Visit (N)
type: integer
ANL02FL:
label: Analysis Flag 02
type: character
File renamed without changes.
2 changes: 1 addition & 1 deletion man/cadab.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/cadpc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading