Skip to content

Commit

Permalink
Update graph snapshot processing (#183)
Browse files Browse the repository at this point in the history
Closes #182 

Merge after insightsengineering/tern#1158

This should standardize the generation of graph snapshots across
different systems and hopefully fix the failing integration tests for
graph snapshot differences.

Note: kmg01 snapshots will be fixed after `g_km` is refactored.

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
edelarua and github-actions[bot] authored Dec 20, 2023
1 parent d943da5 commit fa118d9
Show file tree
Hide file tree
Showing 153 changed files with 86,979 additions and 84,774 deletions.
49 changes: 23 additions & 26 deletions book/graphs/efficacy/fstg01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ subtitle: Subgroup Analysis of Best Overall Response

------------------------------------------------------------------------

{{< include ../../test-utils/envir_hook.qmd >}}

::: panel-tabset
## Data Setup

Expand Down Expand Up @@ -42,7 +44,7 @@ var_labels(anl_rsp_arms_ab) <- c(anl_labels, is_rsp = "Is Responder")

## Standard Plot

```{r, warning=FALSE, fig.width = 15}
```{r plot1, test = list(plot_v1 = "plot"), fig.width = 20, fig.height = 5}
df <- extract_rsp_subgroups(
variables = list(
rsp = "is_rsp",
Expand All @@ -57,15 +59,13 @@ df <- extract_rsp_subgroups(
result <- basic_table() %>%
tabulate_rsp_subgroups(df, vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci"))
p <- g_forest(
tbl = result
)
grid::grid.draw(p)
plot <- g_forest(tbl = result)
plot
```

## Plot Specifying Class Variables and <br/> Options for the Treatment Variable

```{r, warning=FALSE, fig.width = 15}
```{r plot2, test = list(plot_v2 = "plot"), fig.width = 20, fig.height = 5}
anl_rsp_comb_arms_ac <- anl %>%
mutate(is_rsp = AVALC %in% c("CR", "PR")) %>%
filter(ARMCD %in% c("ARM B", "ARM A", "ARM C")) %>%
Expand Down Expand Up @@ -98,16 +98,13 @@ df <- extract_rsp_subgroups(
result <- basic_table() %>%
tabulate_rsp_subgroups(df, vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci"))
p <- g_forest(
tbl = result
)
grid::grid.draw(p)
plot <- g_forest(tbl = result)
plot
```

## Plot Selecting Columns and <br/> Changing the Alpha Level

```{r, warning=FALSE, fig.width = 15}
```{r plot3, test = list(plot_v3 = "plot"), fig.width = 10, fig.height = 4}
df <- extract_rsp_subgroups(
variables = list(
rsp = "is_rsp",
Expand All @@ -122,16 +119,13 @@ df <- extract_rsp_subgroups(
result <- basic_table() %>%
tabulate_rsp_subgroups(df, vars = c("n_tot", "or", "ci"))
p <- g_forest(
tbl = result
)
grid::grid.draw(p)
plot <- g_forest(tbl = result)
plot
```

## Plot with Fixed <br/> Symbol Size

```{r, warning=FALSE, fig.width = 15}
```{r plot4, test = list(plot_v4 = "plot"), fig.width = 20, fig.height = 5}
df <- extract_rsp_subgroups(
variables = list(
rsp = "is_rsp",
Expand All @@ -146,17 +140,16 @@ df <- extract_rsp_subgroups(
result <- basic_table() %>%
tabulate_rsp_subgroups(df, vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci"))
p <- g_forest(
plot <- g_forest(
tbl = result,
col_symbol_size = NULL
)
grid::grid.draw(p)
plot
```

## Plot of CR Only, Setting <br/> Values Indicating Response

```{r, warning=FALSE, fig.width = 15}
```{r plot5, test = list(plot_v5 = "plot"), fig.width = 20, fig.height = 5}
anl_cr_arms_ab <- anl %>%
mutate(is_rsp = AVALC == "CR") %>%
filter(ARMCD %in% c("ARM B", "ARM A")) %>%
Expand All @@ -183,13 +176,17 @@ df <- extract_rsp_subgroups(
result <- basic_table() %>%
tabulate_rsp_subgroups(df, vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci"))
p <- g_forest(
tbl = result
)
plot <- g_forest(tbl = result)
plot
```

grid::grid.draw(p)
```{r test parameters, test = list(width = "width", height = "height"), echo=FALSE}
width <- 20
height <- 5
```

{{< include ../../test-utils/save_results.qmd >}}

## `teal` App

```{r teal, message=FALSE, opts.label='skip_if_testing'}
Expand Down
42 changes: 21 additions & 21 deletions book/graphs/efficacy/fstg02.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ subtitle: Subgroup Analysis of Survival Duration

------------------------------------------------------------------------

{{< include ../../test-utils/envir_hook.qmd >}}

::: panel-tabset
## Data Setup

Expand Down Expand Up @@ -54,7 +56,7 @@ anl <- synthetic_cdisc_dataset("latest", "adtte") %>%

## Standard Plot

```{r variant1, warning=FALSE, fig.width = 15}
```{r plot1, test = list(plot_v1 = "plot"), fig.width = 15, fig.height = 4}
anl1 <- anl
df <- extract_survival_subgroups(
Expand All @@ -71,16 +73,13 @@ result <- basic_table() %>%
result
# Add plot.
p <- g_forest(
tbl = result
)
grid::grid.draw(p)
plot <- g_forest(tbl = result)
plot
```

## Plot Specifying Class Variables and <br/> Options for the Treatment Variable

```{r variant2, warning=FALSE, fig.width = 15}
```{r plot2, test = list(plot_v2 = "plot"), fig.width = 15, fig.height = 4}
anl2 <- anl %>%
mutate(
# Recode levels of arm.
Expand Down Expand Up @@ -108,16 +107,13 @@ result <- basic_table() %>%
)
result
p <- g_forest(
tbl = result
)
grid::grid.draw(p)
plot <- g_forest(tbl = result)
plot
```

## Plot Selecting Columns and <br/> Changing the Alpha Level)

```{r variant3, warning=FALSE, fig.width = 15}
```{r plot3, test = list(plot_v3 = "plot"), fig.width = 8, fig.height = 4}
anl3 <- anl
df <- extract_survival_subgroups(
Expand All @@ -134,16 +130,13 @@ result <- basic_table() %>%
result
# Add plot.
p <- g_forest(
tbl = result
)
grid::grid.draw(p)
plot <- g_forest(tbl = result)
plot
```

## Plot with Fixed <br/> Symbol Size

```{r variant4, warning=FALSE, fig.width = 15}
```{r plot4, test = list(plot_v4 = "plot"), fig.width = 15, fig.height = 4}
anl4 <- anl
df <- extract_survival_subgroups(
Expand All @@ -160,14 +153,21 @@ result <- basic_table() %>%
result
# Add plot.
p <- g_forest(
plot <- g_forest(
tbl = result,
col_symbol_size = NULL
)
plot
```

grid::grid.draw(p)
```{r test parameters, test = list(width = "width", height = "height", plot_v3.width = "plot_v3.width"), echo=FALSE}
width <- 15
height <- 4
plot_v3.width <- 8
```

{{< include ../../test-utils/save_results.qmd >}}

## `teal` App

```{r teal, message=FALSE, opts.label='skip_if_testing'}
Expand Down
10 changes: 7 additions & 3 deletions book/graphs/efficacy/mmrmg02.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ From these results a table is obtained using the `tern.mmrm::tabulate_mmrm_subgr

Here we compare `ARM A` with the reference arm, `ARM B`.

```{r plot1, warning=FALSE, fig.width = 15, test = list(plot_v1 = "plot")}
```{r plot1, test = list(plot_v1 = "plot"), fig.width = 15, fig.height = 4}
df_a <- extract_mmrm_subgroups(
fit = mmrm_results,
visit = "SCREENING",
Expand All @@ -106,7 +106,7 @@ plot

Then we compare `ARM C` with `ARM B`.

```{r plot2, warning=FALSE, fig.width = 15, test = list(plot_v2 = "plot")}
```{r plot2, test = list(plot_v2 = "plot"), fig.width = 15, fig.height = 4}
df_c <- extract_mmrm_subgroups(
fit = mmrm_results,
visit = "SCREENING",
Expand All @@ -130,8 +130,12 @@ plot <- g_forest(
plot
```

```{r test parameters, test = list(width = "width", width = "width"), echo=FALSE}
width <- 15
height <- 4
```

{{< include ../../test-utils/save_results.qmd >}}

{{< include ../../repro.qmd >}}

:::
9 changes: 5 additions & 4 deletions package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,26 @@ Suggests:
DescTools,
dplyr,
forcats,
formatters (>= 0.5.4),
formatters (>= 0.5.5),
ggplot2 (>= 3.4.0),
ggpubr,
ggrepel,
grid,
lubridate,
nestcolor,
renv,
rlistings (>= 0.2.6),
rtables (>= 0.6.5),
rlistings (>= 0.2.7),
rtables (>= 0.6.6),
scales,
scda,
scda.2022 (>= 0.1.5),
stats,
stringr,
svglite (>= 2.1.2),
teal (>= 0.14.0.9027),
teal.modules.clinical (>= 0.8.16.9019),
teal.modules.general (>= 0.2.16.9014),
tern (>= 0.9.2),
tern (>= 0.9.3.9002),
tern.mmrm (>= 0.2.2),
tern.rbmi,
tibble,
Expand Down
10 changes: 10 additions & 0 deletions package/tests/testthat/_snaps/cig01/graph-snaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# plot_v9

Code
print(data_snap[[i]])
Output
ARM A ARM B ARM C
————————————————————————————————————————————————
Mean (SD) 17.7 (9.9) 18.7 (9.8) 19.5 (9.1)
Median 17.5 18.2 19.0

70 changes: 0 additions & 70 deletions package/tests/testthat/_snaps/graph-snaps/brg01-plot-v1.svg

This file was deleted.

Loading

0 comments on commit fa118d9

Please sign in to comment.