Skip to content

Commit

Permalink
Update adal01
Browse files Browse the repository at this point in the history
  • Loading branch information
Qi Liu committed Sep 28, 2024
1 parent b93be66 commit 1325ae3
Showing 1 changed file with 61 additions and 42 deletions.
103 changes: 61 additions & 42 deletions book/listings/pharmacokinetic/adal01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,81 +22,100 @@ adab <- synthetic_cdisc_dataset("latest", "adab")
trt <- "A: Drug X"
min_titer_ada <- 1.10
min_titer_nab <- 0
min_conc <- 0
min_titer_nab <- 1.10
min_conc <- 3.0
if (unique(adpc$RELTMU) == "hr") adpc$NFRLT <- adpc$NFRLT / 24
adpc_f <- adpc %>% filter(PARAM == "Plasma Drug X")
if (unique(adab$RELTMU) == "day") adab$NFRLT <- adab$NFRLT * 24
drug_a <- unique(adab$PARCAT1)[1]
drugcd <- unique(adab$PARAMCD[adab$PARAM == "Antibody titer units"])[1]
conc_u <- unique(adab$AVALU[adab$PARAM == "Antibody titer units"])[1]
conc_u <- unique(adpc_f$AVALU)
adpc_f <- adpc_f %>% select(USUBJID, NFRLT, AVAL)
adab_f <- adab %>%
adab1 <- adab %>%
filter(ARM == trt) %>%
select(-PARAMCD, -PARCAT1, -AVALC, -AVALU) %>%
select(-PARAM, -PARCAT1, -AVALC, -AVALU) %>%
left_join(
adpc_f,
by = c("USUBJID", "NFRLT"),
suffix = c("_ab", "_pk")
) %>%
filter(!is.na(AVAL_ab))
adab_f <- adab_f %>%
adab_f <- adab1 %>%
tidyr::pivot_wider(
names_from = PARAM,
id_cols = c(USUBJID, VISIT, NFRLT, ISTPT, AVAL_pk),
names_from = PARAMCD,
values_from = AVAL_ab
) %>%
rename(
RES_ADA = `ADA interpreted per sample result`,
# TES_ADA = `Treatment Emergent - Positive`,
TU_ADA = `Antibody titer units`,
RES_NAB = `NAB interpreted per sample result`,
# TES_NAB = `Treatment Emergent - Positive, Neutralizing Antibody`,
TU_NAB = `Neutralizing Antibody titer units`
)
out <- adab_f %>%
)
# Select the necessary ADA parameters
adab_f1 <- adab_f %>%
select(USUBJID, VISIT, NFRLT, ISTPT, AVAL_pk, R1800000, R1800001, RESULT1, RESULT2, ADASTAT1, ADASTAT2) %>%
mutate(ADA = R1800000, NAB = R1800001) %>% select(-R1800000, -R1800001)
# %>%
# rename(
# RES_ADA = `ADA interpreted per sample result`,
# TES_ADA = `Treatment Emergent - Positive`,
# TU_ADA = `Antibody titer units`,
# RES_NAB = `NAB interpreted per sample result`,
# TES_NAB = `Treatment Emergent - Positive, Neutralizing Antibody`,
# TU_NAB = `Neutralizing Antibody titer units`
# )
# Find subject level ADA status
adab_s <- adab_f1 %>% select(USUBJID, ADASTAT1, ADASTAT2) %>% filter(!is.na(ADASTAT1), !is.na(ADASTAT2))
# Find time-vary ADA records
adab_r <- adab_f1 %>% select(-ADASTAT1, -ADASTAT2) %>% filter(!is.na(VISIT))
adab_o <- adab_r %>% left_join(adab_s, by = "USUBJID")
out <- adab_o %>%
mutate(AVAL_pk = ifelse(AVAL_pk == 0, NA, AVAL_pk)) %>%
mutate_at(
c("NFRLT", "TU_ADA", "TU_NAB", "AVAL_pk"),
~ ifelse(is.na(.), replace(., is.na(.), "N/A"), format(round(., 2), nsmall = 2))
) %>%
mutate(NFRLT = as.numeric(NFRLT)) %>%
mutate(
RES_ADA = ifelse(RES_ADA == 1, "Positive", "Negative"),
# TES_ADA = ifelse(TES_ADA == 1, "Positive", "Negative"),
RES_NAB = ifelse(RES_NAB == 1, "Positive", "Negative"),
# TES_NAB = ifelse(TES_NAB == 1, "Positive", "Negative"),
TU_ADA = ifelse(TU_ADA <= min_titer_ada, "BLQ", TU_ADA),
TU_NAB = ifelse(TU_NAB <= min_titer_nab, "BLQ", TU_NAB),
AVAL_pk = ifelse(AVAL_pk <= min_conc, "BLQ", AVAL_pk)
RESULT1 = ifelse(RESULT1 == 1, "Positive", "Negative"),
RESULT2 = ifelse(RESULT2 == 1, "Positive", "Negative"),
ADASTAT1 = ifelse(ADASTAT1 == 1, "Positive", "Negative"),
ADASTAT2 = ifelse(ADASTAT2 == 1, "Positive", "Negative")
,
# ADA = ifelse(ADA < min_titer_ada, NA, ADA),
# NAB = ifelse(NAB < min_titer_nab, NA, NAB),
AVAL_pk = ifelse(AVAL_pk < min_conc, "BLQ", AVAL_pk)
) %>%
select(
USUBJID, VISIT, ISTPT, NFRLT, RES_ADA, TU_ADA, # TES_ADA,
RES_NAB, TU_NAB, # TES_NAB,
USUBJID, VISIT, ISTPT, NFRLT, ADA, NAB, RESULT1, RESULT2, ADASTAT1, ADASTAT2,
AVAL_pk
) %>%
mutate_at(
c("NFRLT", "ADA", "NAB", "AVAL_pk"),
~ ifelse(is.na(.), replace(., is.na(.), "N/A"), format(round(., 2), nsmall = 2))
)
var_labels(out) <- names(out)
out <- out %>%
arrange(USUBJID, VISIT, desc(ISTPT), NFRLT) %>%
group_by(USUBJID) %>%
mutate(ADASTAT1 = ifelse(row_number() == 1, ADASTAT1, ""),
ADASTAT2 = ifelse(row_number() == 1, ADASTAT2, "")) %>% # Keep only the first value in ADA status, set others to ""
var_relabel(
USUBJID = "Subject ID",
VISIT = "Visit",
ISTPT = "Timepoint",
NFRLT = "Nominal\nTime\n(hr)",
RES_ADA = "Sample\nADA\nResult",
TU_ADA = "ADA\nTiter\nUnits\n(1)",
# TES_ADA = "Patient\nTreatment\nEmergent ADA\nStatus",
RES_NAB = "Sample\nNeutralizing\nAntibody\n(NAb) Result",
TU_NAB = "NAb\nTiter\nUnits\n(2)",
# TES_NAB = "Patient\nTreatment\nEmergent NAb\nStatus",
RESULT1 = "Sample\nADA\nResult",
ADA = "ADA\nTiter\nUnits\n(1)",
ADASTAT1 = "Patient\nTreatment\nEmergent ADA\nStatus",
RESULT2 = "Sample\nNeutralizing\nAntibody\n(NAb) Result",
NAB = "NAb\nTiter\nUnits\n(2)",
ADASTAT2 = "Patient\nTreatment\nEmergent NAb\nStatus",
AVAL_pk = paste0("Drug\nConcentration\n(", conc_u, ") (3)")
) %>%
arrange(USUBJID, VISIT, desc(ISTPT), NFRLT)
)
```

## Standard Listing
Expand All @@ -112,8 +131,8 @@ lsting <- as_listing(
),
subtitles = paste("\nTreatment Group:", trt),
main_footer = "(1) Minimum reportable titer = 1.10 (example only)
(2) Minimum reportable titer = 0 (example only)
(3) Minimum reportable concentration = 0 (example only)
(2) Minimum reportable titer = 1.10 (example only)
(3) Minimum reportable concentration = 3.0 (example only)
BLQ = Below Limit of Quantitation, LTR = Lower than Reportable, N/A = Not Applicable, N.C. = Not Calculable,
ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic Antibodies)
ROXXXXXXX is also known as [drug]"
Expand Down

0 comments on commit 1325ae3

Please sign in to comment.