- Overview
- Sources of inspiration
- Prerequisites
- Steps for getting up and
running
- 1. Navigate in terminal to the wished directory
- 2. Run cookiecutter
- 3. Navigate to the created project directory
- 4. Build Docker image using Dockerfile
- 5. Run Docker container using the newly built image
- 6. Access RStudio-Server running in the container through a browser
- 7. Stopping and starting a container
- 8. Removing images and containers
- Bonus step 1: Initialise git repository
- Bonus step 2: configure git
- License
- References
This is a working version of a template I use for new bioinformatic projects. This template uses Docker containers for the R environment called Rocker. There is also a paper introducing Rocker by Boettiger and Eddelbuettel (2017).
Here is a schema of the file structure:
project
|- README.md # the top level description of content (this doc)
|- CONTRIBUTING.md # instructions for how to contribute to your project
|- LICENSE # the license for this project
|- CITATION # instructions on how to cite the work
|
|- manuscript/
| |- header.sty # LaTeX header file to format pdf version of manuscript
| |- bibliography.bib # BibTeX formatted references
| |- csl/ # csl files to format references
| |- study.Rmd # executable Rmarkdown for this study, if applicable
|
|- data # raw and primary data, are not changed once created
| |- references/ # reference files to be used in analysis
| |- raw/ # raw data, will not be altered
| |- processed/ # cleaned data, will not be altered once created;
| # will be committed to repo
|
|- docker # Dockerfiles defining exploratory notebooks and manuscript notebook
| |- Jupyterlab/ # Jupyter notebooks run in Jupyterlab
| |- RStudio_server/ # https://github.com/rocker-org/rocker-versioned/tree/master/rstudio
| # The Dockerfile has heavily loaned code from the Rocker project:
| # https://www.rocker-project.org/
|
|- _output.yaml # shared configurations for all presentations
|- presentation_style.css # css for modifying features in presentation
|- presentation.Rmd # R revealjs presentation
|
|- code/ # any programmatic code
| |- test/ # tests for the code
| |- data/ # code for manipulating data
| |- utils/ # code for utilities
| |- visualisation/ # code for producing visualisations
|
|- results # all output from workflows and analyses
| |- tables/ # tables and other tabular data
| |- figures/ # graphs, likely designated for manuscript figures
| |- pictures/ # diagrams, images, and other non-graph graphics
|
|- exploratory/ # exploratory data analysis for study
| |- notebook/ # preliminary analyses
| |- scratch/ # temporary files that can be safely deleted or lost
|
|- environments/ # conda environments used for running Snakemake
|
|- Snake_report/ # Caption data for report.html that Snakemake produces
|
|- Snake_config.yaml # Configfile for snakefile global variables
|
|- Snakefile # executable Snakefile for this study, if applicable
The structure of this template project is inspired by:
-
an article by Wilson et al. (2017)
-
Russ Hyde’s blog posts about Working Directories and RMarkdown
-
Mario Krapp’s cookiecutter boilerplate for Reproducible research
There are some pieces of software that are needed to get this development environment up and running. You should install:
1. Navigate in terminal to the wished directory
Your working directory should be the location where you wish to have your project in. This is the location where you will setup the project using cookiecutter.
cookiecutter https://github.com/ljmesi/bioinfo-template.git
cd {{cookiecutter.project_name}}
Dockerfile is used to build an image which in turn is used to run containers.
docker build -t image_name:version.number docker/
Here you should exchange image_name
, version
and number
with the
appropriate values.
docker run --name container_name -e PASSWORD=some_really_good_password -p 8787:8787 -v $(pwd):/home/rstudio image_name:version.number
Here you should exchange container_name
with a suitable name. Some
more information on running Rocker containers can be found
here.
Here are instructions on accessing the container using a web browser.
In step 5 started running container can be stopped by pressing Ctrl
+
C
and started again with command:
docker start container_name
and stopped again with:
docker stop container_name
Local images can be listed with:
docker images
and containers with:
docker ps -a
Images can be removed with:
# Using image_name:version.number
docker rmi image_name:version.number
# Or using the image ID (2791ce80edf0)
docker rmi 2791ce80edf0
and containers with:
# Using container's name
docker rm container_name
# Using container ID
docker rm 9fcd57ea7ccb
Here
can be found general information on removing images and containers.
Here and
here are
links to docker rm
and docker rmi
command descriptions respectively.
Here are terrific instructions on how to initialise a git repository.
Git can be configured in RStudio server by running the following commands in the terminal panel:
git config --global user.name "your_Github_user_name" && \
git config --global user.email "your_email@address.com" && \
git config --global color.ui true && \
# Store the Github personal access token permanently in .git-credentials file
git config --global credential.helper store
This repository is released under the BSD License.
Boettiger, Carl, and Dirk Eddelbuettel. 2017. “An Introduction to Rocker: Docker Containers for R.” R Journal 9 (2): 527–36. https://rocker-project.org. http://arxiv.org/abs/1710.03675.
Wilson, Greg, Jennifer Bryan, Karen Cranston, Justin Kitzes, Lex Nederbragt, and Tracy K Teal. 2017. “Good enough practices in scientific computing.” Edited by Francis Ouellette. PLOS Computational Biology 13 (6): e1005510. https://doi.org/10.1371/journal.pcbi.1005510.