forked from tompiers/LSI_Rstudio_course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLSI_Rstudio_course_presentation.Rmd
834 lines (610 loc) · 25.5 KB
/
LSI_Rstudio_course_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
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
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
---
title: "Rstudio in Data Science and Paper Writing"
subtitle: "⚔<br/>presentation powered by xaringan"
author: "Gaspar Jekely"
institute: "RStudio course - LSI <br> 25-26th April 2022"
output:
xaringan::moon_reader:
css: addons/xaringan-themer-GJ.css
nature:
ratio: "16:9"
beforeInit: ["addons/macros.js"]
highlightStyle: github
highlightLines: true
countIncrementalSlides: true
slideNumberFormat: "%current%"
navigation:
scroll: true
---
```{r xaringanExtra, echo=FALSE}
xaringanExtra::use_xaringan_extra(c("tile_view", "animate_css", "tachyons"))
#to load xaringanExtra in a single call
```
```{r xaringan-editable, echo=FALSE}
xaringanExtra::use_editable(expires = 1)
#makes slides editable to make a component of your slides editable, use the .can-edit[] class.
```
```{r xaringan-scribble, echo=FALSE}
xaringanExtra::use_scribble()
#to draw on slides
```
```{r xaringan-panelset, echo=FALSE}
xaringanExtra::use_panelset()
#to add panels to slides with
#.panel[.panel-name[NAME]
#...content...
#]
```
#Why do we need open science
* ### Reproducibility crisis
* ### Only a small fraction of research data is available
* ### An even smaller fraction of the code is available (physicists are notoriously bad in sharing)
* ### Open access, if exists, is very expensive and maintains the profit of legacy publishers
* ### Scholarly literature is antiquated, dysfunctional and rewards hype over quality and integrity
* ### Scholarly work flows use non-professional, error-prone, closed-source software (MS, Adobe, Prism etc.) that makes sharing, integration, automation and collaboration difficult
* ### The final product of years of research is often only a single pdf file (1990s) behind a paywall
* ### Data, code and text are not searchable, reuseable, discoverable, shareable
---
class: center
#Most data sets collected by scientists are not available
<img src=assets/img/Data_publication_Pyramide.png width=850>
---
# Most scientists use software developed for accounting
</br>
## Scientists rename human genes to stop Microsoft Excel from misreading them as dates
https://www.theverge.com/2020/8/6/21355674/human-genes-rename-microsoft-excel-misreading-dates
</br>
<img src=https://media1.tenor.com/images/f6362876996697b6a6f554b2ac3d3013/tenor.gif?itemid=10488408 width=300>
---
#Gene name errors are widespread in the scientific literature
</br>
<img src=https://media.springernature.com/full/springer-static/image/art%3A10.1186%2Fs13059-016-1044-7/MediaObjects/13059_2016_1044_Fig1_HTML.gif?as=webp width = 1500>
.red[*"The spreadsheet software Microsoft Excel, when used with default settings, is known to convert gene names to dates and floating-point numbers."*]
.footnote[___
[Ziemann et al. (2016)](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-016-1044-7)]
---
#Code is very often not shared or not shared stably
<br><br><br><br><br><br><br><br><br><br>
* ### *We assess the effectiveness of such a policy by (i) requesting data and code from authors and (ii) attempting replication of the published findings. We chose a random sample of 204 scientific papers published in the journal Science []. We found that we were able to obtain artifacts from 44% of our sample and were able to reproduce the findings for 26%.*
* .red[*"When you approach a PI for the source codes and raw data, you better explain who you are, whom you work for, why you need the data and what you are going to do with it."*]
* .green[*"I have to say that this is a very unusual request without any explanation! Please ask your supervisor to send me an email with a detailed, and I mean detailed, explanation."*]
* .orange[*"The data files remains our property and are not deposited for free access. Please, let me know the purpose you want to get the file and we will see how we can help you."*]
* .purple[*"We do not typically share our internal data or code with people outside our collaboration."*]
* ### .red[sigh...]
<img src=assets/img/Stodden_PNAS.png style="position:absolute; width:44%; left:5%; top:15%">
.footnote[___
[Stodden et al. (2018) ](https://doi.org/10.1073/pnas.1708290115)]
---
#What this course is about: what you can do to be open
* ### tools and approaches for transparent and open publishing
* ### a paper is not only text and figures, but also data and code
* ### all should be shared for reproducibility and openness
* ### otherwise it is not published (physicists, take note!)
* ### we will use Rstudio to learn a comprehensive paper-writing pipeline
* ### code, tabulated data, figures, text, references, supplements all in one place
* ### collaborative working and sharing via github (or other public repository)
* ### the figures are linked to their underlying data and code to generate them
* ### efficient version control
* ### faster, more transparent and reproducible workflow
* ### no software license is needed (no MS, no Adobe, no Matlab)
* ### once you master the approach I advocate, you don't want to go back...
<img src=assets/img/Wormie.jpg style="position:absolute; width:38%; left:61.2%; top:26.9%">
---
class: left
#Installing packages
* install the **tidyverse** package
```{r eval=FALSE, tidy=FALSE}
install.packages("tidyverse")
```
* ### then load the package
```{r eval=TRUE, tidy=FALSE}
library(tidyverse)
library(xaringan)
```
* ### open the R script code/Course_exercises.R with the example code
* ### you can source several packages and functions, listed in one file
```{r eval=TRUE, tidy=FALSE, fig.height=5}
source("code/packages_and_functions.R")
```
---
class: left
# Your workspace in R
* ### Recreate, rather than save workspace, save your code and data, not workspace
<br>
<img src=assets/img/rstudio-workspace.png width=55%>
---
#A note about working directories
```{r eval=FALSE}
getwd()
```
* ### You should never use absolute paths in your scripts, because they hinder sharing: no one else will have exactly the same directory configuration as you.
* ### R experts keep all the files associated with a project together — input data, R scripts, analytical results, figures. This is such a wise and common practice that RStudio has built-in support for this via projects.
* ### If you create a new Rproject, your working dir will in general be where you save the new project
* ### Whenever you refer to a file with a relative path it will look for it in your wd.
---
# Project management
* ### Use folders relative to your main .Rproject file (e.g. My_next_paper.Rproject)
* ### Use a consistent directory structure to store code, data, text, figures, supplements, etc.
* ### Can be ensured if you always use the same template
* ### We will use https://github.com/JekelyLab/LSI_Rstudio_course
* ### Go to github and clone the project to your account
* ### Go to RStudio -> new project -> version control -> git -> git URL
* ### select local dir and pull the project with all directories to your computer
* ### let's check the template
* ### rename new_project_template.Rproject to 'my favourite file name'
---
#Always save and share your computer environment and packages
```{r echo=TRUE, eval=TRUE}
#save session info and Rstudio version info for reproducibility
writeLines(capture.output(sessionInfo()), "code/sessionInfo.txt")
writeLines(capture.output(rstudioapi::versionInfo()), "code/versionInfo.txt")
```
---
#Data plotting with ggplot2
* ### ggplot2 is part of tidyverse and loads when you load tidyverse
* ### very versatile and extendable data visualisation package
* ### as input, you need a data.frame or tibble
```{r eval = TRUE, echo = TRUE, fig.height = 4}
iris %>% #we use a pipe to input the data to ggplot
ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + #we use + to add different elements of the plot
geom_point() +
geom_smooth() +
theme_minimal()
```
---
```{r fig.height=6, echo=TRUE}
ggplot(data=diamonds, mapping=aes(x = carat, y = price, color = cut))+
geom_point()
```
---
```{r fig.height=6, echo=TRUE}
ggplot(data=diamonds) +
geom_histogram(aes(x=carat), binwidth=0.1) +
geom_freqpoly(mapping=aes(x=carat, color=cut), binwidth=0.1)
```
---
# Shapes
<img src=assets/img/shapes-1.png width=35%>
```{r eval = TRUE, echo = TRUE, fig.height = 3}
iris %>% #we use a pipe to input the data to ggplot
ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + #we use + to add different elements of the plot
geom_point(aes(shape=Species, size=Species)) +
scale_shape_manual(values=c(3, 18, 22)) +
scale_size_manual(values=c(1, 2, 3)) +
geom_smooth() +
theme_minimal()
```
---
#Aesthetics, plot types and themes
* ### need to define 'aesthetics', which variable goes to x, y axes, to color, size, line thickness etc.
* ### need to select plot type (geom_... boxplot, line, points etc.)
* ### need to define 'theme' such as axis thickness, fonts, ticks, borders etc.
```{r eval = TRUE, echo = TRUE, fig.height = 4}
iris %>%
ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_boxplot(notch = TRUE) +
theme_minimal()
```
---
#Faceting
* ### facets are panels of multi-panel plots
* ### we can split our data into panels based on a discrete variable, e.g., species
```{r eval = TRUE, echo = TRUE, fig.height = 4}
iris %>%
ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_minimal() +
facet_wrap(vars(Species))
```
---
#Esquisse 'ggplot2 builder' add-on
* ### helps to generate the code for ggplot
* ### select the data frame to plot
* ### map aesthetics to variables in the gui
* ### define themes, facets, fonts etc.
* ### useful as a 'cheat-sheet' and for practicing
* ### not all options available to configure the plot
```{r eval = TRUE, echo = TRUE}
library(esquisse)
help("esquisse")
```
---
#Changing the labels
```{r eval = TRUE, echo = TRUE, fig.height = 4}
iris %>%
ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_minimal() +
facet_wrap(vars(Species)) +
labs(x = "x axis label", y = "y axis label") +
theme_minimal() +
theme(legend.position = "left")
ggsave("pictures/iris_test.png", bg = "white")
```
---
#Tidy your data
* ### Tabular data is a set of values, each associated with a variable and an observation.
* ### Tabular data is tidy if each value is placed in its own “cell”, each variable in its own column, and each observation in its own row.
* ### “Tidy datasets are all alike, but every messy dataset is messy in its own way.” –– Hadley Wickham
<img src=assets/img/heart-TEM.png width=35%>
---
#Tidy your data
__There are three interrelated rules which make a dataset tidy:__
* ### Each variable must have its own column.
* ### Each observation must have its own row.
* ### Each value must have its own cell.
<img src=assets/img/tidy-1.png width=60%>
---
#Tidy your data
```{r, echo=FALSE}
knitr::kable(head(iris), format = 'html')
```
---
#Tibbles == Tidy data
```{r eval = FALSE}
vignette("tibble")
```
##__Why should I care?__
* ### after reading your data, you should always try to convert them into a tibble
* ### downstream analyses (plotting, mutating, sharing etc.) will be a lot easier
* ### data coming from other software, collaborators etc. are often 'messy'
* ### it is worth investing the time in tidying the data first
* ### sometimes it is tricky, as we will see...
---
#A simple tibble
```{r eval = TRUE, echo = TRUE, fig.height=4}
tb <- tibble(variable_1 = c(1,2,3,4,5,6),
variable_2 = c(2,3,4,5,6,7),
variable_3 = c("a", "a", "a", "b", "b", "c"))
tb %>%
ggplot(aes(x = variable_1, y = variable_2, color = variable_3)) +
geom_point()
```
---
#A more realistic example - 1
```{r eval = TRUE, echo = TRUE, fig.height = 3}
tb <- tibble(genotype = c("wt","wt","wt","mut","mut","mut"),
eye_color = c("red", "red", "red", "white", "white", "white"),
eye_size = c(35, 39, 33, 12, 14, 11))
tb
tb %>%
ggplot(aes(x = genotype, y = eye_size, color = eye_color)) +
geom_point()
```
---
#A more realistic example - 2
```{r eval = TRUE, echo = TRUE, fig.height = 2}
tb <- tibble(inhibitor = c("DMSO","DMSO","DMSO","drug1","drug1","drug1","drug1","drug1","drug1"),
activity = c(32,34,23,67,65,57, 56,64,62),
replicate = c("rep1", "rep1", "rep1", "rep1", "rep1", "rep1", "rep2", "rep2", "rep2"))
tb
tb %>%
ggplot(aes(x = inhibitor, y = activity, color = replicate)) +
geom_point()
```
---
#Example dataset from from Barnali
```{r eval = TRUE, echo = TRUE}
Syn_data <- read_csv("data/a-Syn-Data.csv")
Syn_data
```
---
#Need to do some tidying...
* ### Tidying messy data is hard and requires parctice
* ### Read more here: https://r4ds.had.co.nz/tibbles.html
```{r eval = TRUE, echo = TRUE}
#use piping %>% and pivot_longer to convert into long form
Syn_tb <- Syn_data %>%
rename_with(~ gsub("_", "-", .x, fixed = TRUE)) %>%
rename_with(~ gsub("...", "_", .x, fixed = TRUE)) %>%
pivot_longer(matches("aSyn"),
names_to = c("condition", "sample"), names_sep = "_",
values_to = "fluorescence") %>%
group_by(condition)
Syn_tb
```
---
#Let's plot the tidied tibble
```{r eval = TRUE, echo = TRUE, fig.height = 5}
Syn_tb %>%
ggplot(aes(x = Time, y = fluorescence, color = condition)) +
geom_smooth() +
theme_minimal()
ggsave("pictures/synuclein_data.png", bg = "white")
```
---
#Example data from Kei
```{r eval = TRUE, echo = TRUE}
Ca <- read_csv("data/WTvsNOS11_cPRC_INNOS.csv")
Ca
```
---
#Example data from Kei - first let's rename some variables
```{r eval = TRUE, echo = TRUE}
(Ca <- Ca %>%
rename(genotype = phenotype, intensity = intesnsity)
)
```
---
#Example data from Kei
```{r eval = TRUE, echo = TRUE, fig.height = 5}
Ca %>%
ggplot(aes(x = frame, y = intensity, color = genotype,
group = genotype)) +
geom_smooth(level = 0.99, size = 0.5, span = 0.1, method = "loess") +
geom_line(aes(group = sample), size = 0.5, alpha = 0.1) +
theme_classic() +
facet_wrap(vars(cell))
ggsave("pictures/Kei_NOS_data.png", bg = "white")
```
---
#Example data from Tom - not raw data
```{r eval=TRUE, echo=TRUE}
filo <- read_csv("data/Tom_filopodia_analyses.csv")
filo
```
---
#Example data from Tom - raw data
```{r eval=TRUE, echo=TRUE}
filo_raw <- read_csv("data/spine activity_raw.csv")
filo_raw
```
---
#Example data from Tom - let's tidy it up
```{r eval=TRUE, echo=TRUE}
filo_raw_tb_int <- filo_raw %>%
rename_with(~ gsub("SR_R", "SR-R", .x, fixed = TRUE)) %>%
rename_with(~ gsub("_Area!!", "-Area!!", .x, fixed = TRUE)) %>%
rename_with(~ gsub("Time::Relative Time!!R", "time", .x, fixed = TRUE)) %>%
rename_with(~ gsub("_IntensityMean!!", "-IntensityMean!!", .x, fixed = TRUE)) %>%
pivot_longer(matches("Channel"),
names_to = c("channel", "region", "measurement"),
names_sep = "_|::",
values_to = "value") %>%
filter(measurement == 'IntensityMean')
filo_raw_tb_int
```
---
#Let's plot the tidied tibble
```{r eval = TRUE, echo = TRUE, fig.height = 5}
filo_raw_tb_int %>%
ggplot(aes(x = time, y = value, color = region)) +
geom_line(aes(group = region)) +
theme_minimal()
ggsave("pictures/Tom_filo_data.png", bg = "white")
```
---
#Assemble multi-panel figures with cowplot and patchwork
### read the images with readPNG from pictures/ folder
``` {r echo = TRUE, eval = TRUE}
img1 <- readPNG("pictures/Platynereis_SEM_inverted_nolabel.png")
img2 <- readPNG("pictures/synuclein_data.png")
img3 <- readPNG("pictures/Kei_NOS_data.png")
img4 <- readPNG("pictures/Tom_filo_data.png")
img5 <- readPNG("pictures/MC3cover-200um.png")
```
<img src="pictures/MC3cover-200um.png" width=22%>
---
#Assemble multi-panel figures with cowplot and patchwork
### convert to image panel and add text labels with cowplot::draw_image and draw_label
``` {r echo = TRUE, eval = TRUE, fig.height = 4}
panelA <- cowplot::ggdraw() + cowplot::draw_image(img1, scale = 1) +
draw_label("Platynereis larva", x = 0.35, y = 0.99, fontfamily = "sans", fontface = "plain",
color = "black", size = 11, angle = 0, lineheight = 0.9, alpha = 1) +
draw_label(expression(paste("50 ", mu, "m")), x = 0.27, y = 0.05, fontfamily = "sans", fontface = "plain",
color = "black", size = 10, angle = 0, lineheight = 0.9, alpha = 1) +
draw_label("head", x = 0.5, y = 0.85, fontfamily = "sans", fontface = "plain",
color = "black", size = 9, angle = 0, lineheight = 0.9, alpha = 1) +
draw_label("sg0", x = 0.52, y = 0.67, fontfamily = "sans", fontface = "plain",
color = "black", size = 9, angle = 0, lineheight = 0.9, alpha = 1)
panelA
```
---
.scrollable[
#Make panels B-D
``` {r echo = TRUE, eval = TRUE}
panelB <- ggdraw() + draw_image(img2)
panelC <- ggdraw() + draw_image(img3)
panelD <- ggdraw() + draw_image(img4)
panelB
panelC
panelD
```
]
---
.scrollable[
#Adding scale bars
* ### you could add the scale bar directly on the image e.g., in ImageJ
* ### your scale bars may be misaligned and of varying thickness
* ### you can use cowplot::draw_line
* ### the x positions of the start and end of the line are defined as % of the panel width
* ### if you know the width of the image (can add it to file name), it is easy to calculate the size of the scale bar
``` {r echo = TRUE, eval = TRUE}
panelE <- ggdraw() + draw_image(img5, scale = 1) +
draw_line(x = c(0.1, 0.3), y = c(0.07, 0.07), color = "black", size = 0.75)
panelE
```
]
---
#Assemble figure with patchwork
* ### First, we define the layout with textual representation (cool and intuitive!)
```{r eval=TRUE, echo=TRUE}
layout <- "ABCDE"
Figure1 <- panelA + panelB + panelC + panelD + panelE +
patchwork::plot_layout(design = layout, heights = c(1, 1)) +
patchwork::plot_annotation(tag_levels = "A") &
ggplot2::theme(plot.tag = element_text(size = 12, face='plain'))
ggsave("figures/Figure1.png", limitsize = FALSE,
units = c("px"), Figure1, width = 4000, height = 800, bg = "white")
```
<img src=figures/Figure1.png width=100%>
* .red[#### Note that the two scale bars are not aligned and do not have the same thickness, because one was added outside R, the other one in R - try to add scale bars in R for nicer alignment!]
---
#Change the layout of the panels
* ### Change the textual layout definition
* ### We also need to change the dimensions of the exported figure
```{r eval=TRUE, echo=TRUE}
layout <-
"AABC
AADE"
Figure1 <- panelA + panelB + panelC + panelD + panelE +
patchwork::plot_layout(design = layout, heights = c(1, 1)) +
patchwork::plot_annotation(tag_levels = "a") &
ggplot2::theme(plot.tag = element_text(size = 12, face='bold'))
ggsave("figures/Figure1_layout2.png", limitsize = FALSE,
units = c("px"), Figure1, width = 3200, height = 1600, bg = "white")
```
<img src=figures/Figure1_layout2.png width=47%>
---
#Collaborative code and paper writing with Rstudio and GitHub
* ### GitHub www.github.com is a platform for software development and version control
* ### owned by Microsoft since 2018
* ### developers can have public and private repositories
* ### can share repositories privately with collaborators
* ### integrates well with Rstudio
<img src=assets/img/original.png style="position:absolute; width:11%; left:85%; top:15%">
---
#The workflow
* ### Create a new project or clone a template project on GitHub
* ### In Rstudio, New Project -> Version control -> add GitHub repo URL and save locally
* ### Change the code
* ### You can 'commit' and then 'push' changes to GitHub
* ### Your collaborators can be added on GitHub
* ### Collaborators can 'pull' to their own computer and 'push' their own changes
* ### If two developers push changes to the same repo, this can lead to conflict
* ### This can be managed by starting new 'branches'
* ### Branches can be 'merged' to the original 'master' branch
* ### A collaborator can issue a 'pull request' to merge their branch to the master
<img src=assets/img/original.png style="position:absolute; width:11%; left:85%; top:15%">
---
class: left
#Paper writing in Rmarkdown
.pull-left[
* ### Powerful and versatile text editing in Markdown
* ### Easy insertion and formatting of references
* ### Supports equations, tables
* ### Directly insert your figures generated by your code
* ### Can 'knit' into html, pdf or doc formats
<br>
### -> Open text/Manuscript.Rmd]
.pull-right[<video controls width=55%>
<source src=assets/movies/Bryozoan_colony3-1.webm>
</video>
<br>
** A bryozoan colony**
]
---
# The Xaringan Package to make presenations with RStudio
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
```
* ### presentations will be in html format
* ### compatible with all computers with a browser
* ### live links e.g., to references [Randel et al. (2014) ](https://elifesciences.org/articles/02730) (to share with students etc.)
* ### insertion of figures or videos directly from the web
* ### you can save a lot of disk space by reducing redundancies
* ### consistent styling of slides defined by a .css style file (addons/xaringan-themer-GJ.css)
* ### easy to move towards building websites
<img src=https://upload.wikimedia.org/wikipedia/commons/b/be/Sharingan_triple.svg style="position:absolute; width:18%; left:75%; top:20%">
.footnote[___
Image credit: [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Sharingan_triple.svg)]
---
background-image: url(https://upload.wikimedia.org/wikipedia/commons/b/be/Sharingan_triple.svg)
class: center, middle
# xaringan
### /ʃaː.'riŋ.ɡan/
---
class: inverse, center, middle
# Get Started
---
# Hello World
Install the **xaringan** package from [Github](https://github.com/yihui/xaringan):
```{r eval=FALSE, tidy=FALSE}
remotes::install_github("yihui/xaringan")
```
--
You are recommended to use the [RStudio IDE](https://www.rstudio.com/products/rstudio/), but you do not have to.
- Create a new R Markdown document from the menu `File -> New File -> R Markdown -> From Template -> Ninja Presentation`;<sup>1</sup>
--
- Click the `Knit` button to compile it;
--
- or use the [RStudio Addin](https://rstudio.github.io/rstudioaddins/)<sup>2</sup> "Infinite Moon Reader" to live preview the slides (every time you update and save the Rmd document, the slides will be automatically reloaded in RStudio Viewer.
.footnote[
[1] 中文用户请看[这份教程](https://slides.yihui.org/xaringan/zh-CN.html)
[2] See [#2](https://github.com/yihui/xaringan/issues/2) if you do not see the template or addin in RStudio.
]
---
.can-edit[
# A few notes on managing presentations
* ### you can use these examples as templates to get started
* ### put your images to assets/img, your videos to assets/movies
* ### use relative path
* ### you can reuse the same images and movies for many presentations
* ### I keep my presentations related to one topic (e.g. science talks, teaching etc.) in one folder and they share the assets and addons
* ### if you want to save space, you can delete the html and the folder created by xaringan upon knitting (these can easily be recreated from the .Rmd and the assets and addons)
* ### for videos, best is to use .webm format (you can convert from other formats with ffmpeg) (ffmpeg -i input.mp4 -f webm output.webm)
* ### preview slides in the viewer
* ### use the Infinite moon reader addon for immediate update of slides
* ### present in the browser (for me Chrome works best)
* ### you can make editable slides (\.can-edit[...])
]
* ### xaringanExtra for extra functions https://pkg.garrickadenbuie.com/xaringanExtra/#/README?id=xaringanextra
---
class: center
background-image: url(assets/img/Platy_SEM.png)
background-position: 10% 58%
background-size: 70%
## _Platynereis dumerilii_
<img src=assets/img/Platy_adult.png style="position:absolute; width:14%; left:71.2%; top:10.9%">
.left[<br><br><br><br><br><br><br><br><br><br><br>
- breeding .blue[culture], full life-cycle
- .cyan[embryos] daily, year round
- .red[genome] sequence
- .orange[microinjection]
- .green[transgenesis]
- neuron-specific .purple[promoters] and .green[antibodies]
- .red[knock-out] lines
- cellular resolution .blue[expression profiling]
- neuronal .purple[connectome]
- whole-body neuronal .orange[activity imaging]
- whole-animal .cyan[pharmacology] by bath application 😎]
---
class: center
## _Platynereis dumerilii_
.pull-left[#### Day 0
<video controls width=65%>
<source src=assets/movies/spawning_Fischer.webm>
</video>
<br>
**Spawning**
<br>
movie by Albrecht Fischer]
.pull-right[#### Day 1-6
<video controls width=100%>
<source src=assets/movies/3d_Larvae_swimming.webm>
</video>
<br>
**Synchronously developing larvae**]
---
class: center
background-color: white
## Phototactic turning - maximally sensitive to cyan light
.pull-left[<video controls width="80%">
<source src=assets/movies/light_stimulation_eye.webm>
</video>]
.pull-right[<img src=assets/img/phototaxis_action.png width="90%">]
.pull-right[<img src=assets/img/spectrum.png width="60%">]
.footnote[___
[Randel et al. (2014) ](https://elifesciences.org/articles/02730)   [Gühmann et al. (2015)](https://doi.org/10.1016/j.cub.2015.07.017)]
---
#How do I write letters with Rmarkdown
* ### if you use linux add to your ~/.bash_aliases file:
* ### alias open='xdg-open'
* ### then add an alias to create a copy of a template letter with the name given and open it in the default progmam for .Rmd (should be Rstudio)
* ### alias letter='newletter(){ cp ~/Correspondence/letter_LSI_template.Rmd ~/Correspondence/$1; open ~/Correspondence/$1; }; newletter'
* ### start editing in Rstudio, and knit into a pdf
* ### you can add your signature and the LSI header or other logos from an assets folder (/templates in my case)
* ### pull down terminal (1 key) then type 'letter Cover_letter_eLife.Rmd'
---
#Please fill in the feedback form!!
##https://forms.office.com/r/WRwVRVP3pu