-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
arbitrary horizontal lines to tm_g_gh_spaghettiplot #41
Conversation
@junlueZH The pull down for the horizontal lines is going to be populated by the ANRLO, ANRHI, LLOQN and ULOQN variables. These variables all have labels and those labels would be used for the legend labels. So the only remaining item is to bring the arbitrary hline out of the plot aesthetic section and label these updated UIs per the mock I provided in issue #2 good progress, I think we're almost there. |
implemented: |
@junlueZH please refer to the mockup in issue #2 |
What is "spaigeitti"? |
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.
LGTM - I leave this PR to @npaszty supervision
@junlueZH I don't see the update to the teal module function arguments that include the arguments associated with the arbitrary line. |
Is this what you are seeing if you run this app? library(dplyr)
library(scda)
devtools::load_all("~/nest_projects/goshawk/")
devtools::load_all()
# original ARM value = dose value
arm_mapping <- list("A: Drug X" = "150mg QD",
"B: Placebo" = "Placebo",
"C: Combination" = "Combination")
ADSL <- synthetic_cdisc_data("latest")$adsl
ADLB <- synthetic_cdisc_data("latest")$adlb
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", stringr::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),
hline_1 = 78,
hline_2 = 50)
attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
attr(ADLB[["ACTARM"]], 'label') <- var_labels[["ACTARM"]]
app <- teal::init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL, code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"),
cdisc_dataset(
"ADLB",
ADLB,
code = "ADLB <- synthetic_cdisc_data(\"latest\")$adlb
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', stringr::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),
hline_1 = 78,
hline_2 = 50)
attr(ADLB[['ARM']], 'label') <- var_labels[['ARM']]
attr(ADLB[['ACTARM']], 'label') <- var_labels[['ACTARM']]",
vars = list(arm_mapping = arm_mapping)),
check = TRUE
),
modules = root_modules(
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_vars = c("hline1: Label for hline_1" = "hline_1", "hline2: Label for hline_2" = "hline_2"),
# hline_vars_colors = c("pink", "yellow"),
# hline_vars_labels = c("Top", "Bottom")
)
)
)
shinyApp(app$ui, app$server) |
The latest commit fixes the mean / media label not displaying |
@junlueZH seems like there are a lot of iterations and things are breaking. are we testing against the same code? |
if (!is.null(hline_vars)) { | ||
stopifnot(is_character_vector(hline_vars, min_length = 1)) | ||
if (!is.null(hline_vars_labels)) { | ||
stopifnot(is_character_vector( | ||
hline_vars_labels, min_length = length(hline_vars), | ||
max_length = (length(hline_vars))) | ||
) | ||
} | ||
if (!is.null(hline_vars_colors)) { | ||
stopifnot(is_character_vector( | ||
hline_vars_colors, | ||
min_length = length(hline_vars), | ||
max_length = (length(hline_vars))) | ||
) | ||
} | ||
} | ||
|
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.
also, it makes sense to validate arguments in the order as they are in function definition so those should be right after validations on plot_width
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.
implemented
added ULOQ and LLOQ values to example data added ULOQN and LLOQN variables to UI to complete the example
@junlueZH made some mods and pushed. things look good now for app but one issue remains with the check = TRUE value and introduction of the LLOQ and ULOQ variables in the example data. I don't know why check = TRUE fails so changed to check = FALSE. Can you take a look for me. code looks the same between the example data and code in the app. |
It was failing the reproducibility check because the code was generating random numbers without setting a seed. working now: |
Can we avoid generating random numbers in tests? If we pass a seed anyway, it doesn't really matter, we might as well use a constant. |
implemented If you wish to use the random numbers, then the last commit can be reverted. |
@junlueZH @kpagacz the objective is to have a few records within PARAMCD that contain a "<" or ">" so that we can test and provide example to users that illustrates the LOQs. however you want to accomplish that is fine by me. |
The final decision is up to you. Do you want to revert the last commit and use the random numbers? That could easily be done. Please let me know. |
@junlueZH @kpagacz Something looks odd after my review. The LLUQC/N and ULOQC/N values should be the same for all records of the assay. so the count should be 2800 not 1 for ALT The example works fine and we can keep that in place though it is now different than goshawk. |
This reverts commit 31099d8.
I have reverted the last commit to use the random numbers. This is the output of running the line of code in your comment: > ADLB %>% filter(grepl(">", LBSTRESC)) %>% with(table(PARAMCD, LBSTRESC))
LBSTRESC
PARAMCD > 70 > 71 > 73
ALT 0 0 7
CRP 7 0 0
IGA 0 7 0 |
@junlueZH thanks for your help. |
All of the goshawk functions have already been updated to call the (h_*) function. It was failing automation without the update. So I already did that before I merge your PR. |
closes #39
to test: