Skip to content

Commit

Permalink
added a new vignette on reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
shug0131 committed Mar 13, 2024
1 parent 3dcf71f commit 3004654
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 96 deletions.
110 changes: 57 additions & 53 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
---
output: github_document
---
<!-- badges: start -->
[![R-CMD-check](https://github.com/shug0131/eudract_pkg/workflows/R-CMD-check/badge.svg)](https://github.com/shug0131/eudract_pkg/actions)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/shug0131/eudract_pkg?branch=master&svg=true)](https://ci.appveyor.com/project/shug0131/eudract_pkg)
[![Codecov eudract_pkg](https://codecov.io/gh/shug0131/eudract_pkg/branch/master/graph/badge.svg)](https://app.codecov.io/gh/shug0131/eudract_pkg?branch=master)
<!-- badges: end -->




<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
# eudract

The goal of eudract is to provide tools to easily produce summaries of safety data from clinical trials that can easily be uploaded into eudraCT or ClinTrials.gov .



## Installation

You can install from CRAN directly with

```r
install.packages("eudract")
```


You can install the very latest version on github with:

``` r
install.packages("devtools")
devtools::install_github("shug0131/eudract_pkg")
```

## Documentation

https://eudract-tool.medschl.cam.ac.uk provides full documentation

Go and read the help pages within R

```{r example}
?eudract::safety_summary
```

---
output: github_document
---
<!-- badges: start -->
[![R-CMD-check](https://github.com/shug0131/eudract_pkg/workflows/R-CMD-check/badge.svg)](https://github.com/shug0131/eudract_pkg/actions)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/shug0131/eudract_pkg?branch=master&svg=true)](https://ci.appveyor.com/project/shug0131/eudract_pkg)
[![Codecov eudract_pkg](https://codecov.io/gh/shug0131/eudract_pkg/branch/master/graph/badge.svg)](https://app.codecov.io/gh/shug0131/eudract_pkg?branch=master)
<!-- badges: end -->




<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
# eudract

The goal of eudract is to provide tools to easily produce summaries of safety data from clinical trials that can easily be uploaded into eudraCT or ClinTrials.gov .

An additional feature produces commonly used tables and figures that feature in statistical reports and papers for clinical trials.


## Installation

You can install from CRAN directly with

```r
install.packages("eudract")
```


You can install the very latest version on github with:

``` r
install.packages("devtools")
devtools::install_github("shug0131/eudract_pkg")
```

## Documentation

https://eudract-tool.medschl.cam.ac.uk provides full documentation

Go and read the help pages within R `?eudract::safety_summary`

```{r example, file="example/canonical.R", eval=FALSE}
```

And for produce standard reporting outputs

```{r report_example, file="example/reporting.R"}
```
152 changes: 109 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,109 @@

<!-- badges: start -->

[![R-CMD-check](https://github.com/shug0131/eudract_pkg/workflows/R-CMD-check/badge.svg)](https://github.com/shug0131/eudract_pkg/actions)
[![AppVeyor Build
Status](https://ci.appveyor.com/api/projects/status/github/shug0131/eudract_pkg?branch=master&svg=true)](https://ci.appveyor.com/project/shug0131/eudract_pkg)
[![Codecov
eudract_pkg](https://codecov.io/gh/shug0131/eudract_pkg/branch/master/graph/badge.svg)](https://app.codecov.io/gh/shug0131/eudract_pkg?branch=master)
<!-- badges: end -->

<!-- README.md is generated from README.Rmd. Please edit that file -->

# eudract

The goal of eudract is to provide tools to easily produce summaries of
safety data from clinical trials that can easily be uploaded into
eudraCT or ClinTrials.gov .

## Installation

You can install from CRAN directly with

``` r
install.packages("eudract")
```

You can install the very latest version on github with:

``` r
install.packages("devtools")
devtools::install_github("shug0131/eudract_pkg")
```

## Documentation

<https://eudract-tool.medschl.cam.ac.uk> provides full documentation

Go and read the help pages within R

``` r
?eudract::safety_summary
#> starting httpd help server ... done
```

<!-- badges: start -->

[![R-CMD-check](https://github.com/shug0131/eudract_pkg/workflows/R-CMD-check/badge.svg)](https://github.com/shug0131/eudract_pkg/actions)
[![AppVeyor Build
Status](https://ci.appveyor.com/api/projects/status/github/shug0131/eudract_pkg?branch=master&svg=true)](https://ci.appveyor.com/project/shug0131/eudract_pkg)
[![Codecov
eudract_pkg](https://codecov.io/gh/shug0131/eudract_pkg/branch/master/graph/badge.svg)](https://app.codecov.io/gh/shug0131/eudract_pkg?branch=master)
<!-- badges: end -->

<!-- README.md is generated from README.Rmd. Please edit that file -->

# eudract

The goal of eudract is to provide tools to easily produce summaries of
safety data from clinical trials that can easily be uploaded into
eudraCT or ClinTrials.gov .

An additional feature produces commonly used tables and figures that
feature in statistical reports and papers for clinical trials.

## Installation

You can install from CRAN directly with

``` r
install.packages("eudract")
```

You can install the very latest version on github with:

``` r
install.packages("devtools")
devtools::install_github("shug0131/eudract_pkg")
```

## Documentation

<https://eudract-tool.medschl.cam.ac.uk> provides full documentation

Go and read the help pages within R `?eudract::safety_summary`

``` r
safety_statistics <- safety_summary(safety,
exposed=c("Experimental"=60,"Control"=67))
simple <- tempfile(fileext = ".xml")
eudract <- tempfile(fileext = ".xml")
ct <- tempfile(fileext = ".xml")
simple_safety_xml(safety_statistics, simple)
eudract_convert(input=simple,
output=eudract)
clintrials_gov_convert(input=simple,
original=system.file("extdata", "1234.xml", package ="eudract"),
output=ct)
\dontrun{
# This needs a real user account to work
clintrials_gov_upload(
input=simple,
orgname="CTU",
username="Student",
password="Guinness",
studyid="1234"
)

}
```

And for produce standard reporting outputs

``` r
library(eudract)
safety_statistics <- safety_summary(safety,
exposed=c("Control"=99, "Experimental"=101))
safety_statistics$GROUP
#> title subjectsAffectedBySeriousAdverseEvents
#> 1 Control 15
#> 2 Experimental 33
#> subjectsAffectedByNonSeriousAdverseEvents deathsResultingFromAdverseEvents
#> 1 15 9
#> 2 24 22
#> subjectsExposed deathsAllCauses
#> 1 99 9
#> 2 101 22
head( incidence_table(safety_statistics, type="serious") )
#> System Organ Class Preferred Term
#> 1 Blood and lymphatic system disorders B-cell lymphoma
#> 2 Cardiac disorders Cardiac arrest
#> 3 Cardiac failure congestive
#> 4 Gastrointestinal disorders Abdominal pain
#> 5 Gastroenteritis viral
#> 6 Gastrointestinal haemorrhage
#> Control (N = 99) Experimental (N = 101)
#> 1 1% (1, 1) 0% (0, 0)
#> 2 1% (1, 1) 0% (0, 0)
#> 3 0% (0, 0) 1% (1, 1)
#> 4 1% (1, 1) 0% (0, 0)
#> 5 0% (0, 0) 1% (1, 1)
#> 6 0% (0, 0) 1% (1, 1)
relative_risk_table(safety_statistics, type="serious")
#> System Organ Class Preferred Term Relative Risk (C.I.)
#> 1 Hepatobiliary disorders Cholecystitis acute 0.98 (0.0605, 15.9)
#> 2 Immune system disorders Vasculitis 1.96 (0.175, 22)
#> 3 Surgical and medical procedures Hip arthroplasty 1.96 (0.175, 22)
#> 4 Vascular disorders Deep vein thrombosis 2.94 (0.301, 28.8)
#> 5 Pulmonary embolism 0.98 (0.0605, 15.9)
dot_plot(safety_statistics, type="serious", base=4)
```

<img src="README_files/figure-gfm/report_example-1.png" width="100%" />
Binary file added README_files/figure-gfm/report_example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions example/reporting.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
library(eudract)
safety_statistics <- safety_summary(safety,
exposed=c("Control"=99, "Experimental"=101))
safety_statistics$GROUP
head( incidence_table(safety_statistics, type="serious") )
relative_risk_table(safety_statistics, type="serious")
dot_plot(safety_statistics, type="serious", base=4)
91 changes: 91 additions & 0 deletions vignettes/standard_reporting.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: "Standard tables and figures"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{standard_reporting}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
chunk_output_type: console
---

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

```{r setup}
library(eudract)
library(knitr)
```

We can easily produce some of the standard reports needed for most clinical trials, as well
as producing the xml files needed to upload to EudraCT or ClinicalTrials.gov. See the [other vignette](eudract.html)

We first ensure the data is in the correct format, column names to produce a basic safety object

```{r safety}
head(safety)
safety_statistics <- safety_summary(safety,exposed=c("Control"=99, "Experimental"=101))
```

A top level table is the `$GROUP` data frame with slightly improved column names

```{r group}
df <- safety_statistics$GROUP
names(df) <- c("Arm", "SAE count", "Non Serious AE count", "Death from AE count", "N", "All cause deaths count")
kable(df, caption = "Total Adverse Events")
```

Next we provide an incidence table

```{r incidence}
incidence <- incidence_table(safety_statistics, type ="serious")
kable(incidence, caption="SAE incidence")
incidence <- incidence_table(safety_statistics, type ="non_serious")
kable(incidence, caption="Non-serious AE incidence")
```

A table of relative risk can be given

```{r relative_risk}
rr <- relative_risk_table(safety_statistics, type="serious")
kable(rr, caption="SAE relative risks")
rr <- relative_risk_table(safety_statistics, type="non_serious")
kable(rr, caption="Non-serious AE relative risks")
```

Finally a set of dot-plots to show graphically and compare, using functions from [patchwork](https://patchwork.data-imaginist.com/) to add titles

```{r dotplot_sae, fig.cap="SAE", fig.height=8, fig.width=8, out.width="90%"}
dot_plot(safety_statistics, type="serious", base=4)
```

```{r dotplot_ae, fig.cap="Non-Serious AE", fig.height=8, fig.width=8, out.width="90%"}
dot_plot(safety_statistics, type="non_serious", base=4)
```

If you want to modify, then access the two elements `$left.panel` and `$right.panel` to modify as standard `ggplot` objects. The `print` and `plot` methods glue them back together within the framework of the [patchwork](https://patchwork.data-imaginist.com/) package. Or you can dissect, edit, save, and use however you want.

```{r dotplot_edit, fig.height=8, fig.width=8, out.width="90%"}
fig <- dot_plot(safety_statistics, type="non_serious", base=4)
fig$left.panel <- fig$left.panel + ggplot2::labs(title="Absolute Risk")
fig
```

Should you wish to save to a file, then using the workflow below will work, using a graphics device such as, `png`, `jpeg`, `pdf`, `svg`. You will need to explicitly call the `print(fig)` function, and just `fig` on its own may not work.

```{r dotplot_save, eval=FALSE}
temp <- tempfile(fileext=".png")
png(filename = temp)
print(fig)
dev.off()
```

Further filtering and refinements to the labels may be provided using the `relative_risk` and `order_filter` functions. See help pages for more details.

0 comments on commit 3004654

Please sign in to comment.