-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
219 scales parameter for facet_wrap in g_spaghettiplot #201
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chlebowa
suggested changes
Jul 19, 2023
chlebowa
reviewed
Jul 19, 2023
Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
chlebowa
reviewed
Jul 19, 2023
Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
chlebowa
approved these changes
Jul 19, 2023
Code Coverage Summary
Diff against main
Results for commit: fcfa8e1 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
m7pr
added a commit
to insightsengineering/teal.goshawk
that referenced
this pull request
Jul 21, 2023
Closes #219 With this PR I extended `Plot Aesthetic Settings` foldable UI with an option to pass `scales` parameter to `ggplot2::facet_wrap`. This also required a change in insightsengineering/goshawk#201 ```{R} library(dplyr) # original ARM value = dose value arm_mapping <- list( "A: Drug X" = "150mg QD", "B: Placebo" = "Placebo", "C: Combination" = "Combination" ) set.seed(1) ADSL <- goshawk::rADSL ADLB <- goshawk::rADLB var_labels <- lapply(ADLB, function(x) attributes(x)$label) ADLB <- ADLB %>% dplyr::mutate( AVISITCD = dplyr::case_when( AVISIT == "SCREENING" ~ "SCR", AVISIT == "BASELINE" ~ "BL", grepl("WEEK", AVISIT) ~ paste("W", stringr::str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")), TRUE ~ as.character(NA) ), AVISITCDN = dplyr::case_when( AVISITCD == "SCR" ~ -2, AVISITCD == "BL" ~ 0, grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)), TRUE ~ as.numeric(NA) ), AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN), TRTORD = dplyr::case_when( ARMCD == "ARM C" ~ 1, ARMCD == "ARM B" ~ 2, ARMCD == "ARM A" ~ 3 ), ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]), ARM = factor(ARM) %>% reorder(TRTORD), ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]), ACTARM = factor(ACTARM) %>% reorder(TRTORD), ANRLO = 30, ANRHI = 75 ) %>% dplyr::rowwise() %>% dplyr::group_by(PARAMCD) %>% dplyr::mutate(LBSTRESC = ifelse(USUBJID %in% sample(USUBJID, 1, replace = TRUE), paste("<", round(runif(1, min = 25, max = 30))), LBSTRESC )) %>% dplyr::mutate(LBSTRESC = ifelse(USUBJID %in% sample(USUBJID, 1, replace = TRUE), paste(">", round(runif(1, min = 70, max = 75))), LBSTRESC )) %>% ungroup() attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]] attr(ADLB[["ACTARM"]], "label") <- var_labels[["ACTARM"]] attr(ADLB[["ANRLO"]], "label") <- "Analysis Normal Range Lower Limit" attr(ADLB[["ANRHI"]], "label") <- "Analysis Normal Range Upper Limit" # add LLOQ and ULOQ variables ALB_LOQS <- goshawk:::h_identify_loq_values(ADLB) ADLB <- dplyr::left_join(ADLB, ALB_LOQS, by = "PARAM") app <- teal::init( data = teal.data::cdisc_data( teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- goshawk::rADSL"), teal.data::cdisc_dataset( "ADLB", ADLB, code = "set.seed(1) ADLB <- goshawk::rADLB var_labels <- lapply(ADLB, function(x) attributes(x)$label) ADLB <- ADLB %>% dplyr::mutate(AVISITCD = dplyr::case_when( AVISIT == 'SCREENING' ~ 'SCR', AVISIT == 'BASELINE' ~ 'BL', grepl('WEEK', AVISIT) ~ paste('W', stringr::str_extract(AVISIT, '(?<=(WEEK ))[0-9]+')), TRUE ~ as.character(NA)), AVISITCDN = dplyr::case_when( AVISITCD == 'SCR' ~ -2, AVISITCD == 'BL' ~ 0, grepl('W', AVISITCD) ~ as.numeric(gsub('[^0-9]*', '', AVISITCD)), TRUE ~ as.numeric(NA)), AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN), TRTORD = dplyr::case_when( ARMCD == 'ARM C' ~ 1, ARMCD == 'ARM B' ~ 2, ARMCD == 'ARM A' ~ 3), ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]), ARM = factor(ARM) %>% reorder(TRTORD), ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]), ACTARM = factor(ACTARM) %>% reorder(TRTORD), ANRLO = 30, ANRHI = 75) %>% dplyr::rowwise() %>% dplyr::group_by(PARAMCD) %>% dplyr::mutate(LBSTRESC = ifelse(USUBJID %in% sample(USUBJID, 1, replace = TRUE), paste('<', round(runif(1, min = 25, max = 30))), LBSTRESC)) %>% dplyr::mutate(LBSTRESC = ifelse(USUBJID %in% sample(USUBJID, 1, replace = TRUE), paste( '>', round(runif(1, min = 70, max = 75))), LBSTRESC)) %>% ungroup attr(ADLB[['ARM']], 'label') <- var_labels[['ARM']] attr(ADLB[['ACTARM']], 'label') <- var_labels[['ACTARM']] attr(ADLB[['ANRLO']], 'label') <- 'Analysis Normal Range Lower Limit' attr(ADLB[['ANRHI']], 'label') <- 'Analysis Normal Range Upper Limit' ALB_LOQS <- goshawk:::h_identify_loq_values(ADLB) ADLB <- left_join(ADLB, ALB_LOQS, by = 'PARAM')", vars = list(arm_mapping = arm_mapping) ), check = FALSE ), modules = teal::modules( teal.goshawk::tm_g_gh_spaghettiplot( label = "Spaghetti Plot", dataname = "ADLB", param_var = "PARAMCD", param = choices_selected(c("ALT", "CRP", "IGA"), "ALT"), idvar = "USUBJID", xaxis_var = choices_selected(c("Analysis Visit Code" = "AVISITCD"), "AVISITCD"), yaxis_var = choices_selected(c("AVAL", "CHG", "PCHG"), "AVAL"), filter_var = choices_selected( c("None" = "NONE", "Screening" = "BASE2", "Baseline" = "BASE"), "NONE" ), trt_group = choices_selected(c("ARM", "ACTARM"), "ARM"), color_comb = "#39ff14", man_color = c( "Combination" = "#000000", "Placebo" = "#fce300", "150mg QD" = "#5a2f5f" ), hline_arb = c(60, 50), hline_arb_color = c("grey", "red"), hline_arb_label = c("default A", "default B"), hline_vars = c("ANRHI", "ANRLO", "ULOQN", "LLOQN"), hline_vars_colors = c("pink", "brown", "purple", "black"), ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ```  --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for insightsengineering/teal.goshawk#219 and continued here insightsengineering/teal.goshawk#227
Data
Show all scales -
facet_scales = 'fixed'
Free scales for x -
facet_scales = 'free_x'