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

Devr 3487 forestlydata #70

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions data-raw/forestly_adae.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

library(arsenal)
library(stringr)
library(dplyr)



adae <- r2rtf::r2rtf_adae



# Derive AREL from existing AEREL
adae <- adae %>% filter(TRTA!="Xanomeline High Dose") %>%
mutate(AREL = case_when(
AEREL %in% c("PROBABLE", "POSSIBLE") ~ "RELATED",
AEREL %in% c("NONE", "REMOTE", "") ~ "NOT RELATED",
TRUE ~ AEREL # Keep original AREL if none of the conditions are met
))


freq <- adae %>% count(AREL, AEREL) %>%
arrange(desc(n))
print(freq)

freq2 <- forestly_adae %>% count(AREL, AEREL) %>%
arrange(desc(n))
print(freq2)

str(adae$TRTA)
str(forestly_adae$TRTA)




adae$AEACN <- sample(
x = c("DOSE NOT CHANGED", "DRUG INTERRUPTED", "DRUG WITHDRAWN", "NOT APPLICABLE", "UNKNOWN"),
size = length(adae$USUBJID),
prob = c(0.7, 0.1, 0.05, 0.1, 0.05), replace = TRUE
)

for (i in seq_along(adae$AEACN)) {
adae$action_taken[i] <- switch(adae$AEACN[i],
"DOSE NOT CHANGED" = "None",
"DRUG INTERRUPTED" = "Interrupted",
"DRUG WITHDRAWN" = "Discontinued",
"NOT APPLICABLE" = "N/A",
"UNKNOWN" = "Unknown",
"''" = "None",
tools::toTitleCase(tolower(adae$AEACN[i]))
)
}

#CHECKS
# freq <- adae %>% count(AEACN) %>% arrange(desc(n))
# print(freq)
#
#
# adae %>%
# select(USUBJID, TRTAN, TRTA, TRTSDT, ASTDT, ADURN, AETERM, AEREL, AESEQ, TRTEMFL, AREL, AEACN) %>%
# slice(1) %>%
# print()
# forestly_adae %>%
# select(USUBJID, TRTAN, TRTA, TRTSDT, ASTDT, ADURN, AETERM, AEREL, AESEQ, TRTEMFL, AREL, AEACN) %>%
# slice(1) %>%
# print()

Binary file added data-raw/forestly_adae.rda
Binary file not shown.
36 changes: 36 additions & 0 deletions data-raw/forestly_adae_3grp.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

library(arsenal)
library(stringr)
library(dplyr)



adae <- r2rtf::r2rtf_adae



# Derive AREL from existing AEREL
adae <- adae %>%
mutate(AREL = case_when(
AEREL %in% c("PROBABLE", "POSSIBLE") ~ "RELATED",
AEREL %in% c("NONE", "REMOTE", "") ~ "NOT RELATED",
TRUE ~ AEREL # Keep original AREL if none of the conditions are met
),
TRTA = str_replace_all(as.character(TRTA), "Xanomeline ", "") %>% as.factor() # Remove "Xanomeline " and convert to factor
)

freq <- adae %>% count(AREL, AEREL) %>%
arrange(desc(n))
print(freq)

str(adae$TRTA)
str(forestly_adae_3grp$TRTA)

# Define the desired order of levels
desired_levels <- c("Placebo", "Low Dose", "High Dose")

# Standardize TRTA in adae
adae$TRTA <- factor(adae$TRTA, levels = desired_levels)



38 changes: 38 additions & 0 deletions data-raw/forestly_adsl.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

library(arsenal)
library(stringr)


adsl <- r2rtf::r2rtf_adsl




load("~/forestly/data/forestly_adsl_3grp.rda")



source("~/forestly/R/function_dataset0compare.R")


#Compare ADSL dataset

freq <- forestly_adsl_3grp %>% count(TRT01A, TRTA) %>%
arrange(desc(n))
print(freq)

# Derive TRTA from existing AEREL
adsl <- adsl %>%
mutate(
TRTA = str_replace_all(as.character(TRT01A), "Xanomeline ", "") %>% as.factor() # Remove "Xanomeline " and convert to factor
)

# Define the desired order of levels
desired_levels <- c("Placebo", "Low Dose", "High Dose")

# Standardize TRTA in adae
adsl$TRTA <- factor(adsl$TRTA, levels = desired_levels)


# Save the adae dataset as an .rda file
save(adsl, file = "~/forestly/data-raw/forestly_adsl.rda")
Binary file added data-raw/forestly_adsl.rda
Binary file not shown.
Loading