-
-
Notifications
You must be signed in to change notification settings - Fork 2
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 add facet_scales to plot aesthetics menu #227
Conversation
Code Coverage Summary
Diff against main
Results for commit: 011e81e Minimum allowed coverage is ♻️ This comment has been updated with latest results |
@chlebowa thanks
☝️ |
…m/insightsengineering/teal.goshawk into 219_scales_for_spaghettiplot@main
Fair enough. |
Hey @chlebowa check-out this example. Below I created 3 datasets
When I was testing this functionality, I actually tested situation of
full code is below, here is just a bit of comments
FULL CODE
|
I remember about this
Will reply in the next comment |
I should also remember about insightsengineering/goshawk#201 (comment) |
I got ahead of myself about the validator. The input is independent of data nad there will always be a valid value, so input validation will not be necessary. Sorry about that. Now, |
So yeah, |
How about making it a checkbox? |
@chlebowa oh yeah, now it makes sense if there is only 2 options now. Will update |
@chlebowa I just pushed the change. We have a checkboxInput for freeing X scales |
Fix for insightsengineering/teal.goshawk#219 and continued here insightsengineering/teal.goshawk#227 # Data ```{R} library(stringr) # original ARM value = dose value arm_mapping <- list( "A: Drug X" = "150mg QD", "B: Placebo" = "Placebo", "C: Combination" = "Combination" ) color_manual <- c("150mg QD" = "#000000", "Placebo" = "#3498DB", "Combination" = "#E74C3C") ADLB <- goshawk::rADLB var_labels <- lapply(ADLB, function(x) attributes(x)$label) ADLB <- ADLB %>% mutate(AVISITCD = case_when( AVISIT == "SCREENING" ~ "SCR", AVISIT == "BASELINE" ~ "BL", grepl("WEEK", AVISIT) ~ paste( "W", trimws( substr( AVISIT, start = 6, stop = str_locate(AVISIT, "DAY") - 1 ) ) ), TRUE ~ NA_character_ )) %>% mutate(AVISITCDN = case_when( AVISITCD == "SCR" ~ -2, AVISITCD == "BL" ~ 0, grepl("W", AVISITCD) ~ as.numeric(gsub("\\D+", "", AVISITCD)), TRUE ~ NA_real_ )) %>% # use ARMCD values to order treatment in visualization legend mutate(TRTORD = ifelse(grepl("C", ARMCD), 1, ifelse(grepl("B", ARMCD), 2, ifelse(grepl("A", ARMCD), 3, NA) ) )) %>% mutate(ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))])) %>% mutate(ARM = factor(ARM) %>% reorder(TRTORD)) %>% mutate(ANRLO = .5, ANRHI = 1) %>% rowwise() %>% group_by(PARAMCD) %>% mutate(LBSTRESC = ifelse(USUBJID %in% sample(USUBJID, 1, replace = TRUE), paste("<", round(runif(1, min = .5, max = .7))), LBSTRESC )) %>% mutate(LBSTRESC = ifelse(USUBJID %in% sample(USUBJID, 1, replace = TRUE), paste(">", round(runif(1, min = .9, max = 1.2))), LBSTRESC )) %>% ungroup() attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]] attr(ADLB[["ANRLO"]], "label") <- "Analysis Normal Range Lower Limit" attr(ADLB[["ANRHI"]], "label") <- "Analysis Normal Range Upper Limit" # add LLOQ and ULOQ variables ADLB_LOQS <- goshawk:::h_identify_loq_values(ADLB) ADLB <- left_join(ADLB, ADLB_LOQS, by = "PARAM") ``` # Show all scales - `facet_scales = 'fixed'` ```{R} g_spaghettiplot( data = ADLB, subj_id = "USUBJID", biomarker_var = "PARAMCD", biomarker = "CRP", value_var = "AVAL", trt_group = "ARM", time = "RACE", color_manual = color_manual, color_comb = "#39ff14", alpha = .02, facet_scales = "fixed", rotate_xlab = FALSE, group_stats = "median", hline_arb = c(.5, .7, 1), hline_arb_color = c("blue", "red", "green"), hline_arb_label = c("Arb_Hori_line_A", "Arb_Hori_line_B", "Arb_Hori_line_C"), hline_vars = c("ANRHI", "ANRLO") ) ```  ## Free scales for x - `facet_scales = 'free_x'` ```{R} g_spaghettiplot( data = ADLB, subj_id = "USUBJID", biomarker_var = "PARAMCD", biomarker = "CRP", value_var = "AVAL", trt_group = "ARM", time = "RACE", color_manual = color_manual, color_comb = "#39ff14", alpha = .02, facet_scales = "free_x", rotate_xlab = FALSE, group_stats = "median", hline_arb = c(.5, .7, 1), hline_arb_color = c("blue", "red", "green"), hline_arb_label = c("Arb_Hori_line_A", "Arb_Hori_line_B", "Arb_Hori_line_C"), hline_vars = c("ANRHI", "ANRLO") ) ```  --------- Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup 👌
Closes #219
With this PR I extended
Plot Aesthetic Settings
foldable UI with an option to passscales
parameter toggplot2::facet_wrap
. This also required a change in insightsengineering/goshawk#201