Skip to main content

install with bioconda

Genotype Representation Graphs

A Genotype Representation Graph (GRG) is a compact way to store reference-aligned genotype data for large genetic datasets. Computations with GRG can either be performed in a "graph native" way (DFS, BFS, or topological order traversals) or using matrix multiplication, which also supports the standardized matrix and GRM through LinearOperators.

A GRG can be constructed from .vcf.gz, IGD, tskit tree-sequence ARGs, or through Python APIs for node and edge creation.

A GRG contains Mutation nodes (representing variants) and Sample nodes (representing haploid samples), where there is a path from a Mutation node to a Sample node if-and-only-if that sample contains that mutation. These paths go through internal nodes that represent common ancestry between multiple samples, and this can result in significant compression (25-50x smaller than .vcf.gz). Calculations on the whole dataset can be performed very quickly on GRG, using GRGL.

If you use GRG in your research, please cite the initial paper:

DeHaas, Drew, Ziqing Pan, and Xinzhu Wei. "Enabling efficient analysis of biobank-scale data with genotype representation graphs." Nature computational science 5, no. 2 (2025): 112-124.

If you use grapp for PCA, GWAS, LinearOperators, etc., you can cite the recent preprint:

DeHaas, Drew, Chris Adonizio, Ziqing Pan, and Xinzhu Wei. "General, orders-of-magnitude faster whole-genome analysis with genotype representation graphs." bioRxiv (2026).

This preprint also describes improvements in GRGL v2.5: graphs are smaller, faster to construct, and faster for computation.

  • Unlike other graph-based methods (e.g., ARG inference), GRG can be constructed very quickly from tabular datasets, similar to the cost of creating a PLINK2 PGEN file.
  • There is experimental support for unphased data, but it does not compress nearly as well as phased data.
  • Construction from .vcf.gz now supports tabix indexes, making that input format feasible for large datasets
  • Missing data is supported, see the documentation

GRG possible workflows including PCA, GWAS, and arbitrary linear algebra operations

Documentation

Check out the main documentation for core API documentation, examples, tutorials, etc. Things covered in the documentation include:

  • Creating and using GRGs
  • Performing GWAS, PCA, GWAS with covariates, or other analyses with GRG via grapp (pip install grapp)
  • Simulating phenotypes with GRG via grg_pheno_sim (pip install grg_pheno_sim -- see the paper)
  • Using GRG with Python (integration with numpy, pandas, scipy, etc.)

You can also download the tutorials as Jupyter Notebooks and work through them interactively.

Genotype Representation Graph Library (GRGL)

GRGL can be used as a library in both C++ and Python. Support is currently limited to Linux and MacOS. It contains both an API (see docs) and a set of command-line tools.

Installing from pip

If you just want to use the tools (e.g., constructing GRG or converting tree-sequence to GRG) and the Python API then you can install via pip (from PyPi).

pip install pygrgl

This will use prebuilt packages for most modern Linux situations, and will build from source for MacOS. In order to build from source it will require CMake (at least v3.14), zlib development headers, and a clang or GCC compiler that supports C++11.

Installing from conda

You can also install the conda package via the bioconda channel: conda install pygrgl.

Building (Python)

The Python installation installs the command line tools and Python libraries (the C++ executables are packaged as part of this). Make sure you clone with git clone --recursive!

Requires Python 3.7 or newer to be installed (including development headers). It is recommended that you build/install in a virtual environment.

