scvi-tools can be installed via conda or pip. If you don’t know which to choose, we recommend conda.
Install conda. We typically use the mambaforge distribution. Use python>=3.9, and consider using mamba instead of conda. Mamba is a drop-in replacement for conda that is significantly more efficient.
Create a new conda environment:
conda create -n scvi-env python=3.9
Activate your environment:
conda activate scvi-env
If using conda/mamba, then just run
conda install -c anaconda pipand skip this section.
Installing scvi-tools on a Mac with Apple Silicon is only possible using a native version of python. A native version of python can be installed with an Apple Silicon version of mambaforge (which can be installed from a native version of homebrew via
brew install --cask mambaforge). This is due to an scvi-tools dependency on jax, which cannot be run via Rosetta.
After setting up a virtual environment with conda/mamba/pyenv, please install the community-built version of jax before installing scvi-tools.
pip install "jax[cpu]" -f https://whls.blob.core.windows.net/unstable/index.html --use-deprecated legacy-resolver
All scvi-tools models will be faster when accelerated with a GPU. Before installing scvi-tools, you can install GPU versions of PyTorch and jax using conda as follows:
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
conda install jax jaxlib -c conda-forge
Please go to the respective package website for more information on how to install with pip.
conda install scvi-tools -c conda-forge
pip install scvi-tools
Through pip with packages to run notebooks. This installs scanpy, etc.:
pip install "scvi-tools[tutorials]"
Nightly version - clone this repo and run:
pip install .
For development - clone this repo and run:
pip install -e ".[dev,docs]"
scvi-tools can be called from R via Reticulate.
This is only recommended for basic functionality (getting the latent space, normalized expression, differential expression). For more involved analyses with scvi-tools, we highly recommend using it from Python.
The easiest way to install scvi-tools for R is via conda.
Install conda prerequisites.
Install R and reticulate in the conda environment:
conda install -c conda-forge r-base r-essentials r-reticulate
Then in your R code: