The goal of ReproducibleR is to help you to make your analysis reproducible.
You need to have the following softwares:
- For windows (get the executable here. Otherwise, they will try to make you create an account on Dockerhub)
- For Linux: Debian and Ubuntu
- Mac OS
docker run hello-world
Once you have docker, please run the following command. You will get a container with R, RStudio and several useful packages (see more on Rocker).
docker run -e PASSWORD=<YOUR_PASS> --rm -p 8787:8787 rocker/verse
Once you have downloaded it, you can open an Rstudio session in your web
browser. On Linux system, it will be at http://localhost:8787/. On
other systems, localhost
will be replaced by your ip address. Your
will find it when you launch the Docker Quickstart Terminal.
Rstudio will ask you for a username and a password. The username is
rstudio
by default and the password is the one that you specified in
the above command.
Please see this tutorial for more details.
The above command created an container isolated from your hard disk and all that you have created is erased when you close your Docker container.
Although, we often need files and data that are in a project directory.
This can be be done with the -v
flag (v for volume). The part on the
left (before :
) indicates the path on your computer (can be replaced
by $(pwd)
if it is the current directory), and the right side (after
:
) indicates the path in the container (should always begin by
/home/rstudio/
).
docker run -e PASSWORD=<YOUR_PASS> --rm -p 8787:8787 -v /path_to_your_project/project_directory:/home/rstudio/project_directory rocker/verse
More details can be found here.
While running R in a docker container, git will not know you since you are not in your system environment.
If you run your Docker session which points to a git repository, you can configure it locally. Your local git config will be available in the Docker environment.
In your project root, you can run:
# Set up your identity
git config user.name "FirstName LastName"
git config user.email "[email protected]"
Note that if you are not in the git repository, you have initialize it
before to run the above command. It is done as simply as git init
.
You can check the local set up: cat .git/config
## Usage
git clone https://github.com/alaindanet/reproducibleR_workshop.git dir_name
You can see that there is a Dockerfile
in the repository. The
Dockerfile
contains all the informations necessary to install all
dependencies that is needed to execute your code. In this specific case,
it contains intructions to install packages necessary to compile the Rmd
presentation in a pdf beamer presentation.
The following command will execute all the command in the Dockerfile
and store it as an image that we have to name to call it later (Let’s
name it workshop_image
):
docker build -t workshop_image .
Now you can run Docker with the image that we have just created:
docker run -e PASSWORD=<YOUR_PASS> --rm -p 8787:8787 -v $(pwd):/home/rstudio/project workshop_image:latest
Open the file talk/talk.Rmd
in Rstudio and knit it or you can run this
command in your R console:
rmarkdown::render("talk.Rmd")
-
R compendium: Example from Carl Boettiger
-
R package structure: R packages book
-
A package to create a compendium: rrtools
-
A paper explaining compendia for analysis reproducibility: Marwick et al. (2018)
-
A real example of research compendium: by Carl Boettiger
- Using Docker with R: Ropenscilabs course
- A nice documentation to keep close to you: ProGit