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

[Question]: [teal.modules.clinical] Should we show code for all possible datasets in the app, if a module uses only one dataset that is not influenced by any other dataset? #126

Closed
3 tasks done
m7pr opened this issue Aug 1, 2023 · 8 comments
Labels
core question Further information is requested

Comments

@m7pr
Copy link
Contributor

m7pr commented Aug 1, 2023

What is your question?

I am looking at patient-profile https://genentech.shinyapps.io/nest_patient-profile_main/ app deployed to shinyapps.
The code for the app is released in this folder in teal.gallery repository.
There is a button for showing the code, that for a module that only uses ADSL dataset, displays information for all possible datasets. I reckon we trim down module specific code only to the datasets needed for this module or needed to create datasets used in this module

image

library(shiny)
library(teal.data)
library(teal.slice)
library(magrittr)
library(teal.transform)
library(teal)
library(formatters)
library(rtables)
library(tern)
library(teal.modules.clinical)
library(ggplot2)
library(ggmosaic)
library(shinyTree)
library(teal.modules.general)
library(scda)
library(scda.2022)
library(nestcolor)
ADSL <- synthetic_cdisc_data("latest")$adsl
ADAE <- synthetic_cdisc_data("latest")$adae
ADMH <- synthetic_cdisc_data("latest")$admh
ADMH[["MHDISTAT"]] <- "ONGOING"
teal.data::col_labels(ADMH[c("MHDISTAT")]) <- c("Status of Disease")
ADCM <- synthetic_cdisc_data("latest")$adcm
ADCM$CMINDC <- paste0("Indication_", as.numeric(ADCM$CMDECOD))
ADCM$CMDOSE <- 1
ADCM$CMTRT <- ADCM$CMCAT
ADCM$CMDOSU <- "U"
ADCM$CMROUTE <- "CMROUTE"
ADCM$CMDOSFRQ <- "CMDOSFRQ"
ADCM$CMASTDTM <- ADCM$ASTDTM
ADCM$CMAENDTM <- ADCM$AENDTM
teal.data::col_labels(ADCM[c("CMINDC", "CMTRT", "ASTDY", "AENDY")]) <- c("Indication", "Reported Name of Drug, Med, or Therapy", "Study Day of Start of Medication", "Study Day of End of Medication")
ADVS <- synthetic_cdisc_data("latest")$advs
ADLB <- synthetic_cdisc_data("latest")$adlb
stopifnot(rlang::hash(ADSL) == "21d12c09b1abbb8b7a98f30bf6e8e6a3")
stopifnot(rlang::hash(ADAE) == "e34c701cd522f27078f7abb812970842")
stopifnot(rlang::hash(ADMH) == "becc66e51cdbefbaa75e8a42a50a7ca9")
stopifnot(rlang::hash(ADCM) == "2060ac79a312ee1dab9292457ec44232")
stopifnot(rlang::hash(ADVS) == "5570e9b1236983fccc403a2b035543f4")
stopifnot(rlang::hash(ADLB) == "179f8330ae412d6d723b49ff995801b8")
ADAE <- dplyr::inner_join(x = ADAE, y = ADSL[, c("STUDYID", "USUBJID"), drop = FALSE], by = c("STUDYID", "USUBJID"))
ADMH <- dplyr::inner_join(x = ADMH, y = ADSL[, c("STUDYID", "USUBJID"), drop = FALSE], by = c("STUDYID", "USUBJID"))
ADCM <- dplyr::inner_join(x = ADCM, y = ADSL[, c("STUDYID", "USUBJID"), drop = FALSE], by = c("STUDYID", "USUBJID"))
ADVS <- dplyr::inner_join(x = ADVS, y = ADSL[, c("STUDYID", "USUBJID"), drop = FALSE], by = c("STUDYID", "USUBJID"))
ADLB <- dplyr::inner_join(x = ADLB, y = ADSL[, c("STUDYID", "USUBJID"), drop = FALSE], by = c("STUDYID", "USUBJID"))
ANL_1 <- ADSL %>% dplyr::select(STUDYID, USUBJID, AGE, SEX, RACE, COUNTRY, ARM, EOSSTT)
ANL <- ANL_1
ANL <- ANL %>% teal.data::col_relabel(AGE = "Age", SEX = "Sex", RACE = "Race", COUNTRY = "Country", ARM = "Description of Planned Arm", EOSSTT = "End of Study Status")
ANL <- ANL[ANL[["USUBJID"]] == "AB12345-RUS-3-id-378", ]
values <- ANL %>%
  dplyr::select(structure(c(AGE = "AGE", SEX = "SEX", RACE = "RACE", COUNTRY = "COUNTRY", ARM = "ARM", EOSSTT = "EOSSTT"), dataname = "ADSL", always_selected = character(0))) %>%
  utils::head(1) %>%
  t()
