The prerequisites for LeafCutter are

  • samtools should be available on your PATH
  • regtools should be available on your PATH
  • Python 2.7 (earlier versions may be OK)
  • R (version 3.6.0, earlier versions may be OK)

To download the code (you’ll need this for the leafcutter scripts)

git clone

If you just want to get leafcutter quantifications (junction counts for each splicing cluster) e.g. for sQTL analysis, then you just need the python scripts in scripts and clustering.

If you want to do differential splicing analysis and visualization you’ll need to install the leafcutter R package.

Installing the R package

Installing rstan

Leafcutter relies on stan and its R interface rstan. Installing this can be tricky. If you’re lucky


will just work for you. If not, there are instructions that should help you. On Linux I seem to need

CXX14FLAGS=-O3 -march=native -mtune=native -fPIC

in ~/.R/Makevars.

For now we also need a version of rstantools (2.0.0) that is not yet on CRAN, so do:

if (!require("devtools")) install.packages("devtools", repos='')

You can use remotes instead of devtools if you don’t want to wait on the long devtools install.

From source

Alternatively you can install from source. You’ll need to manually install the following R packages: Rcpp, rstan, rstantools, foreach, ggplot2, R.utils, gridExtra, reshape2, Hmisc, dplyr, doMC, optparse, shiny, intervals, shinycssloaders, DT, gtable, shinyjs, DirichletMultinomial, TailRank, magrittr, stringr. Then make sure you’re in the leafcutter package sub-directory (you should see subdirectories called src, R, tests etc) and run

R CMD INSTALL --build .

If you see errors try installing the roxygen2 package and running

R CMD INSTALL --preclean --build .

which will attempt to use stan to rebuild the C++ code from the .stan files in exec.

Using conda

If you are a 64-bit Linux conda user ( installation instructions ) we have an experimental package which can be installed using

conda install -c davidaknowles r-leafcutter

We will build macOS and Windows packages if there is demand for this.