25 Sharing code and data alongside manuscripts
This is a small portion of the larger discussion surrounding reproducible research: sharing manuscripts and code. Here, I’ll outline some steps for turning a repository into a clean, public facing resource accompanying a paper or project.
25.1 Examples
In our lab:
the
SocCaribourepository is a fully functioning R package with functions used for the paper, and a series of ordered scripts for running the analysis. The paper included is simply the journal’s typeset version.the
spatsoc-application-paper. This is a paper outlining the R packagespatsocdeveloped by Alec, Quinn and Eric. Included are the scripts to generate each of the figures, the data used for the figures, and the full.Rmdmanuscript, along with a typeset vesion.the
MovingAcrossGradientslab paper from 2018.
Each of these repositories are also linked to Zenodo, with “GitHub releases” triggering an updated DOI, etc.
A couple examples from outside our group include Carl Boettiger’s nonparametric bayes and noise phenomena papers.
25.2 Linking Projects to Zenodo
(Note: right now, GitLab projects cannot be linked to Zenodo like GitHub projects can be. See this issue).
Set up your repository in the standard way with folders for data, scripts, manuscript, etc. See here for details.
-
Host your repository on GitHub. Note: you can select the
wildlifeevoecoas “Owner” if this is a lab paper/project. If you don’t see that as an option, ask Alec to add you as a member of that group.- making a new repository on GitHub and pushing there. or by
- mirroring your existing repository from GitLab there. See below or here for extended details.
Create a Zenodo account, log in, link to GitHub, and turn on the repository of interest*. Here are all the details.
Create your release (see here for picking a version number), get a DOI, add it to your README with the badge shown in here.
Edit the page on Zenodo, setting up manuscript/project authors, title etc.
* Note: make sure to turn on the repository of interest, before making the release on GitHub. At the moment, Zenodo only tracks future releases - though in progress here.
* Note: if you need to make changes after publishing, make those changes in the repository and add a new Git tag + release on GitHub (https://github.com/namespace/repo-name/releases).
25.3 Preserving Zenodo edits across releases
If you re-release your Github repository, the new Zenodo record will lose all the details, like authors, ORCIDs, descriptions, etc.
A solution is to use a special file (.zenodo.json), and save it in your
repository.
Two options for making this file:
- Manually write it (careful for syntax errors), for example:
{
"description": "<p>This repository contains the code accompanying the paper “At a snail’s pace: the influence of habitat disturbance on terrestrial snail movement using experimentally manipulated mesocosms”.</p>\n\n<p>This project depends on some incredible R packages. We use <a href=\"https://github.com/ropensci/targets\"><code>targets</code></a> for declaring the workflow and <a href=\"https://github.com/rstudio/renv\"><code>renv</code></a> for a reproducible environment. General processing uses <a href=\"https://github.com/Rdatatable/data.table\"><code>data.table</code></a> and plotting with <a href=\"https://github.com/tidyverse/ggplot2\"><code>ggplot2</code></a> and <a href=\"https://github.com/thomasp85/patchwork\"><code>patchwork</code></a>. iSSA methods with <a href=\"https://github.com/jmsigner/amt\"><code>amt</code></a>, <code>raster</code> and <code>sf</code>, modeling with <a href=\"https://github.com/glmmTMB/glmmTMB/\"><code>glmmTMB</code></a> and <code>lme4</code>.</p>",
"title": "Code accompanying - At a snail's pace: the influence of habitat disturbance on terrestrial snail movement using experimentally manipulated mesocosms",
"creators": [
{
"affiliation": "Memorial University",
"name": "Emily Denief"
},
{
"orcid": "0000-0001-5449-5449",
"affiliation": "Memorial University",
"name": "Julie W. Turner"
},
{
"orcid": "0000-0002-5622-4973",
"affiliation": "Memorial University",
"name": "Christina M. Prokopenko"
},
{
"orcid": "0000-0002-4706-1762",
"affiliation": "Memorial University",
"name": "Alec L. Robitaille"
},
{
"orcid": "0000-0002-8534-4317",
"affiliation": "Memorial University",
"name": "Eric Vander Wal"
}
]
}- Generate one on Zenodo after you edit the record, then save it in the repository
- Open your Zenodo record (eg. following the link in the badge)
- Edit the record (top left, orange button)
- Save the record
- Export the record as a JSON (bottom of the page)
- Grab the metadata chunk within this exported JSON (edit it so it looks like the above example)
25.4 Resources
A recent community call with rOpenSci: summary blog and notes.
A paper on research compendium from Lincoln Mullen and Carl Boettiger.