tools for working with genome variation graphs
Variation graphs provide a succinct encoding of the sequences of many genomes. A variation graph (in particular as implemented in vg) is composed of:
This model is similar to sequence graphs that have been used in assembly and multiple sequence alignment.
Paths provide coordinate systems relative to genomes encoded in the graph, allowing stable mappings to be produced even if the structure of the graph is changed. The variation graph model makes this embedding explicit and essential. Tools in vg maintain paths as immutable during transformations of the graph. They use paths to project graph-relative data into reference-relative coordinate spaces. Paths provide stable coordinates for graphs built in different ways from the same input sequences.
Please cite:
vgvg giraffevg giraffe's chaining modes (hifi, r10, chaining-sr)vg callvg deconstructvg snarlsvg haplotypes and/or vg giraffe --haplotype-nameWe maintain a support forum on biostars: https://www.biostars.org/tag/vg/
The easiest way to get vg is to download one of our release builds for Linux. We have a 6-week release cadence, so our builds are never too far out of date.
Download the latest vg release for Linux
For MacOS, see Building on MacOS.
If you don't want to or can't use a pre-built release of vg, or if you want to become a vg developer, you can build it from source instead.
First, obtain the repo and its submodules:
git clone --recursive https://github.com/vgteam/vg.git
cd vg
Then, install VG's dependencies. You'll need the Protobuf and Jansson development libraries installed, and to run the tests you will need:
jq, bc, rs, and parallelhexdump and column from bsdmainutilsnpm for testing documentation examples.On Ubuntu 22.04 or 26.04, you should be able to do:
make get-deps
If you get complaints that sudo is not found, install it:
apt update
apt install sudo
If you get a bunch of errors like E: Unable to locate package build-essential, make sure your package index files are up to date by running:
sudo apt update
On other distros, or if you do not have root access, you will need to perform the equivalent of:
sudo apt-get install \
make git build-essential protobuf-compiler libprotoc-dev libjansson-dev libbz2-dev \
libncurses5-dev automake gettext autopoint libtool jq bsdmainutils bc rs parallel npm \
samtools curl unzip redland-utils librdf-dev cmake pkg-config wget gtk-doc-tools \
raptor2-utils rasqal-utils bison flex gawk libgoogle-perftools-dev liblz4-dev liblzma-dev \
libffi-dev libfontconfig-dev libfreetype-dev libglib2.0-dev libpcre2-dev libpng-dev \
libprotobuf-dev libboost-all-dev tabix bcftools libzstd-dev pybind11-dev \
python3-pybind11 pandoc libssl-dev libjitterentropy3-dev kmc meson
To build vg's bundled Cairo and pixman (currently 1.3.0 or newer is required), so you may also need to do the equivalent of:
sudo apt-get install pipx
pipx install meson
At present, you will need GCC version 10 or greater, with support for C++20, to compile vg. (Check your version with gcc --version.) GCC up to 15.2.0 is supported.
Other libraries may be required. Please report any build difficulties.
Note that a 64-bit OS is required.
When you are ready, build with make. You can use make -j16 to run 16 build threads at a time, which greatly accelerates the process. If you have more CPU cores, you can use higher numbers.
Note that vg can take anywhere from 10 minutes to more than an hour to compile depending on your machine and the number of threads used.
You can also produce a static binary with make static, assuming you have static versions of all the dependencies installed on your system.
Once vg is built, the binary will be at bin/vg inside the vg repository directory. You can run it with:
./bin/vg
You can also add its directory to your PATH enviornment variable, so that you can invoke vg from any directory. To do that on Bash, use this command from the vg repository directory:
echo 'export PATH="${PATH}:'"$(pwd)"'/bin"' >>~/.bashrc
Then close your terminal and open a new one. Run vg to make sure it worked.
If it did not work, make sure that you have a .bash_profile file in your home directory that will run your .bashrc:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
The first step is to clone the vg repository:
git clone --recursive https://github.com/vgteam/vg.git
cd vg
VG depends on a number of packages being installed on the system where it is being built. Dependencies can be installed using either MacPorts or Homebrew.
Using MacPortsYou can use MacPorts to install VG's dependencies:
sudo port install libtool protobuf3-cpp jansson jq cmake pkgconfig autoconf automake libtool coreutils samtools redland bison gperftools md5sha1sum rasqal gmake autogen cairo libomp boost zstd pybind11 openssl
Using Homebrew
Homebrew provides another package management solution for OSX, and may be preferable to some users over MacPorts. VG ships a Brewfile describing its Homebrew dependencies, so from the root vg directory, you can install dependencies, and expose them to vg, like this:
# Install all the dependencies in the Brewfile
brew bundle
With dependencies installed, VG can now be built:
make
As with Linux, you can add -j16 or other numbers at the end to run multiple build tasks at once, if your computer can handle them.
Note that static binaries cannot yet be built for Mac.
The vg Mac build targets whatever the current version of Apple Clang is, and whatever version of Apple Clang is provided by our Github Actions Mac CI system. If your Clang is up to date and vg does not build for you, please open an issue.
Once vg is built, the binary will be at bin/vg inside the vg repository directory. You can run it with:
./bin/vg
You can also add its directory to your PATH enviornment variable, so that you can invoke vg from any directory. To do that on the default zsh Mac shell, use this command from the vg repository directory:
echo 'export PATH="${PATH}:'"$(pwd)"'/bin"' >>~/.zshrc
Then close your terminal and open a new one. Run vg to make sure it worked.
The Mac platform is moving to ARM, with Apple's M1, M1 Pro, M1 Max, and subsequent chip designs. The vg codebase supports ARM on Mac as well as on Linux. The normal installation instructions work on a factory-fresh ARM Mac.
However, it is easy to run into problems when migrating a working vg build environment or migrating MacPorts or Homebrew from x86_64 to ARM. The ARM machine can successfully run x86_64 tools installed via Macports or Homebrew on the old machine, but vg can only build properly on ARM if you are using ARM versions of the build tools, like make and CMake.
So, after migrating to an ARM Mac using e.g. Apple's migration tools:
make clean.make.If you still experience build problems after this, delete the whole checkout and check out the code again.
Whether or not that helps, please then open an issue so we can help fix the build.
[!NOTE] See the
vg autoindexexamples below for how to use that tool in place ofvg constructto build and index graphs in a single step.
One way to build a graph with vg is to construct it from variant calls using a reference FASTA file and VCF file. If you're working in vg's test/ directory:
vg construct -r small/x.fa -v small/x.vcf.gz >x.vg
Note that to build a graph, an index of the VCF file is required. The VCF index file can be generated using the tabix command provided by SAMtools (e.g. tabix -p vcf x.vcf.gz on the command line).
You can also build a graph (and indexes for mapping with vg) from a set of genome assemblies (FASTA), as opposed to variant calls as described above, using Minigraph-Cactus.
vg supports many formats, the three most important are:
PackedGraph (.vg) : This is vg's native format. It supports edits of all kinds (to topology and paths), but can be inefficient at large scales, especially with many paths.GFA (.gfa) : GFA is a standard text-based format and usually the best way to exchange graphs between vg and other pangenome tools. vg can also operate on (uncompressed) GFA files directly, by way of using a PackedGraph representation in memory (and therefore sharing that format's scaling concerns and edit-ability).GBZ (.gbz) : GBZ is a highly-compressed format that uses much less space to store paths than the above formats, but at the cost of not allowing general edits to the graph.You can query the format of any graph using vg stats -F.
In general, you will build and index vg graphs using vg autoindex (from GFA or VCF) or Minigraph-Cactus (FASTAs). You can also import GFA files from other tools such as ODGI and PGGB using vg convert -g.
You can convert any graph to GFA using vg convert -f. By default, vg uses GFA v1.1 where paths are represented as W-lines. To use P-lines instead (GFA v1.0), use vg convert -fW.
The GBZ format
No open issues yet, or sync has not completed.