-
Notifications
You must be signed in to change notification settings - Fork 0
/
07-sharing.Rmd
191 lines (124 loc) · 9.81 KB
/
07-sharing.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
# Sharing Projects
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.
## Examples
In our lab:
- the [`SocCaribou`](https://github.com/wildlifeevoeco/SocCaribou) repository 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`](https://github.com/robitalec/spatsoc-application-paper). This is a paper outlining the R package `spatsoc` developed by Alec, Quinn and Eric. Included are the scripts to generate each of the figures, the data used for the figures, and the full `.Rmd` manuscript, along with a typeset vesion.
- the [`MovingAcrossGradients`](https://github.com/wildlifeevoeco/MovingAcrossGradients) lab paper from 2018.
Each of these repositories are also linked to [Zenodo](https://zenodo.org), with "GitHub releases" triggering an updated DOI, etc.
A couple examples from outside our group include Carl Boettiger's [nonparametric bayes](https://github.com/cboettig/nonparametric-bayes) and [noise phenomena](https://github.com/cboettig/noise-phenomena) papers.
## Moving from GitLab to GitHub {#lab-to-hub}
Three options and it depends on if you'd like your repository to be mirrored over
(dynamic, with updates) or imported (static, one time snapshot). Using the
GitHub Importer (option 3) is easy but will only take a static snapshot. Otherwise,
change your remote (option 1), or use an access token (option 2) and
mirror the repository for a dynamic link between GitLab
and GitHub that will copy over future changes.
### Option 1: Changing your remote (dynamic)
Note: This approach locally changes your remote path to the Git repository.
If there are multiple users of the repository, they **must** either 1) also
change their remote path or 2) clone the new repository at the updated path (
and ideally delete the old local repository).
On GitHub.com:
1. Make an empty repo (<https://github.com/new>). Don't select "initialize with a README" - you want an empty repository.
In GitAhead, or other Git tool on your computer:
1. Open the repository you want to move to GitHub.
2. Edit the URL of the remote. In GitAhead: Select the "Remote" menu/Select "Configure remotes"/Double click on the URL and change the value to your GitHub clone URL eg. https://github.com/wildlifeevoeco/MovingAcrossGradients.git or git@github.com:wildlifeevoeco/MovingAcrossGradients.git
3. Push. It may take longer than usual, it is going to push the entire Git history to the empty GitHub repository.
4. Check your new GitHub repository. You should see all the commits and files there.
If you want your GitLab version to stay up to date, use a Pull remote mirroring.
More information here: https://docs.gitlab.com/ee/user/project/repository/mirror/pull.html
### Option 2: Using an access token (dynamic)
On GitHub.com:
1. Make an empty repo to receive commits from GitLab (<https://github.com/new>). Don't select "initialize with a README" - you want an empty repository.
2. Generate a new personal access token at <https://github.com/settings/tokens>
- Select `public_repo`
3. Copy it, to use as password on Gitlab.com below
On GitLab.com:
1. Navigate to "Settings/Repository" (<https://gitlab.com/user/repository/-/settings/repository>)
2. Select "Mirror a repository"
3. Mirror direction: Push
4. Repository URL: `https://<your_github_username>@github.com/<your_github_group>/<your_github_project>.git`
5. Password: paste the personal access token generated on Github here
Check results:
1. Wait for the spinning circle to finish, make sure no errors come up.
2. Navigate to your new GitHub repository. It may take a few minutes to update.
### Option 3: Using GitHub Importer (static)
1. Open <https://github.com/new/import>.
2. Select the "Owner". Note: you can select the [`wildlifeevoeco`](https://github.com/wildlifeevoeco/) as "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.
3. Provide a repository name.
4. Select "Public".
5. Select "Begin import"
6. If prompted for credentials, provide them for the repository that is being imported, not GitHub.
7. Check your email for confirmation.
The GitHub Importer is described [here](https://docs.github.com/en/free-pro-team@latest/github/importing-your-projects-to-github/importing-a-repository-with-github-importer).
## Linking Zenodo and GitHub
1. Set up your repository in the standard way with folders for data, scripts, manuscript, etc. See [here](Projects) for details.
2. Host your repository on GitHub. Note: you can select the [`wildlifeevoeco`](https://github.com/wildlifeevoeco/) as "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](https://github.com/new) on GitHub and pushing there. or by
- mirroring your existing repository from GitLab there. See [below](#lab-to-hub) or [here](https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html#setting-up-a-push-mirror-from-gitlab-to-github-core) for extended details.
3. Create a Zenodo account, log in, link to GitHub, and turn on the repository of interest\*. [Here are all the details](https://guides.github.com/activities/citable-code/).
4. Create your release (see [here](https://r-pkgs.org/release.html#release-version) for picking a version number), get a DOI, add it to your README with the badge shown in [here](https://zenodo.org/account/settings/github).
5. 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](https://github.com/zenodo/zenodo/issues/1463).
\* **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>).
## 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:
a) Manually write it (careful for syntax errors), for example:
```json
{
"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"
}
]
}
```
b) Generate one on Zenodo after you edit the record, then save it in the repository
1. Open your Zenodo record (eg. following the link in the badge)
1. Edit the record (top left, orange button)
1. Save the record
1. Export the record as a JSON (bottom of the page)
1. Grab the metadata chunk within this exported JSON (edit it so it looks like the above example)
## Resources
A recent community call with rOpenSci: [summary blog](https://ropensci.org/blog/2018/11/29/codereview/) and [notes](https://docs.google.com/document/d/1LfyhgsbVgLWgWPhS0nbaBIZSFjireEBBSYL4PmhUJis/edit).
A paper on [research compendium](/user_uploads/4422/JZqXfCyHQv5eePmN7vFYoIwM/Packaging-Data-Analytical-Work-Reproducibly-Using-R-and-Friends.pdf) from Lincoln Mullen and Carl Boettiger.
[Details in the GitLab docs on mirroring](https://docs.gitlab.com/ee/workflow/repository_mirroring.html#setting-up-a-push-mirror-from-gitlab-to-github-core)
# Reproducibility
![](https://img.shields.io/badge/-WIP-yellow.svg)
See the [`renv`](https://github.com/rstudio/renv/) package for reproducible package versions and
[`targets`](https://github.com/ropensci/targets/) package for workflows.
## Slides
Some Reproducibility
Date: August 4 2020
Alec L. Robitaille
[Resources](https://github.com/robitalec/workshops/tree/master/some-reproducibility), [Binder](https://mybinder.org/v2/gl/robit.a%2Fsome-reproducibility-example/master?urlpath=rstudio)
Note: the workflow used `drake` which has been superseeded by `targets`. Use it
instead!