-
Notifications
You must be signed in to change notification settings - Fork 2
/
themed_xaringan.Rmd
291 lines (209 loc) · 7.3 KB
/
themed_xaringan.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
---
title: "{ggconsort} - Toward building programmatic CONSORT diagrams in ggplot"
author: "Peter DR Higgins"
institute: "University of Michigan"
date: "2020/08/27"
output:
xaringan::moon_reader:
lib_dir: libs
css: xaringan-themer.css
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
library(xaringan)
library(xaringanthemer)
library(tidyverse)
source('create_status_tables.R')
```
```{r xaringan-themer, include=FALSE, warning=FALSE}
library(xaringanthemer)
style_duo_accent(
primary_color = "#292077" ,
secondary_color = "#8c54fc",
inverse_header_color = "#FFFFFF"
)
```
class: header_background
# What Are CONSORT diagrams?
### To promote transparency
In clinical trials, a CONSORT diagram shows the flow of participants from screening to analysis, while identifying and providing reasons for dropout or exclusion of participants at each step along the way.
![image](images/consort5arm_upa_uc.png)
---
class: header_background
# CONSORT diagrams
### Endorsed by most medical journals
.pull-left[
CONSORT = Consolidated Standards of Reporting Trials, developed by the CONSORT group, <http://www.consort-statement.org>, which started in 1993 to improve the quality of reporting of clinical trials.
]
.pull-right[
![image](images/CONSORT_template.png)
]
---
class: header_background
# An Artisanal Product
- CONSORT diagrams are now commonly used to report RCTs,<br>
but the template provided does not provide:
+ An underlying data structure, or
+ Best practices for building a diagram.
- The CONSORT diagram has become an artisanal product
+ Usually built by counting categories and
+ Copy/pasting results into templates.
- This leads to frequent errors in which the participant numbers don't add up.
- Most CONSORT diagrams are built from templates in
+ MS Word
+ Powerpoint, or
+ Adobe Illustrator.
- Note: there is a way to do this in SAS, with PROC SGPLOT
https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3149-2019.pdf
---
class: header_background, center
# {ggconsort} as an Idea
```{r, echo=FALSE, out.width="100%"}
knitr::include_graphics("images/rpubs_consort.png")
```
- https://rpubs.com/phiggins/461686
---
class: header_background
# Limitations
- This is still being done by hand, not reproducible
- I would like to make this programmatic
---
class: header_background
# {ggconsort} Goal: One Function
## draw_consort(status_table)
- any # of arms from 2 to 8 (or more)
- can control text wrap with `\n` or str_wrap(25)
- fits boxes to height, width of text
- creates lines and arrows to box center edges
- sets standard vertical and horizontal spacing between boxes, lines
- creates plot area sufficient to contain diagram
- then draws the diagram
---
class: header_background
# What is the Underlying Data Structure?
---
class: header_background
# Two Parts to CONSORT - N = 1 and N = n_arms
![image](images/Presentation1/Slide1.png)
---
class: header_background
# Naming and labeling components
![image](images/Presentation1/Slide2.png)
---
class: header_background
# Data Model: the Status Table
- One row per candidate participant, with their status at each step of the study
- Includes both:
+ randomized participants, and
+ candidate participants excluded (aka screen failures)
- (optional) column - studyid
- column `randomized` - Yes or NA
- column `exc_reason` - Text or NA
- column `arm` - Text per Arm or NA
- column `recieved_int` - Yes or NA
- column `dnr_int_reason` - Text or NA
- column `completed` - Yes or NA
- column `discontinued_reason` - Text or NA
- column `analyzed` - Yes or NA
- column `not_an_reason` - Text or NA
---
class: header_background
# Example Data - status_tables
- I built examples from actual clinical trials, numbered by # of arms
+ status2 - (Indomethacin vs Placebo)
+ status3 - (Aza vs IFX vs Aza/IFX combo)
+ status4 - (Placebo vs 5,10,15 mg tofacitinib)
+ status5 - (Placebo vs 4 doses of upadacitinib)
+ status8 - (8 interventions to increase uptake of flu vaccine)
---
class: header_background
# Glimpse of a Status Table
```{r, echo=FALSE}
glimpse(status2)
```
---
class: header_background
# Conceptual Model for Drawing CONSORT
- Build a top_tbl
![image](images/top_tbl.png)
- Then ggplot
```{r, eval=FALSE, echo=TRUE}
ggplot(top_tbl) +
geom_rect(aes(xmin = xmin, xmax=xmax, ymin=ymin, ymax=ymax)) +
geom_text(aes(x=xcenter, y = ycenter, label= label)) +
geom_segment(aes(x=x, xend=xend, y=y, yend=yend))
```
---
class: header_background
# Conceptual Model
- Build a bottom_n_tbl
- Shown here are just the assignment rows
![image](images/bottom_n_tbl.png)
- Then ggplot
```{r, eval=FALSE, echo=TRUE}
ggplot(bottom_n_tbl) +
geom_rect(aes(xmin = xmin, xmax=xmax, ymin=ymin, ymax=ymax)) +
geom_text(aes(x=xcenter, y = ycenter, label= label)) +
geom_segment(aes(x=x, xend=xend, y=y, yend=yend))
```
---
class: header_background
# Helper Functions in Place
- count_arms, list_arms
- for individual labels: filter and count #, glue to text for each box
- for complex labels: count exclusions, build mini-table, add total row, move to top line, collapse to text string with newlines
+ Does not handle zeroes well (no discontinuations)
- build top_tbl
- (_in progress_) build bottom_n_tbl
---
class: header_background
# Problems
- I don't know enough about ggplot internals
+ Hard to consistently convert char_width to x values on ggplot
+ Hard to consistently convert lines to y values on ggplot
+ Adding more rows of boxes = self-adjusting ggplot size shrinks previous boxes - labels no longer fit
- Would this be easier with the {ggtext} package?
+ but lacks return values for box location
- Actually building a whole package with tests, roxygen documentation, pkgdown website
+ This is way beyond what I have ever done
+ There is no way I could maintain a package alone.
- Help needed
---
class: header_background
# Aspiration: Package / Repository
.center[
https://github.com/higgi13425/ggconsort
]
```{r, echo=FALSE, out.width="80%", fig.align='center'}
knitr::include_graphics("images/github-ggconsort.png")
```
---
class: header_background
# The Aspirational Hex Sticker
```{r, echo=FALSE, out.width="53%", fig.cap="Because if you have a cool hex sticker you are committed", fig.align='center'}
knitr::include_graphics("images/hex-ggconsort.png")
```
---
class: header_background
# Help (Collaborators) Needed!
- This is just a proof of concept, **not** a proper package.
### Aspirational Goals
- Tests, especially on status_table input
+ e.g. Actual software dev by people who know what they are doing
- Can this work across Graphics Devices (not just MacOS/RStudio)?
- Helper functions to take standard data formats and make a status_table from:
+ SDTM data format?
+ ADaM data format?
- Ability to work with data in the wild (1/0, "No"/Yes", "Completed")
+ Not just carefully curated data
- Useful vignettes
- A proper package (roxygen2) and a useful {pkgdown} site
- More options, customization - currently like the original Model T.
+ You can have any font or spacing that you want, as long as it is the default.
---
class: inverse, center, middle
# Thanks for your Help!