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

[Feature Request]: Validate the data summary in the active filters #540

Open
3 tasks done
vedhav opened this issue Jan 30, 2024 · 3 comments
Open
3 tasks done

[Feature Request]: Validate the data summary in the active filters #540

vedhav opened this issue Jan 30, 2024 · 3 comments
Labels
core enhancement New feature or request

Comments

@vedhav
Copy link
Contributor

vedhav commented Jan 30, 2024

Feature description

If a user provides incorrect join keys, they might make the filter logic produce incorrect data. One common pattern is when the parent-child mappings are reversed. This would make the child filter the parent and cause unusual behavior.

Screenshot 2024-01-30 at 11 34 59 PM

Example app to reproduce this error:

library(teal)

data <- within(teal_data(), {
  library(scda)
  library(scda.2022)
  library(dplyr)
  library(nestcolor)

  ADSL <- synthetic_cdisc_data("latest")$adsl

  adsl_labels <- teal.data::col_labels(ADSL, fill = FALSE)
  ADSL <- ADSL %>%
    mutate(
      TRTDURD = as.numeric(as.Date(TRTEDTM) - as.Date(TRTSDTM)) + 1,
      DTHFL = ifelse(!is.na(DTHDT), "Y", NA),
      EOSSTT = factor(EOSSTT, levels = c("COMPLETED", "ONGOING", "DISCONTINUED"))
    ) %>%
    teal.data::col_relabel(
      TRTDURD = "Treatment Duration in Days",
      DTHFL = "Death Flag",
      DCSREAS = "Reason for Study Discontinuation",
      EOSSTT = "End of Study Status"
    ) %>%
    droplevels()
  teal.data::col_labels(ADSL)[c(names(adsl_labels))] <- adsl_labels

  ADRSSWIM <- synthetic_cdisc_data("latest")$adrs %>%
    filter(PARAMCD == "OVRINV") %>%
    arrange(USUBJID)
})

datanames <- c("ADSL", "ADRSSWIM")
datanames(data) <- datanames

join_keys(data) <- default_cdisc_join_keys[datanames]
join_keys(data)["ADRSSWIM", "ADRSSWIM"] <- c("STUDYID", "USUBJID", "PARAMCD", "AVISIT")


# Broken data in filter panel
join_keys(data)["ADRSSWIM", "ADSL"] <- c("STUDYID", "USUBJID")

# Correct mapping to fix the issue
# join_keys(data)["ADSL", "ADRSSWIM"] <- c("STUDYID", "USUBJID")

app <- init(
  data = data,
  modules = example_module()
)

shinyApp(app$ui, app$server)

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.
@vedhav vedhav added enhancement New feature or request core labels Jan 30, 2024
@chlebowa
Copy link
Contributor

I don't quite understand the error. The app seems to be working fine. Can you please elaborate?

@vedhav
Copy link
Contributor Author

vedhav commented Jan 30, 2024

Added a screenshot in the description. The problem is with the improper joins in the filter panel. There are 2400 rows of ADSL created which are just duplicates of the 400 actual rows.
We should have an error or warning when when invalidations occur due to bad user input, in this case improper parent-child mapping.

@chlebowa
Copy link
Contributor

Got it, thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants