Skip to content

Commit

Permalink
Merge branch 'main' into feature/fix_action_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikSpiegel authored Apr 18, 2024
2 parents 22fc2f4 + 1df4ea8 commit 63a1793
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ To get started, check out the [Quick Start](articles/ramnog.html) guide
library(kableExtra)
library(data.table)
dt <- data.table::data.table(
Package = c("[chef](https://hta-pharma.github.io/chef/)", "[chefStats](https://hta-pharma.github.io/chefStats/)", "[chefCriteria]((https://hta-pharma.github.io/chefCriteria/))", "[ramnog]((https://hta-pharma.github.io/ramnog/))"),
Package = c("[chef](https://hta-pharma.github.io/chef/)", "[chefStats](https://hta-pharma.github.io/chefStats/)", "[chefCriteria](https://hta-pharma.github.io/chefCriteria/)", "[ramnog]((https://hta-pharma.github.io/ramnog/))"),
Description = c(
"Core package that aids in creating endpoint specifications, builds the analysis pipeline, and coordinates the execution of the ananlyses",
"Collection of statistical methods that are used to make summarizations or inferences for each endpoint/outcome",
Expand All @@ -44,7 +44,7 @@ dt <- data.table::data.table(
dt |>
kable(format = "html", table.attr = "class='table table-bordered'") |>
kable_styling(bootstrap_options = c("hover", "condensed", "responsive")) |>
row_spec(0, background = "#2C3E50", color="white")
row_spec(0, background = "#2C3E50", color = "white")
```

# Aim
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ or inferences for each endpoint/outcome
</tr>
<tr>
<td style="text-align:left;">
[chefCriteria]((https://hta-pharma.github.io/chefCriteria/))
[chefCriteria](https://hta-pharma.github.io/chefCriteria/)
</td>
<td style="text-align:left;">
Collection of criteria that are used in AMNOG dossiers to determin when
Expand Down
32 changes: 27 additions & 5 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ template:
bootstrap: 5
bootswatch: flatly

home:
links:
- text: HTA-R openstatsware workstream
href: https://www.openstatsware.org/hta_page.html
- text: ramnog
href: https://hta-pharma.github.io/ramnog/
- text: chefStats
href: https://hta-pharma.github.io/chefStats/
- text: chefCriteria
href: https://hta-pharma.github.io/chefCriteria


navbar:
structure:
left: [intro, articles, contributing]
right: [github]
components:
intro:
text: Quick start
text: Quick Start
href: articles/ramnog.html
contributing:
text: Contributing
Expand All @@ -24,11 +36,11 @@ navbar:
text: Articles
menu:
- text: Overview
- text: Endpoint specification overview
- text: Endpoint Specification
href: articles/ep_overview.html
- text: "----"
- text: Endpoint population and outcome specification
- text: ADaM specification
- text: Population and outcome
- text: ADaM Data
href: articles/ep_spec_adam_data.html
- text: Treatment Arms
href: articles/ep_spec_treatment_arms.html
Expand All @@ -38,13 +50,23 @@ navbar:
href: articles/ep_spec_event_def.html
- text: Strata
href: articles/ep_spec_strata_def.html
- text: Endpoint Label
href: articles/ep_spec_label.html
- text: Processing of Strata without Events
href: articles/ep_spec_strata_w_events.html
- text: ----
- text: Endpoint Statistics
- text: Methods
- text: Criteria Methods
href: articles/methods_criteria.html
- text: Statistical Methods
href: articles/methods_stat.html
- text: ----
- text: Output Data Model
- text: Result Data Model
href: articles/results_datamodel.html
- text: Mapping Results to TFLs
href: articles/results_datamodel2tfl.html
- text: ----
- text: Examples
- text: Endpoint Catalog
href: articles/example_ep_spec.html
Expand Down
2 changes: 1 addition & 1 deletion pkgdown/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
font-weight: 700;
}
.text-muted {
color: var(--bs-navbar-brand-color) !important;
color: #8f9c9d !important;
}
4 changes: 3 additions & 1 deletion vignettes/ep_overview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ For more details on the internal steps of {chef} see [Getting Started with Pipel
The parameters of each endpoint specification can be grouped in to the sets below, which are explained in their respective sections:
```{r, echo=FALSE}
dt <- data.table::data.table(
Type = c(rep("Population and outcome specifications", 13), rep("Methods", 6)),
Type = c(rep("Population and outcome", 14), rep("Methods", 6)),
Section = c(
rep(
"[ADaM data](ep_spec_adam_data.html). What data to use and how to consolidate it into a single data table for the endpoint that is used to calculate statistics.",
Expand All @@ -59,6 +59,7 @@ dt <- data.table::data.table(
4),
"[Strata](ep_spec_strata_def.html). How to slice the data within the endpoint.",
"[Endpoint label](ep_spec_label.html). What events the endpoint describes.",
"[Processing of strata without events](ep_spec_strata_w_events.html). Specification of whether only strata levels with events are to be incorporated in the endpoint.",
rep(
"[Criteria methods](methods_criteria.html). Requirements that must be met to include different types of statistics in the endpoint results.",
3),
Expand All @@ -80,6 +81,7 @@ dt <- data.table::data.table(
"`group_by`",
"`stratify_by`",
"`endpoint_label`",
"`only_strata_with_events`",
"`crit_endpoint`",
"`crit_by_strata_by_trt`",
"`crit_by_strata_across_trt`",
Expand Down
192 changes: 192 additions & 0 deletions vignettes/ep_spec_strata_w_events.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
---
title: "Processing of Strata without Events"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Processing of Strata without Events}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

# Overview

The `only_strata_with_events` endpoint parameter specifies whether the output data will include all strata levels or only those levels that contain events.
By default, all levels will be included in the endpoint

Note: If there is a minimum of one event present in any treatment arm within a specific strata level, that level will be incorporated into the endpoint for all
treatment arms regardsless of whether one of the treatment arms has no events in that stratum.

This functionality is useful in cases where the endpoint specification contains groups and strata that result in many 100s or 1000s of combinations and where only the combinations with events are of interest.
In this case `only_strata_with_events` can be set to `TRUE` to remove the irrelevant combinations and save computation time.

# Examples

```{r, echo=FALSE}
mk_adae <- function(study_metadata) {
adae <- data.table::as.data.table(pharmaverseadam::adae)
adsl <- data.table::as.data.table(pharmaverseadam::adsl)
adsl[, AGEGR2 := data.table::fcase(
AGE < 70, "AGE < 70",
AGE >= 70, "AGE >= 70"
)]
adae_out <-
merge(adsl, adae[, c(setdiff(names(adae), names(adsl)), "USUBJID"),
with =
F
], by = "USUBJID", all = TRUE)
adae_out[]
}
```

##### Ex 7.1

Let us consider the following endpoint specification, where `mk_adae` is defined as in the [Quick Start](ramnog.html),
and grouping is performed on SOC (System Organ Class) and stratification is performed on race.
By default, all strata levels are included, i.e. `only_strata_with_events = FALSE`.

```{r}
ep_spec_ex7_1 <- chef::mk_endpoint_str(
data_prepare = mk_adae,
study_metadata = list(),
pop_var = "SAFFL",
pop_value = "Y",
custom_pop_filter = "TRT01A %in% c('Placebo', 'Xanomeline High Dose') & !is.na(AESOC)",
treatment_var = "TRT01A",
treatment_refval = "Xanomeline High Dose",
group_by = list(list(AESOC = c())),
stratify_by = list(c("RACE")),
stat_by_strata_by_trt = list(N = chefStats::n_subj, n = chefStats::n_subj_event),
endpoint_label = "AESOC: <AESOC>",
only_strata_with_events = FALSE
)
```

In this setup we note:

* `TRT01A` has 2 treatment arms in the analysis data due to `custom_pop_filter`
* `group_by`: `AESOC` has 23 levels
* `stratify_by`: `RACE` has 4 levels
* `stat_by_strata_by_trt`: 2 statistics per combination of group level and strata level

For each SOC this implies:

* Strata = `TOTAL`: 2 treatment arms x 2 statistics = 4 combinations
* Strata = `RACE`: 2 treatment arms x 3 races x 2 statistics = 12 combinations

Thus we have 23 SOCs x (4 + 12) = 368 combinations, i.e. 368 rows in the output data.

Specifically, let us consider the SOC "Eye Disorder" and print the the subset of the output data that covers that SOC (see below).
As expected 4 + 12 = 16 rows are provided. We also notice that two of the strata levels for `RACE` has no event (`n` = 0), which leads to the next example.

```{r, include=FALSE}
mk_endpoint_def <- function(){
chef::mk_endpoint_str(
data_prepare = mk_adae,
study_metadata = list(),
pop_var = "SAFFL",
pop_value = "Y",
custom_pop_filter = "TRT01A %in% c('Placebo', 'Xanomeline High Dose') & !is.na(AESOC)",
treatment_var = "TRT01A",
treatment_refval = "Xanomeline High Dose",
group_by = list(list(AESOC = c())),
stratify_by = list(c("RACE")),
stat_by_strata_by_trt = list(N = chefStats::n_subj, n = chefStats::n_subj_event),
endpoint_label = "AESOC: <AESOC>",
only_strata_with_events = FALSE
)
}
wd_old <- getwd()
prj_old <- suppressMessages(usethis::proj_get())
suppressMessages(testr::create_local_project())
tmp_dir <- getwd()
chef::use_chef(pipeline_id = "01", mk_endpoint_def_fn = mk_endpoint_def, mk_adam_fn = list(mk_adae))
setwd(tmp_dir)
targets::tar_make()
targets::tar_load(ep_stat)
```

```{r}
ep_stat[endpoint_label == "AESOC: EYE DISORDERS", c("stat_filter", "fn_name", "stat_result_value")]
```


##### Ex 7.2

Suppose that we are only interested in the combinations of group levels and strata levels in example 7.1 that have events.
To accomplish this we may specify `only_strata_with_events = TRUE`.

```{r}
ep_spec_ex7_2 <- chef::mk_endpoint_str(
data_prepare = mk_adae,
study_metadata = list(),
pop_var = "SAFFL",
pop_value = "Y",
custom_pop_filter = "TRT01A %in% c('Placebo', 'Xanomeline High Dose') & !is.na(AESOC)",
treatment_var = "TRT01A",
treatment_refval = "Xanomeline High Dose",
group_by = list(list(AESOC = c())),
stratify_by = list(c("RACE")),
stat_by_strata_by_trt = list(N = chefStats::n_subj, n = chefStats::n_subj_event),
endpoint_label = "AESOC: <AESOC>",
only_strata_with_events = TRUE
)
```


Now the number of combination in the output has been reduced to 256.

Let us revisit the SOC "Eye Disorder" and print all rows in the output that relate to that SOC (see below).
We notice that 2 strata levels for `RACE` are not present anymore ("BLACK OR AFRICAN AMERICAN", "AMERICAN INDIAN OR ALASKA NATIVE")
since they have no events c.f. example 7.1., which effectively reduces the number of rows/combinations to 8 for this SOC.

```{r, include=FALSE}
mk_endpoint_def <- function(){
chef::mk_endpoint_str(
data_prepare = mk_adae,
study_metadata = list(),
pop_var = "SAFFL",
pop_value = "Y",
custom_pop_filter = "TRT01A %in% c('Placebo', 'Xanomeline High Dose') & !is.na(AESOC)",
treatment_var = "TRT01A",
treatment_refval = "Xanomeline High Dose",
group_by = list(list(AESOC = c())),
stratify_by = list(c("RACE")),
stat_by_strata_by_trt = list(N = chefStats::n_subj, n = chefStats::n_subj_event),
endpoint_label = "AESOC: <AESOC>",
only_strata_with_events = TRUE
)
}
wd_old <- getwd()
prj_old <- suppressMessages(usethis::proj_get())
suppressMessages(testr::create_local_project())
tmp_dir <- getwd()
chef::use_chef(pipeline_id = "01", mk_endpoint_def_fn = mk_endpoint_def, mk_adam_fn = list(mk_adae))
setwd(tmp_dir)
targets::tar_make()
targets::tar_load(ep_stat)
```

```{r}
ep_stat[endpoint_label == "AESOC: EYE DISORDERS", c("stat_filter", "fn_name", "stat_result_value")]
```

Similarly, the number of combinations for many of the other 22 SOCs are also less than the full 16 combinations:

```{r}
table(ep_stat$endpoint_label)
```

0 comments on commit 63a1793

Please sign in to comment.