Reproducible data science

Organise · Track · Record · Automate · Publish

Jens Wiesehahn

One change, many consequences

What happens if one value changes at the very start?

A branching data pipeline from field plot data to figures, paper, web map and other subprojects

The same pipeline with every step downstream of the field data highlighted in pink

Reproducibility is a spectrum

Same data + same code → same result?

Not all-or-nothing. Every step helps:

Where is what? What does it mean? → Organise & document

What changed, when, and why? → Version control

Will it still run elsewhere? → Record the environment

What do I rerun, in which order? → Automate

Can others find, reuse and cite it? → Publish

Cartoon: a monster judge in the reproducibility court, an R Markdown document as exhibit A

Artwork by Allison Horst, CC-BY 4.0

1 · Organise

One project, one folder

Which file is the current one?

my-project/
├── plots.csv
├── plots_final.csv
├── plots_final_v3_corrected.csv
├── analysis.R
├── analysis_NEW.R
├── analysis_NEW_2.R
├── map.png
└── map_old.png

One project, one folder

Which file is the current one?

diversa-plots/
├── README.md
├── data-raw/   # original
│   └── plots_field_2025.csv
├── data/       # from scripts
├── R/
│   ├── 01_clean_plots.R
│   ├── 02_export.R
│   └── 03_site_vars.R
├── output/     # results
└── _targets.R

Sketch: raw data kept raw, organised wrangling, open analyses, reproducible outputs, backed up with version control

Artwork by Allison Horst, CC-BY 4.0

Raw data stays untouched

How do you correct an error in raw data?

Correct in code, not in the file.

R/01_clean_plots.R
plots <- read.csv("data-raw/plots_field_2025.csv")

# Plot 17 relocated: original site too steep for measurements.
# Re-measured 2026-05-12, see field protocol 42.
plots[plots$plot_id == 17, c("x", "y")] <- c(562520, 5813295)

write.csv(plots, "data/plots.csv", row.names = FALSE)

Document for future you

Would a new colleague understand your project?

Document at every level

project README
data data dictionary
code comments: why, not what
changes commit messages


Template & guide: makeareadme.com

Two monsters reading a climbing guide book with existing routes, warnings and notes

Artwork by Allison Horst for Openscapes, CC-BY 4.0

Describe your data

What does x mean here, and what is NA?

column description type unit allowed values missing
plot_id plot identifier integer – unique –
x, y plot centre number m, EPSG:25832 – NA
forest_type dominant tree species text – beech, spruce, oak, pine NA
management management status text – managed, unmanaged NA


A data dictionary answers questions before they are asked.

Relative paths, not absolute

Does your code run on a colleague’s computer?

C:/Users/me/Documents/
  DIVERSA/final/
  plots_final_v3_corrected.csv

A cartoon of a cracked glass cube looking frustrated with casts on its arm and leg, with bandaids on it, containing setwd, looks on at a metal riveted cube labeled R Proj holding a skateboard looking sympathetic, and a smaller cube with a helmet on labeled here doing a trick on a skateboard.

Artwork by Allison Horst, CC-BY 4.0

Relative paths, not absolute

Does your code run on a colleague’s computer?

data/plots.csv
  • paths start at the project folder
  • open the project as a whole: RStudio project, VS Code folder, …
  • works on every computer, in any language

A cartoon of a cracked glass cube looking frustrated with casts on its arm and leg, with bandaids on it, containing setwd, looks on at a metal riveted cube labeled R Proj holding a skateboard looking sympathetic, and a smaller cube with a helmet on labeled here doing a trick on a skateboard.

Artwork by Allison Horst, CC-BY 4.0

2 · Track

Why git?

Which version did I send to the other subproject?

history · undo · compare · why

Two climbing panels: with version control a clear route with commits, without it a tangle of analysis_final_final.xls files

Artwork by Allison Horst for Openscapes, CC-BY 4.0

A commit is a save point with a message

What changed, when, and why?

a3f9c21  Move plot 17: too steep
7be01d4  Fix species codes
1c2e8f0  Add plot sites 2025


You decide when to save and what to say.

A climbing monster falls but is caught by the rope clipped into commits

Artwork by Allison Horst for Openscapes, CC-BY 4.0

See exactly what changed

What changed, when, and why?

data/plots.csv
plot_id,x,y,forest_type,management
16,561870,5813015,beech,unmanaged
17,562455,5813410,spruce,managed
18,563102,5812877,oak,unmanaged

See exactly what changed

What changed, when, and why?

data/plots.csv
plot_id,x,y,forest_type,management
16,561870,5813015,beech,unmanaged
- 17,562455,5813410,spruce,managed
+ 17,562520,5813295,spruce,managed
18,563102,5812877,oak,unmanaged


a3f9c21 · Jens · 2026-05-12 · Move plot 17: original site too steep

Why add a remote?

What if your laptop dies tomorrow?

git works locally, a remote is optional.

  • backup: off your laptop
  • collaboration: one shared history
  • sharing: one link for everything


private: only you, or your team

public: open, route to publication


GitHub · GitLab · Codeberg

A bunny and a mouse, both looking stressed and sweaty, look on at a smoking laptop as flames start to grow from it. Text reads: plan on it.

A row of 6 cute smiling monsters celebrating using GitHub. The first, wearing a climbing harness labeled Me, is high-fiving another whose harness says Future Me. Others hold a box of snacks that are tacos, a map, and a rope. Text above the monsters quotes Jenny Bryan: Collaboration is the most compelling reason to manage a project with Git and GitHub. My definition of collaboration includes hands-on participation by multiple people, including your past and future self, as well as an asymmetric model, in which some people are active makers and others only read or review.

