-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.qmd
447 lines (314 loc) · 8.5 KB
/
index.qmd
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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
---
title: "Sharpening the Axe"
subtitle: "Reproducible Data Analysis at the Speed of Thought"
abstract: |
This talk is all about workflows and tools.
We will learn about `Quarto`, the next iteration of Rmarkdown
and integrate it into our workflow.
We will see the `targets` R package in action to help us
keep track of complicated analysis pipelines and produce
verifiably reproducible results.
Lastly, we will venture into uncharted territory to find
out first hand, why it always pays off to learn the intricacies
of your tools with a live demonstration of using `Quarto` and
`targets` in `Neovim`.
date: December 19, 2023
author: Jannik Buhr
institute: Heidelberg Institute for Theoretical Studies
format:
revealjs:
# embed-resources: false
title-slide-attributes:
data-background-image: ./img/hand-axe.png
data-background-size: contain
data-background-position: left
auto-animate-unmatched: false
code-copy: true
citations-hover: true
reference-links: false
progress: true
slide-number: true
chalkboard:
buttons: true
multiplex: false
preview-links: auto
theme: [default, theme.scss]
css: ./styles.css
footer: |
<https://jmbuhr.de/2023-workflow>
bibliography: ./references.bib
nocite: ""
execute:
warning: false
eval: true
echo: true
engine: knitr
---
# Welcome
```{r}
#| echo: false
library(tidyverse)
library(palmerpenguins)
```
<html>
<script>
document.head.appendChild(Object.assign(document.createElement("link"), {rel: "icon", href: "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🦦</text></svg>"}))
</script>
</html>
## Otters have a favorite Rock 🪨
:::: {layout="[1,1]"}
![](./img/otter-hello.png)
:::{#quote}
![](./img/otter-pound.png){#otter-pound}
> "The mean number of **blows** necessary **to open a mussel** was **35.5** [...].\
> The **same stone** was frequently **retained** for several successive food items, [...]"
>
> --- @hallToolUsingBehaviorCalifornia1964
:::
::::
:::footer
Image sources: <https://en.wikipedia.org/wiki/Tool_use_by_sea_otters>, <https://en.wikipedia.org/wiki/Tool_use_by_sea_otters>
:::
## Otters have a favorite Rock 🪨
> "Give me six hours to cut down a tree and I will spend the first four sharpening the axe."
>
> --- Abraham Lincoln
![](./img/abraham-lincoln.png)
## Otters have a favorite Rock 🪨
> "Give me six minutes to open a mussel and I will spend the first four finding the perfect rock."
>
> --- ~~Abraham~~ Otterham Lincoln
![](./img/otterham-lincoln.png)
## Humans are toolmakers 🪓
![](./img/pexels-anna-urlapova-2957058.jpg){.fl width=38%}
:::{#textbox}
**Humans** don't just **use** tools.
We **shape** and **perfect** them.
:::
. . .
![](./img/hand-axe.png){.fr width=38%}
:::footer
Image sources: <https://www.pexels.com/photo/person-holding-a-stone-2957058/>, <https://en.wikipedia.org/wiki/Hand_axe>
:::
## Who am I? 🦦
:::{#jannik .fr}
![](./img/jannik.png)
:::
Hi, I'm Jannik!
Computational Biochemist at\
HITS and Heidelberg University
I use **Quantum Mechanical Simulations** to study how **Collagen** breaks under force
![](./img/helix-wide.png){width=60%}
I love building and teaching tools 🧰
:::profile
- \@jmbuhr
- [](https://github.com/jmbuhr){.bi-github}
- [](https://jmbuhr.de){.bi-house}
- [](https://mastodon.online/@jmbuhr){.bi-mastodon}
- [](https://www.youtube.com/@jmbuhr){.bi-youtube}
- [](https://www.linkedin.com/in/jmbuhr/){.bi-linkedin}
:::
{{< qrcode https://github.com/jmbuhr.de/2023-workflow qr width=124 height=124 colorDark='#1E4287' >}}
## The Tools Today 🧰
::: {.columns}
::: {.column width="30%"}
![](./img/quarto.png){width=100%}
![](./img/targets.png){width=50%}
![](./img/Neovim-logo.svg){width=100%}
:::
::: {.column width="70%"}
### Quarto
<https://quarto.org/>
Next iteration of `Rmarkdown`.
### Targets
<https://docs.ropensci.org/targets/>
R package for reproducible workflows.
### Neovim
<https://neovim.io/>
hyperextensible Vim-based text editor
:::
:::
# Warmup!
## Remember these letters
```{r}
#| echo: false
countdown::countdown(minutes = 0, seconds = 7)
```
[xfwiadcnanvrqybceawgjdczlyhlwoovxxce]{#letters}
## Remember these letters
How many of these letters do you remember?
## Remember these letters
```{r}
#| echo: false
countdown::countdown(minutes = 0, seconds = 7)
```
[The quick brown fox jumps over the lazy dog]{#letters}
## Remember these letters
Do you remember the sentence on the previous slide?
. . .
Of course you do, it's just **one** sentence!
. . .
But it has the **same number of letters** as the random letters.
## The Magic 7 ± 2
One piece of information is a **chunk**.
We can keep **7** (± 2) **chunks** in our **working memory** [@millerMagicalNumberSeven1956a].
We gain space by combining thoughts and **concepts**
Letters → Words → Sentences → Concepts
# Optimize Your Workflow
## Quarto: Structure Thoughts
:::tr
![](./img/quarto.png)
:::
<https://quarto.org/>
An open-source scientific and technical publishing system.
- Keep **thoughts, code and results** close
- Cater to different **output formats**
- web, pdf, docx, ppt ...
- Fully **reproducible**
![](./img/rstudio.png){#rstudio}
## {background-image="./img/choose.png" background-size=70% background-position=top}
|
|
|
|
|
`qmd` files are just plain text!
````
---
title: "quarto demo"
format:
html:
code-fold: true
---
## Air Quality
@fig-airquality further explores the impact of temperature on ozone level.
```{{r}}
#| label: fig-airquality
#| fig-cap: "Temperature and ozone level."
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess"
)
```
````
## Quarto: Structure Thoughts
:::tr
![](./img/quarto.png)
:::
:::sidenote
🖥️📱📰
:::
::: {.incremental}
- **Why** did I perform this operation?
- Read a detailed **explanation** of past-me right **next** to the code!
- Different and changing **output formats**?
- Just let quarto **generate** them for you!
- Could you increase the fontsize in **all your plots**?
- Sure, just **change** one number and **re-render**!
:::
. . .
> "I have a machine learning model that takes 6 hours to calculate. [...] how do I put this in a Quarto notebook?"
. . .
Well, **don't!**
## Targets: Organize Workflows
:::tr
![](./img/targets.png){width=50%}
:::
<https://docs.ropensci.org/targets/>
Function-oriented Make-like **declarative workflows** for R.
```{r}
#| echo: false
#| out-width: 90%
targets::tar_visnetwork()
```
Aim for **pure functions** that take **inputs** and produce **outputs**
without side effects.
## NeoVim: Not just for Speed!
![](./img/nvim-clean.png)
## NeoVim: Not just for Speed!
![](./img/nvim-quarto.png)
## NeoVim: Not just for Speed!
**Modal editing** allows us to **communicate** with the editor.
**Complicated operations** become one **chunk**.
**Free up resources** for the important questions.
|
|
- modes
- normal, insert, visual
- verbs
- change, delete, paste etc.
- nouns (text objects)
- word, sentence, paragraph, block, parenthesis, function etc.
- movements
- "to end of line", "to beggining of the document", "down 3 lines" etc.
# Demo
Demo Time!
![](./img/lter_penguins.png){width=80%}
::: {.aside}
Artwork by \@allisonhorst
:::
# Take Home Messages
## Take Home Messages
Keyboard shortcuts are for thoughts, not just speed ⌨️
. . .
Reproducibility and Interactivity can go hand in hand ▶️
. . .
Find your favorite rock 🪨
. . .
And sharpen the axe 🪓
. . .
Slides: <https://jmbuhr.de/2023-workflow>
{{< qrcode https://github.com/jmbuhr.de/2023-workflow qr2 width=200 height=200 colorDark='#1E4287' >}}
:::profile
- \@jmbuhr
- [](https://github.com/jmbuhr){.bi-github}
- [](https://jmbuhr.de){.bi-house}
- [](https://mastodon.online/@jmbuhr){.bi-mastodon}
- [](https://www.youtube.com/@jmbuhr){.bi-youtube}
- [](https://www.linkedin.com/in/jmbuhr/){.bi-linkedin}
:::
## References
:::{#refs}
:::
# Backup Slides
## Aside: Pure Functions
```{dot}
//| echo: false
//| fig-height: 3
digraph functions {
rankdir=LR;
node [shape=circle];
A -> B [label="f"];
B -> C [label="g"];
A -> C [label="h"];
}
```
$$
g \circ f = h\
$$
::: {.columns}
::: {.column width=""}
**pure**
```{r}
#| eval: false
f = function(data, cutoff) {
data |>
filter(x < cutoff) |>
mutate(x = x * pi)
}
```
:::
::: {.column width=""}
vs. **Side Effects**
```{r}
#| eval: false
f_prime = function(cutoff) {
data <<- data |>
filter(x < cutoff) |>
mutate(x = x * pi)
}
```
:::
:::