Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
V

vg

> 编程语言
Open source

tools for working with genome variation graphs

1.3K stars0 likes0 views
WebsiteGitHub

About

tools for working with genome variation graphs

vg

variation graph data structures, interchange formats, alignment, genotyping, and variant calling methods

Variation graphs provide a succinct encoding of the sequences of many genomes. A variation graph (in particular as implemented in vg) is composed of:

  • nodes, which are labeled by sequences and IDs
  • edges, which connect two nodes via either of their respective ends
  • paths, which describe genomes, sequence alignments, and annotations (such as gene models and transcripts) as walks through nodes connected by edges

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.

Citing VG

Please cite:

  • The VG Paper when using vg
  • The VG Giraffe Paper when using vg giraffe
  • The Long Read Giraffe Paper when using vg giraffe's chaining modes (hifi, r10, chaining-sr)
  • The VG Call Paper when SV genotyping with vg call
  • The GBZ Paper when using GBZ
  • The HPRC Paper when using vg deconstruct
  • The Snarls Paper when using vg snarls
  • The Personalized Pangenome Paper when using vg haplotypes and/or vg giraffe --haplotype-name

Support

We maintain a support forum on biostars: https://www.biostars.org/tag/vg/

Installation

Download Releases

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.

Building on Linux

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.

Linux: Clone VG

First, obtain the repo and its submodules:

git clone --recursive https://github.com/vgteam/vg.git
cd vg

Linux: Install Dependencies

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 parallel
  • hexdump and column from bsdmainutils
  • npm 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.

Linux: Build

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.

Linux: Run

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

Building on MacOS

Mac: Clone VG

The first step is to clone the vg repository:

git clone --recursive https://github.com/vgteam/vg.git
cd vg

Mac: Install Dependencies

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 MacPorts

You 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

Mac: Build

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.

Mac: Run

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.

Migrate a VG installation from x86 to ARM

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:

  1. Uninstall MacPorts and its packages, if they were migrated from the old machine. Only an ARM MacPorts install can be used to provide dependencies for vg on ARM.
  2. Uninstall Homebrew and its packages, if they were migrated. Similarly, only an ARM Homebrew install will work.
  3. Reinstall one of MacPorts or Homebrew. Make sure to use the M1 or ARM version.
  4. Use the package manager you installed to install system dependencies of vg, such as CMake, as documented above.
  5. Clean vg with make clean.
  6. Build vg again with 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.

Usage

Variation graph construction

From VCF

[!NOTE] See the vg autoindex examples below for how to use that tool in place of vg construct to 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).

From Assemblies

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.

Importing and exporting different graph formats

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.

Importing

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.

Exporting

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.

Path Types

The GBZ format

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •_nodes_, which are labeled by sequences and IDs
  • •_edges_, which connect two nodes via either of their respective ends
  • •_paths_, which describe genomes, sequence alignments, and annotations (such as gene models and transcripts) as walks through nodes connected by edges
  • •The VG Paper when using vg
  • •The VG Giraffe Paper when using vg giraffe
  • •The Long Read Giraffe Paper when using vg giraffe's chaining modes (hifi, r10, chaining-sr)
  • •The VG Call Paper when SV genotyping with vg call
  • •The GBZ Paper when using GBZ
  • •The HPRC Paper when using vg deconstruct
  • •The Snarls Paper when using vg snarls

> Tags

C++dnagenome-graphgenomicsgraph

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言