Artwork by Allison Horst (partly for Openscapes), CC-BY 4.0

The daily loop

How does a change get from my folder to GitHub?

Diagram: working folder, add, staging area, commit, local repository, push, remote repository, pull back to working folder

In RStudio and VS Code these are buttons.

No terminal needed

Do I need the command line?

VS Code, Source Control view:

  1. + stages a changed file
  2. write a message
  3. Commit
  4. Sync = pull + push


RStudio: same in the Git pane.

VS Code Source Control view with a commit message box, Commit button, staged changes and the Stage Changes button

Screenshot: VS Code docs, CC BY 3.0 US

3 · Record

“Works on my machine”

Will your code still run next year?

Package versions change, and results with them.

  • minimum: list software and package versions in the README
  • R: renv::snapshot() writes the lock file, renv::restore() rebuilds it
  • commit renv.lock to git
  • this presentation: Quarto version pinned in the workflow
renv.lock (excerpt)
{
  "R": { "Version": "4.4.1" },
  "Packages": {
    "sf": {
      "Version": "1.0-16"
    },
    "targets": {
      "Version": "1.7.1"
    }
  }
}

4 · Automate

What do I rerun?

Which scripts do I need to rerun after a change?

The pipeline with every step downstream of the field data highlighted

Write the pipeline down

Who knows the order of the steps?

Script list

run_all.R
source("R/01_clean_plots.R")
source("R/02_read_soil.R")
source("R/03_diversity.R")
source("R/04_model.R")

You keep the order, everything reruns.

Pipeline

_targets.R
list(
  tar_target(plots, clean(raw)),
  tar_target(soil, read_soil(f)),
  tar_target(div, calc_div(plots, soil)),
  tar_target(model, fit(div))
)

The tool knows the order, only changes rerun.

targets::tar_make() · same idea in other languages: Make, Snakemake

Only rerun what changed

Do I have to rerun everything?

Pipeline where soil data changed: only diversity indices, models, figures, paper and other subprojects are rerun, all other steps are skipped

changed rerun up to date, skipped

From script to report

How do figures and numbers get into your paper?

Copy & paste

Figures and numbers copied into Word. Works, but every change means updating each copy by hand.

One document

Text, code and results in one file:

report.qmd
We sampled `{r} n` plots.

```{r}
#| fig-cap: Plot locations
plot(plots$x, plots$y)
```

Render → text, numbers and figures update together.

A schematic representing the multi-language input (e.g. Python, R, Observable, Julia) and multi-format output (e.g. PDF, html, Word documents, and more) versatility of Quarto.

These slides are made this way too.

Artwork by Allison Horst, CC-BY 4.0

5 · Publish

FAIR in one slide

What makes data and code reusable?

Findable DOI, metadata Zenodo record
Accessible open, standard protocol public repository
Interoperable open formats, vocabularies CSV, GeoPackage
Reusable licence, documentation README, data dictionary

No licence, no reuse

May others reuse your code and data?

Licence spectrum from open to restrictive. Data: CC0, CC BY (recommended), CC BY-SA, CC BY-NC, no licence. Code: MIT (recommended), Apache 2.0, GPL, no licence.

No licence → unclear rights → no safe reuse. Help choosing: choosealicense.com

Get a DOI, cite a version

How do others cite your work?

  1. connect GitHub to Zenodo (once)
  2. create a release on GitHub (v1.0)
  3. Zenodo archives it and mints a DOI
resolves to
version DOI exactly this release
concept DOI always the latest

CITATION.cff → Cite this repository button on GitHub

Zenodo record of this presentation, version v1.0, with title, author, abstract and the versions box showing the version DOI and the concept DOI

This presentation on Zenodo · version DOI 10.5281/zenodo.24471760 · concept DOI 10.5281/zenodo.24471759

Back to the start

One folder, all steps

What does a reproducible project look like?

diversa-plots/
├── README.md       ← organise
├── data-raw/       ← organise
├── R/              ← organise
├── .git/           ← track
├── renv.lock       ← record
├── _targets.R      ← automate
├── report.qmd      ← automate
├── LICENSE         ← publish
└── CITATION.cff    ← publish → DOI

Code, data, environment and report in one citable package: a research compendium.

Back to the start

What happens if one value changes at the very start?

  • what changed → diff
  • why → commit message
  • rerun → pipeline
  • cite → version DOI

Start small

Where do I start?

step try this
1 · Organise write a README
2 · Track git init + a GitHub repository
3 · Record note your package versions
4 · Automate describe your steps as a pipeline
5 · Publish a release on Zenodo

Learn more

Thank you


Slides available at:

wiesehahn.github.io/presentation-reproducible_data_processing


References

Bryan, Jennifer, The STAT 545 TAs, and Jim Hester. n.d. “Happy Git and GitHub for the useR.” Accessed November 23, 2026. https://happygitwithr.com.
Horst, Allison. n.d. “Data Science and Stats Illustrations.” Accessed November 23, 2026. https://allisonhorst.com.
The Turing Way Community. 2022. The Turing Way: A Handbook for Reproducible, Ethical and Collaborative Research. Zenodo. https://doi.org/10.5281/zenodo.3233853.

Backup: explore a real repository

r-spatial/sf: simple features for R

  • commits & history
  • blame: who changed which line
  • issues: questions, bugs, ideas
  • pull requests: proposed changes
  • branches & releases
  • Actions: automatic checks