key <- get_labels(ANL)$column_labels[rownames(values)]
result <- data.frame(key = key, value = values) %>%
  dplyr::select(key, value) %>%
  dplyr::rename(`   ` = key, ` ` = value)
result

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@m7pr m7pr added question Further information is requested core labels Aug 1, 2023
@m7pr
Copy link
Contributor Author

m7pr commented Aug 1, 2023

The same goes for the code present in the Reporter previewer for saved Cards

@lcd2yyz
Copy link

lcd2yyz commented Aug 2, 2023

Great question! Indeed from user perspective, it would make sense to limit the data processing code to display only those associated with datasets used in the module. It would greatly improve readability of the code.

@m7pr
Copy link
Contributor Author

m7pr commented Aug 7, 2023

@lcd2yyz so I guess we can change this card to a regular task (not a question)? Can you do that and prioritize in accordingly in the planning for future sprints?

@lcd2yyz
Copy link

lcd2yyz commented Aug 9, 2023

I don't see a big business need to prioritize this at the moment - yes it doesn't look as pretty as it could be and it's bothersome to read, but as it does not cause errors or affect functionality. Assuming it's relatively straightforward to handle, I think it can be one of the misc task as a filler for a sprint or if someone is in need of switch of "scenery".
But let me know if you see there is some technical priority or a lot more complexity to this issue, eg. it relates to the redesign of data extraction flow that we started to discuss.

@m7pr
Copy link
Contributor Author

m7pr commented Aug 9, 2023

I actually think this could be a part of the redesign of the data extraction you might started to discuss recently. What do you think @gogonzo ?

@gogonzo
Copy link
Contributor

gogonzo commented Aug 9, 2023

@m7pr
In example you provided, the problem lays in teal.modules.clinical not in teal.code. This module asks for datanames = "all" instead of datanames = c(dataname, parentname)

https://github.com/insightsengineering/teal.modules.clinical/blob/13085511515e94a5b22e48e861dd148a5532a3e5/R/tm_g_pp_adverse_events.R#L295

It's a module responsibility to inform teal which datasets it needs. teal and teal.data return dataset-specific code and it works just fine in teal.modules.general modules, for example:

https://github.com/insightsengineering/teal.modules.general/blob/77ec532f83b9e26f02fed02b30029551706ec3b6/R/tm_g_association.R#L130

I actually think this could be a part of the redesign of the data extraction you might started to discuss recently

I think its worth a shot - If you continue work on "code-depends" we will have more information and will be easier to decide.

@m7pr m7pr changed the title [Question]: Should we show code for all possible datasets in the app, if a module uses only one dataset that is not influenced by any other dataset? [Question]: [teal.modules.clinical] Should we show code for all possible datasets in the app, if a module uses only one dataset that is not influenced by any other dataset? Aug 10, 2023
@lcd2yyz
Copy link

lcd2yyz commented Aug 16, 2023

@gogonzo
Copy link
Contributor

gogonzo commented Aug 16, 2023

Closing discussion in favor of specific issue

insightsengineering/teal.modules.clinical#821

@gogonzo gogonzo closed this as completed Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants