Skip to content

Commit

Permalink
Update author list with IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Monika-H committed Mar 15, 2024
1 parent d2315cc commit abc21c9
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 177 deletions.
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ Type: Package
Title: The Maraca Plot: Visualization of Hierarchical Composite Endpoints in Clinical Trials
License: Apache License (>= 2)
Authors@R: c(
person("Martin Karpefors", "", email = "[email protected]", role = "aut"),
person("Samvel B. Gasparyan", "", email = "[email protected]", role = "aut"),
person("Monika Huhn", "", email = "[email protected]", role = c("aut", "cre")),
person("Stefano Borini", "", email = "[email protected]", role = c("ctb")))
person("Martin Karpefors", "", email = "[email protected]", role = "aut",
comment = c(ORCID = "0000-0003-3136-9882")),
person("Samvel B. Gasparyan", "", email = "[email protected]", role = "aut",
comment = c(ORCID = "0000-0002-4797-2208")),
person("Stefano Borini", "", email = "[email protected]", role = c("ctb")),
person("Monika Huhn", "", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0009-0000-7865-6008")))
Description: Library that supports visual interpretation of hierarchical composite
endpoints (HCEs). HCEs are complex constructs used as primary endpoints in
clinical trials, combining outcomes of different types into ordinal endpoints,
Expand Down
349 changes: 176 additions & 173 deletions vignettes/winOdds.Rmd
Original file line number Diff line number Diff line change
@@ -1,173 +1,176 @@
---
title: "Maraca Plots - Plotting win odds"
author: "Monika Huhn"
date: "10/10/2023"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Maraca Plots - Plotting win odds}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE)
library(dplyr)
library(ggplot2)
library(maraca)
```

## Component plot

The maraca package also contains an additional plot
called `"component_plot"`. This one allows to plot the
different components that make up the win odds calculation.
More specifically, for each outcome, the plot shows how
often patients in each treatment arm "won" against the other
arm. For the time-to-event endpoints, this means counting how many
patients of the other arm had no more prioritized event prior.
For the continuous outcome this means counting how many patients had a lower value.
The results are separated for each outcome (non-cumulative)
and also include ties (patients from 2 treatment arms having same
outcome at the same time/same continuous outcome value).

Let us first read in some data.
```{r maraca1, eval = TRUE}
library(maraca)
data(hce_scenario_a)
```

In order to use the `component_plot`, we have to first create a
`maraca` object. Important here is to set the argument
`compute_win_odds = TRUE`, so that the necessary calculations
are included.
```{r}
maraca_dat <- maraca(
data = hce_scenario_a,
step_outcomes = c("Outcome I", "Outcome II", "Outcome III", "Outcome IV"),
last_outcome = "Continuous outcome",
fixed_followup_days = 3 * 365,
column_names = c(outcome = "GROUP", arm = "TRTP", value = "AVAL0"),
arm_levels = c(active = "Active", control = "Control"),
# Make sure to calculate the win odds
compute_win_odds = TRUE
)
```

Now we can just plot the object using the `component_plot()` function.
```{r fig.width=7, fig.height=6}
component_plot(maraca_dat)
```

It is also possible to use the `component_plot()` function directly on
an `hce` object (created using the
[hce package](https://cran.r-project.org/package=hce)).

```{r fig.width=7, fig.height=6}
library(hce)
Rates_A <- c(1.72, 1.74, 0.58, 1.5, 1)
Rates_P <- c(2.47, 2.24, 2.9, 4, 6)
hce_dat <- simHCE(n = 2500, TTE_A = Rates_A, TTE_P = Rates_P,
CM_A = -3, CM_P = -6, CSD_A = 16, CSD_P = 15, fixedfy = 3,
seed = 31337)
component_plot(hce_dat)
```

## Cumulative plot

Furthermore, there is also a plot called `"cumulative_plot"`.
Similar to the `component_plot`, this plot shows the different HCE components that
make up the win odds calculation. Different to the component plot,
this plot provides insight into the contributed effect for each of the components as
they are added in sequence (from top to bottom).
Additionally, there is also a right-hand panel that shows a forest plot with the win odds
and win ratio corresponding to the same cumulative sequence. To understand the contribution
from each outcome, we artificially set all the less prioritized outcomes as ties and calculate
the win odds/ratio. Thus, for each added outcome there will be less ties.

As before, in order to use the `cumulative_plot`, we have to first create a
`maraca` object. Important here is to set the argument
`compute_win_odds = TRUE`, so that the necessary calculations
are included.
```{r}
maraca_dat <- maraca(
data = hce_scenario_a,
step_outcomes = c("Outcome I", "Outcome II", "Outcome III", "Outcome IV"),
last_outcome = "Continuous outcome",
fixed_followup_days = 3 * 365,
column_names = c(outcome = "GROUP", arm = "TRTP", value = "AVAL0"),
arm_levels = c(active = "Active", control = "Control"),
# Make sure to calculate the win odds
compute_win_odds = TRUE
)
```

Now we can just plot the object using the `cumulative_plot()` function.
```{r fig.width=7, fig.height=6}
cumulative_plot(maraca_dat)
```

It is also possible to use the `cumulative_plot()` function directly on
an `hce` object (created using the
[hce package](https://cran.r-project.org/package=hce)).

```{r fig.width=7, fig.height=6}
cumulative_plot(hce_dat)
```

The user can also choose to only display one of the statistics (win odds or win ratio)
by specifying so in the `include` parameter.
```{r fig.width=7, fig.height=6}
cumulative_plot(maraca_dat, include = "win odds")
```

The y-axis can easily be reversed using the `reverse` parameter.
```{r fig.width=7, fig.height=6}
cumulative_plot(hce_dat, reverse = TRUE)
```

## Styling

The resulting plot for the `component_plot()` functions
is a normal ggplot2 object that can be styled accordingly.
```{r fig.width=7, fig.height=6}
component_plot(maraca_dat) +
ggplot2::scale_fill_manual(values = c("seagreen", "red", "grey"), name = NULL)
```

Note that the `cumulative_plot()` function is using the
patchwork package to combine 2 ggplot2 objects. They
can be accessed as list items and styled accordingly.
```{r fig.width=7, fig.height=6}
p <- cumulative_plot(maraca_dat)
p[[1]] <- p[[1]] +
ggplot2::scale_fill_manual(values = c("seagreen", "red", "grey"), name = NULL)
p
```

For the users convenience, there are also different themes
available to style the plot.

The default style is called `theme = "maraca"`.
```{r fig.width=7, fig.height=6}
component_plot(maraca_dat, theme = "maraca")
```

There are 2 different themes with different color
schemes, `theme = "color1"` and `theme = "color2"`.
```{r fig.width=7, fig.height=6}
cumulative_plot(maraca_dat, theme = "color1")
```

```{r fig.width=7, fig.height=6}
component_plot(maraca_dat, theme = "color2")
```

There is also a theme without any styling `theme = "none"` that
can be used as a base when the user wants to style the plot themselves.
```{r fig.width=8, fig.height=6}
cumulative_plot(maraca_dat, theme = "none")
```
---
title: "Maraca Plots - Plotting win odds"
author: "Monika Huhn"
date: "10/10/2023"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Maraca Plots - Plotting win odds}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE)
library(dplyr)
library(ggplot2)
library(maraca)
```

