insightsengineering / goshawk

Functions that plot and summarize biomarkers/labs of interest
https://insightsengineering.github.io/goshawk/
Other
5 stars 1 forks source link

Treatment Variable in Plot Title #248

Closed npaszty closed 2 months ago

npaszty commented 2 months ago

Feature description

affects all plots

there is no indication of which treatment arm is selected. this should be toggled in the title as "Planned Treatment" and "Actual Treatment" per selection made in "Select Treament Variable" UI item.

Code of Conduct

Contribution Guidelines

Security Policy

m7pr commented 2 months ago

@npaszty just to double check,

image
Code used to create the app ```r data <- teal_data() data <- within(data, { library(dplyr) library(stringr) library(nestcolor) # original ARM value = dose value arm_mapping <- list( "A: Drug X" = "150mg QD", "B: Placebo" = "Placebo", "C: Combination" = "Combination" ) ADSL <- rADSL ADLB <- 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", str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")), TRUE ~ as.character(NA) ), AVISITCDN = 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 = 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) ) attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]] attr(ADLB[["ACTARM"]], "label") <- var_labels[["ACTARM"]] }) datanames <- c("ADSL", "ADLB") datanames(data) <- datanames join_keys(data) <- default_cdisc_join_keys[datanames] app <- init( data = data, modules = modules( tm_g_gh_lineplot( label = "Line Plot", dataname = "ADLB", param_var = "PARAMCD", param = choices_selected(c("ALT", "CRP", "IGA"), "ALT"), shape_choices = c("SEX", "RACE"), xaxis_var = choices_selected("AVISITCD", "AVISITCD"), yaxis_var = choices_selected(c("AVAL", "BASE", "CHG", "PCHG"), "AVAL"), trt_group = choices_selected(c("ARM", "ACTARM"), "ARM"), hline_arb = c(20.5, 19.5), hline_arb_color = c("red", "green"), hline_arb_label = c("A", "B") ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ```
m7pr commented 2 months ago

I think the only enhancement we can provide in here is the addition of the name of the variable selected in the Select Treatment Variable. So we can extend the plot legend with Treatment Variable: {name} where {name} is the same as provided in the data (in this case ARM or ACTARM, but in other data this can be X and Y).

npaszty commented 2 months ago

there are dynamic title and labeling examples in other modules so not sure what the blocker is here. for example, units are dynamicaly added to labels/titles

image image image image image

by grabbing these dynamic value screen shots I now see quite a few inconsistencies in plot titling and labeling which would be great if we could address in this issue too.

npaszty commented 2 months ago

@m7pr @donyunardi

I'm re-thinking this and closing it. rationale for closing is that the Planned and Actual treatment label is already in the legend so it is already dynamically toggled. that is good enough for now and we have other higher valule issues to focus on. 😄