Overview
In order to document the code and results from a bioinformatics workflow you’ll be introduced to R Markdown and Knitr, and will use these tools to wrap up all your code and outputs (figures, tables, etc) together in a dyanmic document that can be placed in your lab notebook or published as a supplementary file in your manuscript. Reproducing an analysis requires more than just code. You need the original raw data, access to the appropriate programming languages, and application specific packages (and often specific versions of these packages). This poses a major impediment to reproducibility, even for researchers with a background in bioinformatics. To address this challenge, you’ll learn how to ‘containerize’ your data, scripts and software, making it easy to share and rerun an entire analysis with the push of a button.
Learning objectives
- Discuss the basic building blocks for assembling a figure
- Understand the basics of Rmarkdown and dynamic documents
- Learn how to construct an Rmarkdown doc using ‘essential’ code chunks from the course.
- make a flexdashboard the incorporates graphics and code
- Learn how to make your research analyses reproducible
- Create a reproducible package environment with renv
- Share your project via GitHub and git
- Understand how to streamline code using custom R functions.
Code
Rmarkdown_template.Rmd - a skeletal template that you can fill out with the code ‘essentials’ that we covered in class.
Rmarkdown_essentials.Rmd - same template as above, but already filled in with essentials
flexdashboard_essentials.Rmd - a different style of Rmarkdown that puts the focus on creating a dashboard of graphics. Particularly powerful when combined with the interactive graphs we produced during the course.
Lecture videos
Part 1 – Building blocks for making a good figure
Part 2 - Introduction to markdown
Part 3 - Constructing an Rmarkdown document that compiles to HTML or PDF
Part 4 - Reproducibility via the renv package
Part 5 - Keeping your code clean via custom functions
Reading
lab post on Knitr by Karl Broman
Happy Git and GitHub with RStudio - Jenny Bryan and team walk through every step of how to install git, connect to GitHub and access version control from within RStudio.
There’s a lot of reading material for how to get started making functions and packages. Beyond the extensive and very well written book on building R packages and excellent documentation for the usethis package, you may also want to check out some great lab posts on making R packages (here, here, here, and here).
Other examples of markdown in action
Supplementary code files from some of our recent papers:
Make your own CV in markdown - uses the Vitae and Scholar packages in R. Here’s mine on github
This course website! - Each page on the course website is just a simple markdown document.
My lab website is just a bunch of markdown files served from github (repo here)