insightsengineering / insightsengineering/teal.transform

merge_dataset should return better information about filter variables and levels

Open
#19 0 comments 0 reactions 0 assignees View on GitHub
core
Dominant language
R
Stars
2
Forks
3
PR merge metrics
No merged PRs in 30d

Description

`data_extract` is designed to contain custom filter for each variable (data_extract). This means
that in `teal.modules.clinical` where we don't need to merge data (all inputs can come from the same dataset), we just need to return information such as `columns_source` and easy accessible `filter_info`.
`data_extract` should be optimized for both scenarios
1. We enable filter input separately for each column selection.
2. We enable filter input globally for all column selections.

At this moment both 1 and 2 is possible (thanks to the `tmc::cs_to_des_filter`), but in both scenarios it's hard to obtain information from `anl_merged()$filter_infos` about the filters without performing some nested-list-filtering. See that in teal.modules.general we don't use `filter` selection anywhere - we use only `columns_source`. Below is the output from `anl_m$filter_info`. Perhaps, easiest solution is to create wrapper function to `get_de_filter_selected(vars = "ADRS")` or something similar. We might wan't to combine all data_extract(s) information for each

```r
[[1]]
NULL

[[2]]
[[2]][[1]]
[[2]][[1]]$columns
[1] "PARAMCD"

[[2]][[1]]$selected
[[2]][[1]]$selected[[1]]
[1] "BESRSPI"

[[2]][[1]]$multiple
[1] FALSE

[[2]][[1]]$drop_keys
[1] FALSE

[[3]]
NULL
```

Check `tm_t_logistic`. Put `browser()` in `srv_t_logistic` after `anl_m <- anl_merged()` and see the output of `anl_m`. `paramcd` which we are interested in is a filter which means that in `columns_source` it will be always empty, but it will be reflected in `anl_m$filter_info`. We can still obtain `selected` from `anl_m$filter_info` but the problem is because we can't select by filter variable name - `filter_info` is unnamed and not robust to reordering.

Find better way to manage `data_extract_input(..., data_extract_spec = )` in `teal.modules.clinical` modules or optimize `teal/teal.devel` workflow to cover both tmg and tmc.

```r
devtools::load_all("../teal")
devtools::load_all("../teal.devel")
devtools::load_all("../teal.modules.clinical")

library(random.cdisc.data)
library(dplyr)
ADSL <- radsl(cached = TRUE)
ADRS <- radrs(cached = TRUE) %>%
filter(PARAMCD %in% c("BESRSPI", "INVET"))

arm_ref_comp = list(
ACTARMCD = list(
ref = "ARM B",
comp = c("ARM A", "ARM C")
),
ARM = list(
ref = "B: Placebo",
comp = c("A: Drug X", "C: Combination")
)
)

app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL, code = 'ADSL <- radsl(cached = TRUE)'),
cdisc_dataset(
"ADRS", ADRS,
code = 'ADRS <- radrs(cached = TRUE) %>% filter(PARAMCD %in% c("BESRSPI", "INVET"))'
),
check = TRUE
),
modules = root_modules(
tm_t_logistic(
label = "Logistic Regression",
dataname = "ADRS",
arm_var = choices_selected(
choices = variable_choices(ADRS, c("ARM", "ARMCD")),
selected = "ARM"
),
arm_ref_comp = arm_ref_comp,
paramcd = choices_selected(
choices = value_choices(ADRS, "PARAMCD", "PARAM"),
selected = value_choices(ADRS, "PARAMCD", "PARAM")
),
cov_var = choices_selected(
choices = c("SEX", "AGE", "BMRKR1", "BMRKR2"),
selected = "SEX"
),
interaction_var = choices_selected(
choices = c("SEX", "AGE", "BMRKR1", "BMRKR2"),
selected = NULL
)
)
)
)

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

Provenance:
```
Creator: gogonzo
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.