-
Notifications
You must be signed in to change notification settings - Fork 1
/
presentation.Rmd
375 lines (264 loc) · 8.73 KB
/
presentation.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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
---
title: Adopting open source practices<br/>for better science
author: |
Pierce Edmiston
<pedmiston@wisc.edu>
[sapir.psych.wisc.edu](http://sapir.psych.wisc.edu)
[github.com/pedmiston](https://github.com/pedmiston)
output:
xaringan::moon_reader:
css: ["default", "static/font.css"]
---
# Outline
Open source practices that make for more reproducible science:
1. Version control
2. Dynamic documents
3. Building from source
Conclusion: It's worth it!
```{r, include=FALSE}
library(knitr)
opts_chunk$set(echo = FALSE, message = FALSE)
source("presentation.R")
```
---
# Why I care about reproducibility
1. I want my research to be reproducible.
2. I want to attract collaborators.
???
I want my research to be reproducible by other people and by myself. This means no undocumented steps! Document things in code for maximum reproducibility.
I want the bar for getting involved in one of my projects to be as low as possible.
---
# The reproducibility crisis
<small>Open Science Collaboration. (2015). Estimating the reproducibility of psychological science. _Science_.</small>
```{r reproducibility-crisis}
figs("osc_2015_science")("fig3", draw = TRUE)
```
???
My interest in reproducibility is really more of an obsession or a paranoia. I worry that my own research is not going to replicate.
---
### Why isn't psychological research more reproducible?
- Simmons, Nelson, & Simonsohn. (2011). False-positive psychology. _Psychological Science_.
- Gelman & Loken. (2013). The garden of forking paths. Unpublished manuscript.
- Palmeri. (2016). Psychology is in crisis over whether it's in crisis. _WIRED_.
- Ioannidis. (2005). Why most published research findings are false. _PLOS Medicine_.
- Edmiston. (now). Publications are not answers to research questions. Unpublished thoughts.
???
The first reason is that there is a lot of flexibility in how we analyze behavioral data. The second reason is that we tend to look until we find something. But of course there are plenty of people who disagree whether the state of psychology research is as bad as some say. And actually these problems with publication bias and the file drawer effect are much more widespread than just psychology. Personally I think the culprit is the idea that publications are definitive answers to research questions.
---
# Reproducibility is a big problem
<small>Munafò et al. (2017). A manifesto for reproducible science. _Nature_.</small>
```{r threats-to-reproducibility}
figs("munafo_etal_2017_nature")("fig1", draw = TRUE)
```
---
# Steps toward reproducible science
- Blind data analysts to experiment conditions.
- Improve statistics education (adapted for web).
- Hire methodological consultants.
- Seek collaboration for scalability.
---
# Why I think open source is the answer
Compare these two goals of reproducibility in science and in open source:
1. Fellow researchers should be able to reproduce my work.
2. Anyone should be able to use and contribute to this project.
```{r open-source-science}
DiagrammeR::grViz("
digraph {
label = 'Open source science';
labelloc = t;
fontname = 'Helvetica-bold';
node[shape = none, fontname = Helvetica];
Reproducibility -> {Confidence, Collaboration};
}", height = 200)
```
???
Open source is the answer because the goal of reproducibility in open source communities is actually a loftier goal than in the scientific community.
---
class: center
# Version control
```{r version-control-in-the-wild, fig.width=12}
grid.arrange(img("undo-button"), img("wiki-revisions"), img("git-log"), nrow = 1)
```
---
# Pick your poison
- **git**
- mercurial
- subversion
- gitless
---
class: center
# Tools for climbing
```{r climbing-tools}
img("climbing-tools", ext = ".jpg", draw = TRUE)
```
???
There are a number of ways to think about version control. One way is to think about it as a safety net, that no matter what you do, you can always roll back to what it was before. This is the power of the "undo" button. However, this doesn't really get at why I think version control is such a powerful tool. A better analogy is to think about version control as a tool for climbing. The picture is of tools used by rock climbers called "nuts" that you jam into a crack in the rock, and then you can use it as a hold. This is how I think about version control. It definitely has the effect of keeping you safer, but it also allows you to climb in places you otherwise wouldn't be able to.
---
class: center
# Conquer clutter
```{r cluttered-folder}
img("cluttered-folder", draw = TRUE)
```
---
class: center
# Forks and branches
```{r git-tree}
DiagrammeR::grViz("
digraph {
rankdir = LR;
bgcolor = transparent;
node[label = ''; style = 'filled'; fillcolor = '#8DA0CB'];
t2;
b0 -> b1 -> b2 -> b3[style = invis];
m0 -> m1 -> m2 -> m3;
t0 -> t1 -> t2[style = invis];
m1 -> t2 -> m3[constraint = false];
m2 -> b3[constraint = false];
b0, b1, b2, t0, t1[style = invis];
}", height = 200)
```
---
# Submodules
.pull-left[
```
# key
parent_repo/
├── child_repo_1 # submodule 1
└── child_repo_2 # submodule 2
# example 1
talk or publication/
├── research_project_1
└── research_project_2
```
]
.pull-right[
```
# example 2
meta-analysis/
├── research_project_1
├── ...
└── research_project_n
# example 3
big-project/
├── *web-app* -> also installed on web server
├── *lab-exp* -> also installed on lab computers
├── *r-pkg* -> installed by anyone who wants the data
├── conference
└── journal
```
]
---
# Version control's dirty little secret
(It only really works on plaintext files.)
```{r excel-panic, fig.cap="Excel panic. Well, did you make changes or didn't you??"}
img("excel-panic", draw = TRUE)
```
---
# The good news
Once you're working in plaintext, you can do lots of cool things.
- Full power of VCS (merge, blame, etc).
- Use free and open source tools (Unix).
- **Write dynamic documents.**
---
# Dynamic documents
- Philosophy: DRY, Literate Programming
- Tools: Sphinx, Jupyter, Knitr, Pandoc
---
# Philosophy
.pull-left[
## Don't Repeat Yourself (DRY)
> Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
Hunt & Thomas. (1999). _The pragmatic programmer_.
]
.pull-right[
## Literate programming (LP)
* Intermingle prose and code for better understanding of the program.
* The explanation of a program does not need to resemble the program structure.
Knuth, Donald E. (1983). _Literate programming_.
]
---
# Sphinx
**Python documentation generation**
* Python standard library: [json](https://docs.python.org/3/library/json.html)
* Third party packages: [requests](http://docs.python-requests.org/en/master/api/#requests.request)
---
# Project Jupyter
**Web-based, language-agnostic lab notebook.**
```{r jupyter-preview}
img("jupyter-preview", draw = TRUE)
```
---
# Knitr
**Elegant, flexible and fast dynamic report generation with R.**
Participants in condition A outperformed participants in
condition B, `report_model_results(mod, param = "condition")`.
```{r knitr-side-by-side}
grid.arrange(img("knitr-source"), img("knitr-output"), nrow = 1)
```
---
# Dynamic documents in practice
- Handouts
- Homework
- Supplemental materials
- Conference proceedings
- Journal papers
---
# A litmus test for reproducible research
Can you build the published paper without the original data?
### Building from source
- Open source tools
- No undocumented steps
- Centralized control
---
# Identical environments
.pull-left[
## Open source tools
- python
- R (S)
- Octave (Matlab)
## Virtual environments
- Enthought
- Anaconda
]
.pull-right[
## Cloud computing
- Amazon Web Services
- Open Stack
## Infrastructure-as-code
- ansible
- terraform
]
---
# Examples of "Building from source"
1. Kaggle leaderboards
2. Totems game
---
# Does it work?
<small>McKiernan, _et al._ (2016). How open science helps researchers succeed. _eLife_.</small>
```{r open-access-citations}
figs("mckiernan_etal_2016_elife")("fig1", draw = TRUE)
```
---
# Cultural ratchets
.pull-left[
## Many species have elements of culture
- chimps (Whiten et al., 1999)
- whales (Garland et al., 2011)
- crows (Hunt & Gray, 2003)
]
.pull-right[
## Only humans exhibit **cumulative** culture
- ratchet effect (Tomasello et al., 1993)
- evolutionary process (Basalla, 1988)
- transmission fidelity (Lewis & Laland, 2012)
]
---
# Adoption open source practices for better science
Pierce Edmiston (<pedmiston@wisc.edu>)
[github.com/pedmiston/reproducible-research](https://github.com/pedmiston/reproducible-research)
[bit.ly/reproducible-research-refs](http://bit.ly/reproducible-research-refs)
Open source practices that make for more reproducible science:
1. Version control
2. Dynamic documents
3. Building from source
Conclusion: It's worth it!