Skip to content

alaindanet/reproducibleR_workshop

Repository files navigation

Build Status

ReproducibleR

The goal of ReproducibleR is to help you to make your analysis reproducible.

Prerequisites

You need to have the following softwares:

  • Git to version your work
  • Docker to ensure that we work in the same container

Install Git

Install Docker

Check your install

docker run hello-world

Download an image and run it

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.

Use Docker

Pointing a Docker session to your project

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.

Commit with git inside a docker container

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

Clone the repository

git clone https://github.com/alaindanet/reproducibleR_workshop.git dir_name

Compile the presentation

Build the Docker image

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

Compile

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")

Some useful links

Compendium

Docker

Git

  • A nice documentation to keep close to you: ProGit

About

A workshop how to use R to make your analysis reproducible

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published