## Component plot

The maraca package also contains an additional plot
called `"component_plot"`. This one allows to plot the
different components that make up the win odds calculation.
More specifically, for each outcome, the plot shows how
often patients in each treatment arm "won" against the other
arm. For the time-to-event endpoints, this means counting how many
patients of the other arm had no more prioritized event prior.
For the continuous outcome this means counting how many patients had a lower value.
The results are separated for each outcome (non-cumulative)
and also include ties (patients from 2 treatment arms having same
outcome at the same time/same continuous outcome value).

Let us first read in some data.
```{r maraca1, eval = TRUE}
library(maraca)
data(hce_scenario_a)
```

In order to use the `component_plot`, we have to first create a
`maraca` object. Important here is to set the argument
`compute_win_odds = TRUE`, so that the necessary calculations
are included.
```{r}
maraca_dat <- maraca(
data = hce_scenario_a,
step_outcomes = c("Outcome I", "Outcome II", "Outcome III", "Outcome IV"),
last_outcome = "Continuous outcome",
fixed_followup_days = 3 * 365,
column_names = c(outcome = "GROUP", arm = "TRTP", value = "AVAL0"),
arm_levels = c(active = "Active", control = "Control"),
# Make sure to calculate the win odds
compute_win_odds = TRUE
)
```

