Skip to content

Commit

Permalink
Merge pull request #92 from RConsortium/82-adlbc-derivations
Browse files Browse the repository at this point in the history
82 adlbc derivations

close #82 

I will fix CI workflow check for Validate Links in the minutes RMD outside of this PR.
  • Loading branch information
laxamanaj authored Apr 17, 2023
2 parents 7aab85b + ec80a01 commit 4ad0663
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file modified adam/TDF_ADaM - Pilot 3 Team updated.xlsx
Binary file not shown.
Binary file added submission/.DS_Store
Binary file not shown.
21 changes: 5 additions & 16 deletions submission/programs/adlbc.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' modification History:
#' Dadong Zhang, 17DEC2022
#' Nicole Jones, 12Jan2023
#' Nicole Jones, 02Feb2023
#' Nicole Jones, 13Apr2023
###########################################################################

# Set up ------------------------------------------------------------------
Expand Down Expand Up @@ -33,14 +33,9 @@ supplb <- convert_blanks_to_na(read_xpt(file.path("sdtm", "supplb.xpt")))
# Read and convert NA for ADaM DATASET
## Subject-Level Analysis
adsl <- convert_blanks_to_na(read_xpt(file.path("submission", "datasets", "adsl.xpt")))
## Analysis Dataset Lab Blood Chemistry
prodc <- convert_blanks_to_na(read_xpt(file.path("adam", "adlbc.xpt")))

# Variables for programming
toprogram <- setdiff(colnames(prodc), c(colnames(lb), unique(supplb[["QNAM"]])))

# create labels
metacore <- spec_to_metacore("adam/TDF_ADaM - Pilot 3 Team updated.xlsx", where_sep_sheet = FALSE)
metacore <- spec_to_metacore("adam/TDF_ADaM - Pilot 3 Team updated.xlsx", where_sep_sheet = FALSE, quiet = T)

adlbc_spec <- metacore %>%
select_dataset("ADLBC")
Expand Down Expand Up @@ -100,12 +95,6 @@ adlb01 <- adlb00 %>%
# Dates -------------------------------------------------------------------

adlb02 <- adlb01 %>%
derive_vars_dtm(
new_vars_prefix = "A",
dtc = LBDTC,
highest_imputation = "s",
ignore_seconds_flag = T
) %>%
derive_vars_dt(
new_vars_prefix = "A",
dtc = LBDTC,
Expand Down Expand Up @@ -201,7 +190,7 @@ adlb07 <- adlb06 %>%
group_by(USUBJID, PARAMCD) %>%
mutate(AENTMTFL_1 = ifelse(max(AVISITN, na.rm = T) == AVISITN, "Y", "")) %>%
select(USUBJID, PARAMCD, AENTMTFL_1, LBSEQ) %>%
full_join(adlb06, by = c("USUBJID", "PARAMCD", "LBSEQ")) %>%
full_join(adlb06, by = c("USUBJID", "PARAMCD", "LBSEQ"), multiple = "all") %>%
mutate(AENTMTFL = ifelse(AENTMTFL == "Y", AENTMTFL, AENTMTFL_1)) %>%
select(-AENTMTFL_1) %>%
rbind(eot2) %>%
Expand Down Expand Up @@ -241,13 +230,13 @@ adlb09 <- adlb08 %>%
filter((VISITNUM >= 4 & VISITNUM <= 12) & !grepl("UN", VISIT)) %>%
group_by(USUBJID, PARAMCD) %>%
mutate(
maxALBTRVAL = max(ALBTRVAL, na.rm = T),
maxALBTRVAL = ifelse(!is.na(ALBTRVAL), max(ALBTRVAL, na.rm = T), ALBTRVAL),
ANL01FL = ifelse(maxALBTRVAL == ALBTRVAL, "Y", "")
) %>%
arrange(desc(ANL01FL)) %>%
select(USUBJID, PARAMCD, LBSEQ, ANL01FL) %>%
slice(1) %>%
full_join(adlb08, by = c("USUBJID", "PARAMCD", "LBSEQ"))
full_join(adlb08, by = c("USUBJID", "PARAMCD", "LBSEQ"), multiple = "all")

# Treatment Vars ------------------------------------------------------------

Expand Down

0 comments on commit 4ad0663

Please # to comment.