build xaringan slides with snakemake
snakemake all --cores 1
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
.
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.
Follow these Steps to install the necessary software on your system
You need to have the following software and packages installed:
Either:
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.8
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
R
We provide instructions on how to install R here
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.
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
Major changes are tracked in the NEWS file with brief descriptions of the changes implemented.
I’d love to hear your comments, suggestions or installation issues encountered when running the example.
Post an issue on Github.
Deer, Lachlan. 2021. Building Xaringan Presentations with Snakemake.
url = “https://github.com/lachlandeer/xaringan-snakemake“