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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygrgl-2.10.tar.gz (8.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pygrgl-2.10-cp315-cp315-manylinux_2_24_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.15manylinux: glibc 2.24+ x86-64

pygrgl-2.10-cp314-cp314-manylinux_2_24_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64

pygrgl-2.10-cp313-cp313-manylinux_2_24_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64

pygrgl-2.10-cp312-cp312-manylinux_2_24_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64

pygrgl-2.10-cp311-cp311-manylinux_2_24_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64

pygrgl-2.10-cp310-cp310-manylinux_2_24_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64

pygrgl-2.10-cp39-cp39-manylinux_2_24_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64

File details

Details for the file pygrgl-2.10.tar.gz.

File metadata

  • Download URL: pygrgl-2.10.tar.gz
  • Upload date:
  • Size: 8.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for pygrgl-2.10.tar.gz
Algorithm Hash digest
SHA256 61c37909b241d42ccf16ea8dff1e7f619080cd0a3751871d964b4c112e486ed4
MD5 e49c1a02de0713a261081989ab294995
BLAKE2b-256 b31ffc14a9cbd0131e734c7eaa2f4282fbc67d33cedc5c2a4e513939c9bd7a7b

See more details on using hashes here.

File details

Details for the file pygrgl-2.10-cp315-cp315-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for pygrgl-2.10-cp315-cp315-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 56b7ed2e2d0c2a81e3d9e92f6421922ac900c190e5997f9eed0ae874cd4875df
MD5 854ae50ddc16141441856193fd499916
BLAKE2b-256 cb16c4ff58ed90683bc5e28c53d78eb4f9b707b3c976d86e780e78b7e4780e0b

See more details on using hashes here.

File details

Details for the file pygrgl-2.10-cp314-cp314-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for pygrgl-2.10-cp314-cp314-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 7d6e343b12a950382664c94aca81fe54077dcf2dd3c12fcda54ff5d0e0c38426
MD5 c4a27415ddfb9ffa077ad6dd30d42c6a
BLAKE2b-256 3e806af2a2bf02773c57985f67c37d985c33d5d12f4d679b0ebc56862039fbeb

See more details on using hashes here.

File details

Details for the file pygrgl-2.10-cp313-cp313-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for pygrgl-2.10-cp313-cp313-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 e2d265690066557dcbca5e4f2660c7a97d0e51a3e945d0eea74d212ab5644652
MD5 46cf5044554478ebd9050f90602a5774
BLAKE2b-256 f8a7cb7983cb65a2726979c2b1ccaddb02a7c7fadff00b1e49923145cb6d8767

See more details on using hashes here.

File details

Details for the file pygrgl-2.10-cp312-cp312-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for pygrgl-2.10-cp312-cp312-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 17ef2dabae9c7b9bff8ee091edef8dce17dbdcd3cd5b04c904954990ef974a8c
MD5 424ac348a4579cccee4fe273de00811b
BLAKE2b-256 3bf2c0fc51a12a31c8f6fa9c6e99f83d731d5d7366cc473485cfa9678784d27a

See more details on using hashes here.

File details

Details for the file pygrgl-2.10-cp311-cp311-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for pygrgl-2.10-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 e54887e8757fa47a2ce62c24e87f9de0934905a30b34c6454862ebafca205b92
MD5 930fae08ad218e38debe70c72581cbe7
BLAKE2b-256 f64fa270de2e7060fdf962b01aa6d939b1be3a654c4fb535eab0f4ffaf1273c8

See more details on using hashes here.

File details

Details for the file pygrgl-2.10-cp310-cp310-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for pygrgl-2.10-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 8e928aae8c95176b293ed181fc7533a4d3320096ff79456c8f6cde1c99980fbe
MD5 cdca1091b6af69d9ae3925e0592257ac
BLAKE2b-256 e43c35759dfa53d5cc2292c668f25e81eb1c8c7f5d4c9c94b496826948e2e20b

See more details on using hashes here.

File details

Details for the file pygrgl-2.10-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for pygrgl-2.10-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 3643630249aba218eb141edf3841189292424219f57c8ecc212df6276dea0cc9
MD5 930899ed149192c83aea8df33b1571b6
BLAKE2b-256 aacf4110831d820046313d543a542468f6d0ceb64ff4bba7564b05dc99bd37bd

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.10 This release

8 files

2.9

8 files

2.8

8 files

2.7

7 files

2.6

7 files

2.5

7 files

2.4

7 files

2.3

7 files

2.2

7 files

2.1

6 files

2.0

6 files

1.3

6 files

1.2

6 files

1.1

6 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