insightsengineering / insightsengineering/teal.osprey

tm_g_heat_bygrade

Open
#2 5 comments 0 reactions 0 assignees View on GitHub
blocked sme
Dominant language
R
Stars
5
Forks
2
Avg merge
10h 8m
Merged PRs (30d)
3

Description

The example does not work when changing the data to cached = TRUE.

```r
library(random.cdisc.data)
ADSL <- radsl(cached = TRUE)
ADEX <- radex(cached = TRUE)
ADAE <- radae(cached = TRUE)
ADCM <- radcm(cached = TRUE)
# function to derive AVISIT from ADEX
add_visit <- function(data_need_visit){
visit_dates <- ADEX %>%
filter(PARAMCD == "DOSE") %>%
distinct(USUBJID, AVISIT, ASTDTM) %>%
group_by(USUBJID) %>%
arrange(ASTDTM) %>%
mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) %>%
rename(this_vis = ASTDTM)
data_visit <- data_need_visit %>%
select(USUBJID, ASTDTM) %>%
left_join(visit_dates, by = "USUBJID") %>%
filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) %>%
left_join(data_need_visit)
return(data_visit)
}
# derive AVISIT for ADAE and ADCM
ADAE <- add_visit(ADAE)
ADCM <- add_visit(ADCM)
# derive ongoing status variable for ADEX
ADEX <- ADEX %>%
filter(PARCAT1 == "INDIVIDUAL") %>%
mutate(ongo_status = (EOSSTT == "ONGOING"))

app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL),
cdisc_dataset("ADEX", ADEX),
cdisc_dataset("ADAE", ADAE),
cdisc_dataset("ADCM", ADCM),
code = "
ADSL <- radsl(N = 30, seed = 1)
ADEX <- radex(ADSL)
ADAE <- radae(ADSL)
ADCM <- radcm(ADSL)
ADEX <- ADEX %>%
filter(PARCAT1 == 'INDIVIDUAL') %>%
mutate(ongo_status = (EOSSTT == 'ONGOING'))
add_visit <- function(data_need_visit){
visit_dates <- ADEX %>%
filter(PARAMCD == 'DOSE') %>%
distinct(USUBJID, AVISIT, ASTDTM) %>%
group_by(USUBJID) %>%
arrange(ASTDTM) %>%
mutate(next_vis = lead(ASTDTM), is_last = ifelse(is.na(next_vis), TRUE, FALSE)) %>%
rename(this_vis = ASTDTM)
data_visit <- data_need_visit %>%
select(USUBJID, ASTDTM) %>%
left_join(visit_dates, by = 'USUBJID') %>%
filter(ASTDTM > this_vis & (ASTDTM < next_vis | is_last == TRUE)) %>%
left_join(data_need_visit)
return(data_visit)
}
ADAE <- add_visit(ADAE)
ADCM <- add_visit(ADCM)
",
check = TRUE
),
modules = root_modules(
tm_g_heat_bygrade(
label = "Heatmap by grade",
sl_dataname = "ADSL",
ex_dataname = "ADEX",
ae_dataname = "ADAE",
cm_dataname = "ADCM",
id_var = choices_selected(selected = "USUBJID",
choices = c("USUBJID", "SUBJID")),
visit_var = choices_selected(selected = "AVISIT",
choices = c("AVISIT")),
ongo_var = choices_selected(selected = "ongo_status",
choices = c("ongo_status")),
anno_var = choices_selected(selected = c("SEX", "COUNTRY"),
choices = c("SEX", "COUNTRY", "USUBJID")),
heat_var = choices_selected(selected = "AETOXGR",
choices = c("AETOXGR")),
conmed_var = choices_selected(selected = "CMDECOD",
choices = c("CMDECOD")),
plot_height = c(600, 200, 2000)
)
)
)

shinyApp(app$ui, app$server)
```

user/3166/files/fac79380-acdf-11eb-80b6-136101c77b0b)

NEST/agile-R/issues/1756 becomes incredibly tricky for me.

Provenance:
```
Creator: kpagacz
```

Contributor guide

Open the contributing guide

Research direction

Start with the supplied tm_g_heat_bygrade example and run it with cached = TRUE, comparing the result with the non-cached case. Trace where the cached datasets enter the module and reproduce the failure; done means the complete example runs successfully with cached = TRUE.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data, data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.