Skip to content


Repository files navigation



Evolocity is a Python package that implements evolutionary velocity, which constructs landscapes of protein evolution by using the local evolutionary predictions enabled by language models to predict the directionality of evolution and is described in the paper "Evolutionary velocity with protein language models predicts evolutionary dynamics of diverse proteins" by Brian Hie, Kevin Yang, and Peter Kim. This repository also contains the analysis code and links to the data for reproducing the results in the paper.

Evolocity is a fork of the scVelo tool for RNA velocity by Bergen et al. and relies on many aspects of the Scanpy library for high-dimensional biological data analysis. Like Scanpy and scVelo, evolocity makes use of anndata, a convenient way to store and organize biological data. Our main implementation is based on the ESM-1b language model by Rives et al.


For in-depth API documentation, go to


You should be able to install evolocity using pip:

python -m pip install evolocity

API example and tutorials

Below is a quick Python example of using evolocity to load and analyze sequences in a FASTA file.

import evolocity as evo
import scanpy as sc

# Load sequences and compute language model embeddings.
fasta_fname = 'data.fasta'
adata = evo.pp.featurize_fasta(fasta_fname)

# Construct sequence similarity network.

# Run evolocity analysis.

# Embed network and velocities in two-dimensions and plot.

More detailed documentation is provided here.

Tutorials are also available in the documentation and also on Google Colab for influenza A nucleoprotein and cytochrome c.


Unit tests require using pytest and can be run with the command

python -m pytest tests/

from the top-level directory.


Below are scripts for reproducing the experiments in our paper. To apply evolocity to your own sequence data, we also encourage you to check out the tutorials in the documentation. Our experiments were run with Python version 3.7 on Ubuntu 20.04.


You can download the relevant datasets using the commands

tar xvf data.tar.gz
ln -s data/target/ target

within the same directory as this repository. Be sure to move the target/ directory one level up or create a symlink to it (as done above).


Before running the scripts below, we encourage you to use the conda environment in environment-epi.yml using

conda env create --file environment-epi.yml

To run the TAPE baseline, TAPE needs to be installed separately as described in PyTorch will need to be reupdated after TAPE installation.

Evolocity analysis

Our main evolocity analyses can be reproduced using the command

bash bin/

which will create new log files and figures in a new figures/ directory. Analyses should fit within 100 GB of CPU RAM and 8 GB of GPU RAM, and should finish within a few hours.

Benchmark results are generated by the commands

python bin/
python bin/

Benchmarking results can be reproduced with the commands below, but can take several days to complete if run in serial.

bash bin/
bash bin/

Scripts for other analyses

Phylogenetic tree reconstruction of NP and ancient proteins can be done with the commands below (you will first need to install PhyML and FastTree):

bash bin/ > phylo_np.log 2>&1
bash bin/ > phylo_eno.log 2>&1
bash bin/ > phylo_pgk.log 2>&1
bash bin/ > phylo_ser.log 2>&1

Deep mutational scan benchmarking can be done with the command

python bin/ esm1b > dms_esm1b.log 2>&1
python bin/ tape > dms_tape.log 2>&1