forked from STAT545-UBC/STAT545-UBC-original-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
530 lines (457 loc) · 28 KB
/
index.html
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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<meta name="author" content="Shaun Jackman" />
<meta name="dcterms.date" content="2014-11-03" />
<title>Automating Data-analysis Pipelines</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="reveal.js/css/reveal.min.css"/>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; }
code > span.dt { color: #902000; }
code > span.dv { color: #40a070; }
code > span.bn { color: #40a070; }
code > span.fl { color: #40a070; }
code > span.ch { color: #4070a0; }
code > span.st { color: #4070a0; }
code > span.co { color: #60a0b0; font-style: italic; }
code > span.ot { color: #007020; }
code > span.al { color: #ff0000; font-weight: bold; }
code > span.fu { color: #06287e; }
code > span.er { color: #ff0000; font-weight: bold; }
</style>
<link rel="stylesheet" href="reveal.js/css/theme/simple.css" id="theme">
<style type="text/css">.reveal pre{font-size: 0.7em;}</style>
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'reveal.js/css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="reveal.js/lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="automating-data-analysis-pipelines" class="slide level2">
<h1>Automating Data-analysis Pipelines</h1>
<p>UBC <a href="http://stat545-ubc.github.io/">STAT 545A</a>/STAT 547M<br />2014-11-03<br /><a href="http://sjackman.ca">Shaun Jackman</a> <a href="http://twitter.com/sjackman">@sjackman</a><br /><a href="http://www.stat.ubc.ca/~jenny/">Jenny Bryan</a> <a href="https://twitter.com/JennyBryan">@JennyBryan</a><br /><a href="http://creativecommons.org/licenses/by/4.0/"><img src="images/cc-by.png" alt="Creative Commons Attribution License" /></a></p>
</section>
<section><section id="pipelines-automation-dependencies" class="titleslide slide level1"><h1>Pipelines Automation Dependencies</h1></section><section id="automation" class="slide level2">
<h1>Automation</h1>
<ul>
<li>using <a href="http://tryr.codeschool.com/">R</a></li>
<li>using the <a href="http://en.wikipedia.org/wiki/Shell_script">shell</a> and <a href="https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rscript.html">Rscript</a></li>
<li>using <a href="http://en.wikipedia.org/wiki/Make_(software)">make</a></li>
</ul>
</section><section class="slide level2">
<p><a href="http://xkcd.com/1319/"><img src="http://imgs.xkcd.com/comics/automation.png" alt="Automation" /></a></p>
<p>'Automating' comes from the roots 'auto-' meaning 'self-', and 'mating', meaning 'screwing'.</p>
</section></section>
<section><section id="pipelines" class="titleslide slide level1"><h1>Pipelines</h1></section><section id="a-pipeline" class="slide level2">
<h1>A pipeline</h1>
<p>breaks up a monolithic make-all-the-things script into discrete, manageable chunks.</p>
</section><section id="each-stage-of-the-pipeline" class="slide level2">
<h1>Each stage of the pipeline</h1>
<p>… defines its input and its outputs.<br />… does <em>not</em> modify its inputs, so it is <em>idempotent</em>.</p>
<p>Rerunning a stage of the pipeline<br />produces the same results as the previous run.</p>
</section><section id="advantage-1" class="slide level2">
<h1>Advantage #1</h1>
<p>When you modify one stage of the pipeline,<br />you don't have to rerun the entire pipeline.</p>
<p>You only rerun the downstream, dependent stages.</p>
</section><section id="advantage-2" class="slide level2">
<h1>Advantage #2</h1>
<p>Divide up work amongst a group by assigning to each person stages of the pipeline design.</p>
</section><section id="advantage-3" class="slide level2">
<h1>Advantage #3</h1>
<p>You can draw pretty pictures of your pipeline,<br />because a pipeline is a graph.</p>
</section><section class="slide level2">
<p><a href="images/pipeline.gv"><img src="images/pipeline.png" alt="01_justR" /></a><br /><a href="01_justR"><em>01_justR</em></a></p>
</section></section>
<section><section id="automation-1" class="titleslide slide level1"><h1>Automation</h1></section><section id="automate-a-pipeline" class="slide level2">
<h1>Automate a pipeline</h1>
<p>… to reproduce previous results.<br />… to recreate results deleted by fat fingers.<br />… to rerun the pipeline with updated software.<br />… to run the same pipeline on a new data set.</p>
</section><section id="tools" class="slide level2">
<h1>Tools</h1>
<ul>
<li><a href="http://tryr.codeschool.com/">R</a></li>
<li>the <a href="http://en.wikipedia.org/wiki/Shell_script">shell</a> and <a href="https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rscript.html">Rscript</a></li>
<li><a href="http://en.wikipedia.org/wiki/Make_(software)">make</a></li>
</ul>
</section><section id="r" class="slide level2">
<h1>R</h1>
<pre class="sourceCode r"><code class="sourceCode r"><span class="co">#!/usr/bin/env Rscript</span>
<span class="kw">source</span>(<span class="st">"00_downloadData.R"</span>)
<span class="kw">source</span>(<span class="st">"01_filterReorder.R"</span>)
<span class="kw">source</span>(<span class="st">"02_aggregatePlot.R"</span>)</code></pre>
<div class="fragment">
<ul>
<li>Shows in what order to run the scripts.</li>
<li>You can resume the pipeline from the middle.</li>
</ul>
</div>
</section><section id="shell-and-rscript" class="slide level2">
<h1>Shell and Rscript</h1>
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="co">#!/bin/sh</span>
<span class="kw">set</span> <span class="kw">-eux</span>
<span class="kw">Rscript</span> 00_downloadData.R
<span class="kw">Rscript</span> 01_filterReorder.R
<span class="kw">Rscript</span> 02_aggregatePlot.R</code></pre>
<div class="fragment">
<p>Allows you to easily run your pipeline from the shell.</p>
</div>
<div class="fragment">
<table>
<thead>
<tr class="header">
<th style="text-align: left;">Option</th>
<th style="text-align: left;">Effect</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>set -e</code></td>
<td style="text-align: left;">Stop at the first error</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>set -u</code></td>
<td style="text-align: left;">Undefined variables are an error</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>set -x</code></td>
<td style="text-align: left;">Print each command as it is run</td>
</tr>
</tbody>
</table>
</div>
</section><section id="mix-r-scripts-with-other-tools" class="slide level2">
<h1>Mix R scripts with other tools</h1>
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="co">#!/bin/sh</span>
<span class="kw">set</span> <span class="kw">-eux</span>
<span class="kw">curl</span> -L http://bit.ly/lotr_raw-tsv <span class="kw">></span>lotr_raw.tsv
<span class="kw">Rscript</span> 01_filterReorder.R
<span class="kw">Rscript</span> 02_aggregatePlot.R</code></pre>
<div class="fragment">
<p>R is a good tool, but not always the best tool for the job.</p>
<p>Not sacrilege, but the principal tenet of a polyglot.</p>
</div>
</section><section id="makefile" class="slide level2">
<h1>Makefile</h1>
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="co">#!/usr/bin/make -f</span>
<span class="dv">lotr_raw.tsv:</span>
curl -L http://bit.ly/lotr_raw-tsv >lotr_raw.tsv
<span class="dv">lotr_clean.tsv:</span><span class="dt"> 01_filterReorder.R lotr_raw.tsv</span>
Rscript 01_filterReorder.R
<span class="dv">totalWordsByFilmRace.tsv:</span><span class="dt"> 02_aggregatePlot.R lotr_clean.tsv</span>
Rscript 02_aggregatePlot.R</code></pre>
<div class="fragment">
<p>A Makefile gives both the commands<br /><em>and their dependencies</em>.</p>
</div>
</section><section id="make-is-beautiful" class="slide level2">
<h1>Make is beautiful</h1>
<p>Tell Make how to create one type of file from another<br />and which files you want to create.</p>
<div class="fragment">
<p>Make looks at which files you have<br />and figures out how to create the files that you want.</p>
</div>
</section></section>
<section><section id="dependency-graph" class="titleslide slide level1"><h1>Dependency graph</h1></section><section id="a-pipeline-is-a-graph" class="slide level2">
<h1>A pipeline is a graph</h1>
<p>Scripts and data files are vertices of the graph.</p>
<p>Dependencies between stages are edges of the graph.</p>
</section><section class="slide level2">
<p>Both scripts and data files are shown.</p>
<p><a href="images/pipeline.gv"><img src="images/pipeline.png" alt="01_justR" /></a><br /><a href="01_justR"><em>01_justR</em></a></p>
</section><section class="slide level2">
<ul>
<li>Only dependencies between scripts are shown.</li>
<li>Data files are not shown.</li>
<li>Run the scripts in <em>topographical</em> order.</li>
</ul>
<p><a href="https://sites.google.com/site/stat540diffmethleuk/code"><img src="images/stat540diffmethleuk.png" alt="STAT 540 Differential Methylation in Leukemia" /></a><br /><em>STAT 540 Differential Methylation in Leukemia</em></p>
</section><section id="order-of-dependencies" class="slide level2">
<h1>Order of dependencies</h1>
<p>A shell script gives <em>one</em> order in which you can successfully run the pipeline.</p>
<div class="fragment">
<p>Unless the pipeline is completely linear, there are likely other such orders.</p>
</div>
</section><section class="slide level2">
<p><a href="https://sites.google.com/site/stat540diffmethleuk/code"><img src="images/stat540diffmethleuk.png" alt="STAT 540 Differential Methylation in Leukemia" /></a></p>
<p>A different order of commands may be more convenient, but without information of the dependencies, you're stuck with the given order.</p>
</section></section>
<section><section id="a-reproducible-manuscript" class="titleslide slide level1"><h1>A reproducible manuscript</h1></section><section id="one-makefile" class="slide level2">
<h1>One Makefile</h1>
<ul>
<li>Downloads the data</li>
<li>Runs the command-line programs</li>
<li>Performs the statistical analyses using <a href="http://tryr.codeschool.com/">R</a></li>
<li>and Generates the TSV tables</li>
<li>Renders the figures using <a href="http://ggplot2.org/">ggplot2</a></li>
<li>Renders the supplementary material using <a href="http://rmarkdown.rstudio.com/">RMarkdown</a></li>
<li>Renders the manuscript using <a href="http://johnmacfarlane.net/pandoc/">Pandoc</a></li>
</ul>
</section><section id="turns-this" class="slide level2">
<h1>Turns this</h1>
<figure>
<img src="images/UniqTag-md.png" alt="UniqTag Markdown" /><figcaption><a href="https://github.com/sjackman/uniqtag-paper/blob/master/UniqTag.md">UniqTag Markdown</a></figcaption>
</figure>
</section><section id="into-this" class="slide level2">
<h1>Into this</h1>
<figure>
<img src="images/UniqTag-pdf.png" alt="UniqTag PDF" /><figcaption><a href="http://biorxiv.org/content/early/2014/08/01/007583.full.pdf">UniqTag PDF</a></figcaption>
</figure>
</section></section>
<section><section id="workflow" class="titleslide slide level1"><h1>Workflow</h1></section><section class="slide level2">
<p><a href="http://kieranhealy.org/blog/archives/2014/01/23/plain-text/">Plain Text, Papers, Pandoc</a> by <a href="http://kieranhealy.org/">Kieran Healy</a></p>
<figure>
<img src="images/workflow-rmd-md.png" alt="I promise this is less insane than it appears" /><figcaption>I promise this is less insane than it appears</figcaption>
</figure>
</section><section id="markdown-for-the-manuscript" class="slide level2">
<h1>Markdown for the manuscript</h1>
<p><a href="https://help.github.com/articles/markdown-basics/">Markdown</a> is a plain-text typesetting language</p>
<pre class="sourceCode markdown"><code class="sourceCode markdown">A header
========
A list:
+ <span class="fl">This text is *italic*</span>
<span class="fl">+ This text is **bold**</span></code></pre>
<h3 id="a-header">A header</h3>
<p>A list:</p>
<ul>
<li>This text is <em>italic</em></li>
<li>This text is <strong>bold</strong></li>
</ul>
</section><section id="rmarkdown" class="slide level2">
<h1>RMarkdown</h1>
<ul>
<li><a href="http://rmarkdown.rstudio.com/">RMarkdown</a> interleaves prose with <a href="http://tryr.codeschool.com/">R</a> code
<ul>
<li>to aggregate and summarize the data</li>
<li>to generate tables</li>
<li>to render figures using <a href="http://ggplot2.org/">ggplot2</a></li>
</ul></li>
<li><a href="http://rmarkdown.rstudio.com/">RMarkdown</a> is ideal for supplementary material</li>
</ul>
</section><section id="rmarkdown-example" class="slide level2">
<h1>RMarkdown example</h1>
<pre><code>The Sum of 1 + 1
================
The sum of 1 + 1 is calculated as follows.
```{r}
1 + 1
```
![*Fig. 1*: A graphical view of 1 + 1](figure.png)</code></pre>
<p><a href="article/article.Rmd"><em>article.Rmd</em></a></p>
</section><section id="the-sum-of-1-1" class="slide level2">
<h1>The Sum of 1 + 1</h1>
<p>The sum of 1 + 1 is calculated as follows.</p>
<pre class="sourceCode r"><code class="sourceCode r"><span class="dv">1</span> +<span class="st"> </span><span class="dv">1</span></code></pre>
<pre><code>## [1] 2</code></pre>
<figure>
<img src="article/figure.png" alt="Fig. 1: A graphical view of 1 + 1" /><figcaption><em>Fig. 1</em>: A graphical view of 1 + 1</figcaption>
</figure>
</section><section class="slide level2">
<p><a href="images/article.gv"><img src="images/article.png" alt="article.gv" /></a></p>
<p>Dependencies of <a href="article/Makefile"><em>article/Makefile</em></a></p>
</section><section id="render-html" class="slide level2">
<h1>Render HTML</h1>
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">%.md:</span><span class="dt"> %.Rmd</span>
Rscript -e <span class="st">'knitr::knit("</span><span class="ch">$<</span><span class="st">", "</span><span class="ch">$@</span><span class="st">")'</span>
<span class="dv">%.html:</span><span class="dt"> %.md</span>
pandoc -s -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">%.html:</span><span class="dt"> %.Rmd</span>
Rscript -e <span class="st">'rmarkdown::render("</span><span class="ch">$<</span><span class="st">")'</span>
<span class="dv">article.html:</span><span class="dt"> figure.png</span>
<span class="dv">%.png:</span><span class="dt"> %.gv</span>
dot -Tpng <span class="ch">$<</span> ><span class="ch">$@</span></code></pre>
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">make</span> article.html</code></pre>
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">dot</span> -Tpng figure.gv <span class="kw">></span>figure.png
<span class="kw">Rscript</span> -e <span class="st">'rmarkdown::render("article.Rmd")'</span></code></pre>
</section><section id="knit-markdown" class="slide level2">
<h1>Knit Markdown</h1>
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">%.md:</span><span class="dt"> %.Rmd</span>
Rscript -e <span class="st">'knitr::knit("</span><span class="ch">$<</span><span class="st">", "</span><span class="ch">$@</span><span class="st">")'</span>
<span class="dv">%.html:</span><span class="dt"> %.md</span>
pandoc -s -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">%.html:</span><span class="dt"> %.Rmd</span>
Rscript -e <span class="st">'rmarkdown::render("</span><span class="ch">$<</span><span class="st">")'</span>
<span class="dv">article.html:</span><span class="dt"> figure.png</span>
<span class="dv">%.png:</span><span class="dt"> %.gv</span>
dot -Tpng <span class="ch">$<</span> ><span class="ch">$@</span></code></pre>
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">make</span> article.md article.html</code></pre>
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">Rscript</span> -e <span class="st">'knitr::knit("article.Rmd", "article.md")'</span>
<span class="kw">dot</span> -Tpng figure.gv <span class="kw">></span>figure.png
<span class="kw">pandoc</span> -s -o article.html article.md</code></pre>
</section><section id="pandoc" class="slide level2">
<h1>Pandoc</h1>
<p><a href="http://johnmacfarlane.net/pandoc/">Pandoc</a> renders attractive documents and slides<br />from plain-text typesetting formats</p>
<p>It converts between every format known (just about)</p>
<ul>
<li>Markdown</li>
<li>HTML</li>
<li>LaTeX</li>
<li>PDF</li>
<li>ODT and docx (yes, really)</li>
</ul>
</section></section>
<section><section id="evolving-a-makefile" class="titleslide slide level1"><h1>Evolving a Makefile</h1></section><section class="slide level2">
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="co">#!/bin/sh</span>
<span class="kw">set</span> <span class="kw">-eux</span>
<span class="kw">dot</span> -Tpng -o figure.png figure.gv
<span class="kw">Rscript</span> -e <span class="st">'knitr::knit("article.Rmd")'</span>
<span class="kw">pandoc</span> -s -o article.html article.md</code></pre>
<p>Shell script</p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span>
dot -Tpng -o figure.png figure.gv
Rscript -e <span class="st">'knitr::knit("article.Rmd")'</span>
pandoc -s -o article.html article.md</code></pre>
<p>First Makefile</p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span><span class="dt"> article.html</span>
<span class="dv">article.html:</span>
dot -Tpng -o figure.png figure.gv
Rscript -e <span class="st">'knitr::knit("article.Rmd")'</span>
pandoc -s -o article.html article.md</code></pre>
<p>Add a rule to build <code>article.html</code></p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span><span class="dt"> article.html</span>
<span class="dv">article.html:</span><span class="dt"> article.Rmd</span>
dot -Tpng -o figure.png figure.gv
Rscript -e <span class="st">'knitr::knit("article.Rmd")'</span>
pandoc -s -o article.html article.md</code></pre>
<p><code>article.html</code> depends on <code>article.Rmd</code></p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span><span class="dt"> article.html</span>
<span class="dv">figure.png:</span><span class="dt"> figure.gv</span>
dot -Tpng -o figure.png figure.gv
<span class="dv">article.md:</span><span class="dt"> article.Rmd</span>
Rscript -e <span class="st">'knitr::knit("article.Rmd")'</span>
<span class="dv">article.html:</span><span class="dt"> article.md figure.png</span>
pandoc -s -o article.html article.md</code></pre>
<p>Split one rule into three</p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span><span class="dt"> article.html</span>
<span class="dv">figure.png:</span><span class="dt"> figure.gv</span>
dot -Tpng -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">article.md:</span><span class="dt"> article.Rmd</span>
Rscript -e <span class="st">'knitr::knit("</span><span class="ch">$<</span><span class="st">", "</span><span class="ch">$@</span><span class="st">")'</span>
<span class="dv">article.html:</span><span class="dt"> article.md figure.png</span>
pandoc -s -o <span class="ch">$@</span> <span class="ch">$<</span></code></pre>
<p>Use the variables <code>$<</code> and <code>$@</code> for the input and output file</p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span><span class="dt"> article.html</span>
<span class="dv">%.png:</span><span class="dt"> %.gv</span>
dot -Tpng -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">%.md:</span><span class="dt"> %.Rmd</span>
Rscript -e <span class="st">'knitr::knit("</span><span class="ch">$<</span><span class="st">", "</span><span class="ch">$@</span><span class="st">")'</span>
<span class="dv">article.html:</span><span class="dt"> article.md figure.png</span>
pandoc -s -o <span class="ch">$@</span> <span class="ch">$<</span></code></pre>
<p>Use pattern rules. The <code>%</code> matches any string</p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span><span class="dt"> article.html</span>
<span class="dv">%.png:</span><span class="dt"> %.gv</span>
dot -Tpng -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">%.md:</span><span class="dt"> %.Rmd</span>
Rscript -e <span class="st">'knitr::knit("</span><span class="ch">$<</span><span class="st">", "</span><span class="ch">$@</span><span class="st">")'</span>
<span class="dv">%.html:</span><span class="dt"> %.md</span>
pandoc -s -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">article.html:</span><span class="dt"> figure.png</span></code></pre>
<p><code>article.html</code> also depends on <code>figure.png</code></p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span><span class="dt"> article.html</span>
<span class="dv">clean:</span>
rm -f article.md article.html figure.png
<span class="dv">%.png:</span><span class="dt"> %.gv</span>
dot -Tpng -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">%.md:</span><span class="dt"> %.Rmd</span>
Rscript -e <span class="st">'knitr::knit("</span><span class="ch">$<</span><span class="st">", "</span><span class="ch">$@</span><span class="st">")'</span>
<span class="dv">%.html:</span><span class="dt"> %.md</span>
pandoc -s -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">article.html:</span><span class="dt"> figure.png</span></code></pre>
<p>Add the target named <code>clean</code></p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span><span class="dt"> article.html</span>
<span class="dv">clean:</span>
rm -f article.md article.html figure.png
<span class="ot">.PHONY:</span><span class="dt"> all clean</span>
<span class="ot">.DELETE_ON_ERROR:</span>
<span class="ot">.SECONDARY:</span>
<span class="dv">%.png:</span><span class="dt"> %.gv</span>
dot -Tpng -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">%.md:</span><span class="dt"> %.Rmd</span>
Rscript -e <span class="st">'knitr::knit("</span><span class="ch">$<</span><span class="st">", "</span><span class="ch">$@</span><span class="st">")'</span>
<span class="dv">%.html:</span><span class="dt"> %.md</span>
pandoc -s -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="dv">article.html:</span><span class="dt"> figure.png</span></code></pre>
<p>Add <code>.PHONY</code>, <code>.DELETE_ON_ERROR</code> and <code>.SECONDARY</code></p>
</section><section class="slide level2">
<pre class="sourceCode makefile"><code class="sourceCode makefile"><span class="dv">all:</span><span class="dt"> article.html</span>
<span class="dv">clean:</span>
rm -f article.md article.html figure.png
<span class="ot">.PHONY:</span><span class="dt"> all clean</span>
<span class="ot">.DELETE_ON_ERROR:</span>
<span class="ot">.SECONDARY:</span>
<span class="co"># Render a GraphViz file</span>
<span class="dv">%.png:</span><span class="dt"> %.gv</span>
dot -Tpng -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="co"># Knit a RMarkdown document</span>
<span class="dv">%.md:</span><span class="dt"> %.Rmd</span>
Rscript -e <span class="st">'knitr::knit("</span><span class="ch">$<</span><span class="st">", "</span><span class="ch">$@</span><span class="st">")'</span>
<span class="co"># Render a Markdown document to HTML</span>
<span class="dv">%.html:</span><span class="dt"> %.md</span>
pandoc -s -o <span class="ch">$@</span> <span class="ch">$<</span>
<span class="co"># Dependencies on figures</span>
<span class="dv">article.html:</span><span class="dt"> figure.png</span></code></pre>
</section></section>
<section><section id="fin" class="titleslide slide level1"><h1>fin</h1></section><section id="links" class="slide level2">
<h1>Links</h1>
<p><a href="http://stat545-ubc.github.io/">STAT 545A</a> | <a href="http://xkcd.com/1319/">xkcd automation</a><br /><a href="http://tryr.codeschool.com/">R</a> | <a href="https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rscript.html">Rscript</a> | <a href="http://en.wikipedia.org/wiki/Shell_script">shell</a> | <a href="http://en.wikipedia.org/wiki/Make_(software)">make</a><br /><a href="https://help.github.com/articles/markdown-basics/">Markdown</a> | <a href="http://rmarkdown.rstudio.com/">RMarkdown</a> | <a href="http://johnmacfarlane.net/pandoc/">Pandoc</a> | <a href="http://ggplot2.org/">ggplot2</a><br /><a href="http://kieranhealy.org/blog/archives/2014/01/23/plain-text/">Plain Text, Papers, Pandoc</a><br /><a href="https://sites.google.com/site/stat540diffmethleuk/code">STAT 540 Differential Methylation in Leukemia</a></p>
<p><a href="http://twitter.com/sjackman">@sjackman</a> | <a href="https://github.com/sjackman">github.com/sjackman</a> | <a href="http://sjackman.ca">sjackman.ca</a></p>
</section><section id="shaun-jackman" class="slide level2">
<h1>Shaun Jackman</h1>
<p><a href="http://bcgsc.ca">Genome Sciences Centre</a>, BC Cancer Agency<br />Vancouver, Canada<br /><a href="http://twitter.com/sjackman">@sjackman</a><br /><a href="https://github.com/sjackman">github.com/sjackman</a><br /><a href="http://sjackman.ca">sjackman.ca</a></p>
<figure>
<img src="images/sjackman.jpg" />
</figure>
</section></section>
</div>
</div>
<script src="reveal.js/lib/js/head.min.js"></script>
<script src="reveal.js/js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
slideNumber: true,
theme: 'sky', // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
// { src: 'reveal.js/plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; }, }
// { src: 'reveal.js/plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }
]});
</script>
</body>
</html>