Reproducible Research
About this course
A reproducible project can be re-run, understood and shared by other people. It is also easier for you to return to months later.
This course introduces the practical habits that make this possible. It covers project structure, documentation, Quarto reports, virtual environments and sharing data.
The course takes about two hours. Each topic has a hands-on activity (and sometimes a short demo): we do a part together, you try something on your own, and then we look at the answer. The notes are written so you can also work through the course on your own.
The course contains examples for both Python and R, with opportunities to include your own code and examples.
The examples use the Palmer penguins dataset: measurements of three penguin species near Palmer Station, Antarctica. It is small and easy to understand, so we can focus on how the project is organised rather than on the analysis.
Prerequisites
- Some experience of using code to analyse data (e.g. Python, R, Julia)
- Have Quarto installed, for the activity where you turn one document into several formats. RStudio and Positron include it. Otherwise install it (version 1.4 or later)
- Download the example folder (use the button on this page)
Learning outcomes
By the end of this course, you will be able to:
- Organise a project into raw data, processed data, code and outputs, and explain why raw data is never edited.
- Describe what a good README and data dictionary contain, and why they matter, particularly for Data Management Plans.
- Explain why Quarto helps reproducibility, and make HTML, PDF and Word versions of a report from one document.
- Explain why environments matter, and say what someone needs in order to re-run your project on another computer.
- Apply these practices to your own coding projects, using the R and Python examples as a starting point.
- Choose one practice to start using on your own project, and know where to find out more.
Course outline
| Section | Topic | Time |
|---|---|---|
| 1 | Project structures | 25 min |
| 2 | Documentation & Quarto | 45 min |
| 3 | Virtual environments | 30 min |
| 4 | Your first step | 15 min |
Every section has slides and an activity for you, and sections 2 and 3 also have a short demo from the instructor. If there is time, there is also an optional extra on sharing your data (Q-FAIR), which is covered in full in the notes. After the course, there is an optional capstone exercise that puts it all together: you build a project from scratch, give it an environment and write a report with code, in R or Python.
References & Citations
The penguins data used throughout the course comes from:
- Horst, A. M., Hill, A. P. and Gorman, K. B. (2020). palmerpenguins: Palmer Archipelago (Antarctica) penguin data. R package version 0.1.0. doi:10.5281/zenodo.3960218
- Gorman, K. B., Williams, T. D. and Fraser, W. R. (2014). Ecological sexual dimorphism and environmental variability within a community of Antarctic penguins (genus Pygoscelis). PLoS ONE, 9(3), e90081. doi:10.1371/journal.pone.0090081