Installation

Installation#

To install the sfsutils package in R, execute the following command:

devtools::install_github("Sendrowski/SFSUtils")

Once the installation is successfully completed, initiate the package within your R session using:

library(sfsutils)

The sfsutils R package serves as a wrapper around the Python library but re-implements visualization through ggplot2. Because of this, the Python package must be installed separately. This can be accomplished with:

install_sfsutils()

sfsutils is compatible with Python 3.11 through 3.13.

Note

The backends for the different input sources are optional extras: vcf (the cyvcf2 dependency, for VCF files), zarr (the zarr dependency, for VCF-Zarr stores) and arg (the tskit dependency, for tree sequences / ARGs). To enable the ones you need, run the following command in R before calling install_sfsutils(), for example for all of them:

reticulate::py_install("sfsutils-popgen[vcf,zarr,arg]", pip = TRUE)

Note

sfsutils is also available on conda-forge. As install_sfsutils() installs the Python package into a conda environment via reticulate, you can instead provision that environment directly. zarr and tskit are on conda-forge, while cyvcf2 (for VCF handling) is on bioconda, so add both channels:

mamba create -n sfsutils -c conda-forge -c bioconda sfsutils cyvcf2 zarr tskit

Then point reticulate at that environment before loading the package:

reticulate::use_condaenv("sfsutils", required = TRUE)

Alternatively, you can also follow the instructions in the Python installation guide to install the Python package.

Once installed, the sfsutils wrapper module can be loaded into your R environment using the following command:

su <- load_sfsutils()

See the R package documentation for more information on the available functions.