Help improve this workflow!
This workflow has been published but could be further improved with some additional meta data:- Keyword(s) in categories input, output, operation, topic
You can help improve this workflow by suggesting the addition or removal of keywords, suggest changes and report issues, or request to become a maintainer of the Workflow .
TLDR:
-
Install R, Snakemake and xaringan.
-
Navigate to this project's directory and then run:
snakemake all --cores 1
- End result is a html and pdf presentation
Introduction
Repository provides a template to build xaringan presentations to html and pdf using the Snakemake workflow management system.
I also manage R's package dependencies with
renv
.
Motivating Example
I use the Rmarkdown file
slides.Rmd
which contains the slide template that you would get if you created a new xaringan presentation in RStudio.
Installation Instructions
Follow these Steps to install the necessary software on your system
You need to have the following software and packages installed:
-
Python 3 (Python 3.6 or higher)
-
Snakemake (we'll install it in a couple of lines time!)
-
R (version 4.0.x)
Installing Python
Either:
-
Install Anaconda Python:
- We provide instructions on how to install anaconda python here
-
Install Python using the deadsnakes ppa (Debian/Ubuntu flavored):
- Here's how to add the deadsnakes ppa and install Python 3.8
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:deadsnakes/ppa $ sudo apt-get update $ sudo apt-get install python3.8
Installing Snakemake
I have included a
requirements.txt
file that we can use to install a specific version of snakemake.
This makes sure that my example runs on your machine (or at least won't break because you use a different version of snakemake than I do)
pip3 install -r requirements.txt
you may need to replace
pip3
with
pip
Installing
R
We provide instructions on how to install R here
Installing
xaringan
Either:
-
Install it using
install.packages('xaringan')
in the R console -
Use our renv workflow:
Open a terminal and navigate to this directory. Then in the terminal enter the following command to install renv:
snakemake --cores 1 renv_install
Then you will need to provide consent for
renv
to be able to write files to your system:
snakemake --cores 1 renv_consent
Once this is complete you can use renv to create a separate R environment that contains the packages we use in our example by entering the following command into the terminal:
snakemake --cores 1 renv_init
The above command will initialize a separate R environment for this project.
Now we will install the necessary packages (and their precise versions) which are stored in the
renv.lock
file:
snakemake --cores 1 renv_restore
This will install all the packages we need. It may take a while.
Running the Example:
Navigate to this project's directory, and then run the following command in the terminal:
If you want html and pdf slides:
$ snakemake all --cores 1
If you only want the html presentation:
$ snakemake build_html --cores 1
To get the pdf (you need the html), so use
snakemake all --cores 1
Updates to Workflow Example
Major changes are tracked in the NEWS file with brief descriptions of the changes implemented.
Comments / Suggestions / Issues
I'd love to hear your comments, suggestions or installation issues encountered when running the example. Post an issue on Github.
Suggested Citation
Deer, Lachlan. 2021. Building Xaringan Presentations with Snakemake. url = "https://github.com/lachlandeer/xaringan-snakemake"
Code Snippets
11 12 | shell: "{runR} install_renv.R" |
16 17 | shell: "R -e 'renv::consent(provided = TRUE)'" |
21 22 | shell: "R -e 'renv::init()'" |
26 27 | shell: "R -e 'renv::snapshot()'" |
31 32 | shell: "R -e 'renv::restore()'" |
24 25 26 | shell: "{run_r} {input.runner} {input.slides} \ {output.slides} > {log} {log_all}" |
37 38 39 | shell: "{run_r} {input.runner} {input.slides} \ {output.slides} > {log} {log_all}" |
49 50 | shell: "rm *.pdf *.html" |
Support
- Future updates