Now we can just plot the object using the `component_plot()` function.
```{r fig.width=7, fig.height=6}
component_plot(maraca_dat)
```

It is also possible to use the `component_plot()` function directly on
an `hce` object (created using the
[hce package](https://cran.r-project.org/package=hce)).

```{r fig.width=7, fig.height=6}
library(hce)
Rates_A <- c(1.72, 1.74, 0.58, 1.5, 1)
Rates_P <- c(2.47, 2.24, 2.9, 4, 6)
hce_dat <- simHCE(n = 2500, TTE_A = Rates_A, TTE_P = Rates_P,
CM_A = -3, CM_P = -6, CSD_A = 16, CSD_P = 15, fixedfy = 3,
seed = 31337)
component_plot(hce_dat)
```

## Cumulative plot

Furthermore, there is a plot called `"cumulative_plot"`.
Similar to the `component_plot`, this plot shows the different HCE components that
make up the win odds calculation. Different to the component plot,
this plot provides insight into the contributed effect for each of the components as
they are added in sequence (from top to bottom).
Additionally, there is also a right-hand panel that shows a forest plot with the win odds
and win ratio corresponding to the same cumulative sequence. To understand the contribution
from each outcome, we artificially set all the less prioritized outcomes as ties and calculate
the win odds/ratio. Thus, for each added outcome there will be less ties.

As before, in order to use the `cumulative_plot`, we have to first create a
`maraca` object. Important here is to set the argument
`compute_win_odds = TRUE`, so that the necessary calculations
are included.
```{r}
maraca_dat <- maraca(
data = hce_scenario_a,
step_outcomes = c("Outcome I", "Outcome II", "Outcome III", "Outcome IV"),
last_outcome = "Continuous outcome",
fixed_followup_days = 3 * 365,
column_names = c(outcome = "GROUP", arm = "TRTP", value = "AVAL0"),
arm_levels = c(active = "Active", control = "Control"),
# Make sure to calculate the win odds
compute_win_odds = TRUE
)
```

Now we can just plot the object using the `cumulative_plot()` function.
```{r fig.width=7, fig.height=6}
cumulative_plot(maraca_dat)
```

It is also possible to use the `cumulative_plot()` function directly on
an `hce` object (created using the
[hce package](https://cran.r-project.org/package=hce)).

```{r fig.width=7, fig.height=6}
cumulative_plot(hce_dat)
```

The user can also choose to only display one of the statistics (win odds or win ratio)
by specifying so in the `include` parameter.
```{r fig.width=7, fig.height=6}
cumulative_plot(maraca_dat, include = "win odds")
```

The y-axis can easily be reversed using the `reverse` parameter.
```{r fig.width=7, fig.height=6}
cumulative_plot(hce_dat, reverse = TRUE)
```

## Styling

The resulting plot for the `component_plot()` functions
is a normal ggplot2 object that can be styled accordingly.
```{r fig.width=7, fig.height=6}
component_plot(maraca_dat) +
ggplot2::scale_fill_manual(values = c("seagreen", "red", "grey"), name = NULL)
```

Note that the `cumulative_plot()` function is using the
patchwork package to combine 2 ggplot2 objects - the
bar plot and the forest plot that together make up the
`cumulative_plot()`. They
can be accessed as list items and styled accordingly.
```{r fig.width=7, fig.height=6}
p <- cumulative_plot(maraca_dat)
# Accessing the first ggplot2 object and adding styling (bar plot)
p[[1]] <- p[[1]] +
ggplot2::scale_fill_manual(values = c("seagreen", "red", "grey"), name = NULL)
p
```

For the users convenience, there are also different themes
available to style the plot.

The default style is called `theme = "maraca"`.
```{r fig.width=7, fig.height=6}
component_plot(maraca_dat, theme = "maraca")
```

There are 2 different themes with different color
schemes, `theme = "color1"` and `theme = "color2"`.
```{r fig.width=7, fig.height=6}
cumulative_plot(maraca_dat, theme = "color1")
```

```{r fig.width=7, fig.height=6}
component_plot(maraca_dat, theme = "color2")
```

There is also a theme without any styling `theme = "none"` that
can be used as a base when the user wants to style the plot themselves.
```{r fig.width=8, fig.height=6}
cumulative_plot(maraca_dat, theme = "none")
```

0 comments on commit abc21c9

Please sign in to comment.