python3 -m venv /path/to/MyEnv
source /path/to/MyEnv/bin/activate
python setup.py bdist_wheel               # Compiles C++, builds a wheel in the dist/ directory
pip install --force-reinstall dist/*.whl  # Install from wheel

Build and installation should take at most a few minutes on the typical computer. For more details on build options, see DEVELOPING.md.

Building (C++ only)

The C++ build is only necessary for folks who want to include GRGL as a library in their C++ project. Typically, you would include our CMake into your project via add_subdirectory, but you can also build standalone as below. Make sure you clone with git clone --recursive!

If you only intend to use GRGL from C++, you can just build it via CMake:

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j4

See below to install the libraries to your system. It is recommended to install it to a custom location (prefix) since removing packages installed via make install is a pain otherwise. Example:

mkdir /path/to/grgl_installation/
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/grgl_installation/
make -j4
make install
# There should now be bin/, lib/, etc., directories under /path/to/grgl_installation/

Building (Docker)

We've included a Dockerfile if you want to use GRGL in a container.

Example to build:

docker build . -t grgl:latest

Example to run, constructing a GRG from an example VCF file:

docker run -v $PWD:/working -it grgl:latest bash -c "cd /working && grg construct --force /working/test/inputs/msprime.example.vcf"

Usage (Command line)

There is a command line tool that is mostly for file format conversion and performing common computations on the GRG. For more flexibility, use the Python or C++ APIs. After building and installing the Python version, run grg --help to see all the command options. Some examples are below.

Convert a tskit tree-sequence into a GRG. This creates my_arg_data.grg from my_arg_data.trees:

grg convert /path/to/my_arg_data.trees my_arg_data.grg

Load a GRG and emit some simple statistics about the GRG itself:

grg process stats my_arg_data.grg

You can also use grapp to see the same stats:

grapp show -i my_arg_data.grg

To construct a GRG from a VCF file, use the grg construct command. (NOTE raw VCF is incredibly slow for non-trivial datasets, use BGZF indexed with tabix or IGD):

grg construct -j 1 path/to/foo.vcf.gz

To convert a VCF(.gz) to an IGD and then build a GRG:

pip install igdtools
igdtools path/to/foo.vcf -o foo.igd
grg construct -j 1 foo.igd

Increase -j to the number of threads you have. igdtools can also use more threads if the VCF is BGZF and tabix indexed. Construction for small datasets (such as those included as tests in this repository) should be very fast, on the order of seconds. Really large datasets (such as Biobank-scale whole genome sequences) can take on the order of hours when using lots of threads (e.g., 70). 1,000 Genomes Project chromosomes usually take on the order of a few minutes.

Usage (Python API)

See the provided jupyter notebooks and GettingStarted.md for more examples.

Limits

Quantity Limit
Haploid samples 2,147,483,646
Total nodes 2,147,483,646
Total mutations (variants) 4,294,967,294
Total edges 18,446,744,073,709,551,615
Edges to/from a single node 4,294,967,295

Note: Node limits can theoretically be expanded to about a trillion, by turning on the LARGE_NODE_IDS preprocessor flag, but this mode is not well tested.

Metadata

Release files for pygrgl 2.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygrgl 2.11
File Size Uploaded
pygrgl-2.11.tar.gz 8.3 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for pygrgl 2.11
File
pygrgl-2.11-cp315-cp315-manylinux_2_24_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.24+ x86-64 Details
pygrgl-2.11-cp314-cp314-manylinux_2_24_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.24+ x86-64 Details
pygrgl-2.11-cp313-cp313-manylinux_2_24_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.24+ x86-64 Details
pygrgl-2.11-cp312-cp312-manylinux_2_24_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.24+ x86-64 Details
pygrgl-2.11-cp311-cp311-manylinux_2_24_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ x86-64 Details
pygrgl-2.11-cp310-cp310-manylinux_2_24_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.24+ x86-64 Details
pygrgl-2.11-cp39-cp39-manylinux_2_24_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.24+ x86-64 Details

Total release size: 23.2 MB

Release files / pygrgl-2.11.tar.gz

Download URL pygrgl-2.11.tar.gz
Size 8.3 MB
Tags Source
SHA-256 checksum
How to use checksums
05a28410aed9c6bda6c7a6631ee9ff1da67085b47f785de7af6c6ebd1d979fc6
BLAKE2b-256 checksum
How to use checksums
3e450285ff0593b1fa307bef4519119ada20d1d18133569b70c233023b1a2bba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / pygrgl-2.11-cp315-cp315-manylinux_2_24_x86_64.whl

Download URL pygrgl-2.11-cp315-cp315-manylinux_2_24_x86_64.whl
Size 2.1 MB
Tags CPython 3.15 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
da39720a8abd865dea1a7f9157eaae19f0c6a8c5237cbd5a468363c4d6bedf6a
BLAKE2b-256 checksum
How to use checksums
9d47834733e901c60a6f2571b2ec0417eb0055310a2debbebd08952e8d1012bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / pygrgl-2.11-cp314-cp314-manylinux_2_24_x86_64.whl

Download URL pygrgl-2.11-cp314-cp314-manylinux_2_24_x86_64.whl
Size 2.1 MB
Tags CPython 3.14 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
3a317f8cc7d23a1b973fe65a1da72e071079d347095248e3574c9e9aa383aa2a
BLAKE2b-256 checksum
How to use checksums
65a7c2094121e60662dc92e8cbd6b337a5f44a0087f9f4be7a9794701dbff49e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / pygrgl-2.11-cp313-cp313-manylinux_2_24_x86_64.whl

Download URL pygrgl-2.11-cp313-cp313-manylinux_2_24_x86_64.whl
Size 2.1 MB
Tags CPython 3.13 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
20b420fa963917d15118c6320e7176b0d4118dcd3333c0854dfbcd2737993c86
BLAKE2b-256 checksum
How to use checksums
0ca01eed4ae40c7dd5a1fea1a599588ab5033f10d9019ea6b24cc5c81f37997e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / pygrgl-2.11-cp312-cp312-manylinux_2_24_x86_64.whl

Download URL pygrgl-2.11-cp312-cp312-manylinux_2_24_x86_64.whl
Size 2.1 MB
Tags CPython 3.12 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
9d9c0a76d74f7aad65adc99df581cc920b0d60a2d4ce0164240d37787f42849b
BLAKE2b-256 checksum
How to use checksums
78ab0fd83efdc013a3b0cdec364c4ecb559ac0903af0fb6c502c0b6a0aa7d7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / pygrgl-2.11-cp311-cp311-manylinux_2_24_x86_64.whl

Download URL pygrgl-2.11-cp311-cp311-manylinux_2_24_x86_64.whl
Size 2.1 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
2515dd18f30a17977242d8f0e8b8e24cf5799af801293207bc473c32337275e2
BLAKE2b-256 checksum
How to use checksums
eff3412096cf629e25d6e65f8ebac473a9203f6663536851d55d006ab1ed90a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / pygrgl-2.11-cp310-cp310-manylinux_2_24_x86_64.whl

Download URL pygrgl-2.11-cp310-cp310-manylinux_2_24_x86_64.whl
Size 2.1 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
1e3327e42cb99ddb24a6b9b6f51222226c4e6f8858c0e506017b534ea280d244
BLAKE2b-256 checksum
How to use checksums
28698a43954b4c7b8e81793068554ea7ef556f264c84e220eeedaeab0a21138e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / pygrgl-2.11-cp39-cp39-manylinux_2_24_x86_64.whl

Download URL pygrgl-2.11-cp39-cp39-manylinux_2_24_x86_64.whl
Size 2.1 MB
Tags CPython 3.9 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
bdf5d911a291fc5f5bac2f735d3563c42146f077a378a7bbf058488db7bce814
BLAKE2b-256 checksum
How to use checksums
96b4e7aaf99f2feb1546701d7dd8de6246ce9bd2fca99a8ffc3a72ab533610b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

2.12

8 release files

This release

2.11 This release

8 release files

2.10

8 release files

2.9

8 release files

2.8

8 release files

2.7

7 release files

2.6

7 release files

2.5

7 release files

2.4

7 release files

2.3

7 release files

2.2

7 release files

2.1

6 release files

2.0

6 release files

1.3

6 release files

1.2

6 release files

1.1

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page