Skip to content
antigenomicsPublic

Repository files navigation

vdjtools

vdjtools — immune-repertoire analysis

PyPI CI docs python license

Get started · Guides · Commands · API · Examples · Glossary

Read receptor tables, measure diversity and overlap, fit recombination models, and export statistical feature tables or published corpus signatures. vdjtools is a Python/C++ rewrite of the original Groovy/Java tool, using AIRR column names and Polars frames. arda, seqtree and vdjmatch supply the shared native/reference engines.

Install

pip install vdjtools

Prebuilt CPython wheels include the native extension. A source install needs a C++ toolchain. Optional extras include [overlap] for sample MDS, [sc] for single-cell bridges and [examples] for marimo notebooks. See getting started.

Quickstart

from vdjtools import io, stats   # import before numerical libraries

sample = io.read("clones.tsv")
diversity = stats.diversity_stats(sample)
v_usage = stats.segment_usage(sample, "v")
vdjtools diversity samples/*.tsv -o diversity.tsv
vdjtools features samples/*.tsv --coverage 0.8 --threads 1 -o features.tsv
vdjtools signature --corpus blood samples/*.tsv -o vsig.tsv

features exports unrotated measurements and channels without a corpus. Declared log/CLR/logit transforms remain; “raw” means before corpus scaling, winsorization and PCA. signature applies the published vsig corpus transform. These are different outputs. mirpy's rsig geometry half joins vsig on sample_id; mirpy's sample RFF vectors are a separate representation.

Fit your own sample PCA on selected measurements, compatible control rows, or reuse a saved rotation:

vdjtools pca features.tsv --columns feature_columns.txt --fit rotation.npz --components 32 -o pcs.tsv
vdjtools pca new_features.tsv --rotation rotation.npz -o new_pcs.tsv

The raw feature/PCA guide explains feature selection, coverage, imputation, feature-space identities and saved rotations.

Find the right page

Task Guide
Load, measure and compare your first samples Getting started
Filter, correct, downsample or pool Pre-processing
Diversity, overlap, gene usage, biomarkers and dynamics User guide
Unrotated features and optional sample PCA Raw features
Published vsig/rsig corpus coordinates Signatures · Methods · Channels
Pgen, generation and model fitting Model workshop
Single-cell data and interoperability Single cell
Functions, flags, examples and terms API · Commands · Examples · Glossary

Recorded performance measurements and model validation describe the native Pgen, generation and inference engines.

Resource budgets

Import vdjtools before numerical libraries in a fresh interpreter. Native batch APIs use allocation-aware CPU budgets; sample workers use serial inner kernels. Signature --jobs and analysis --threads select bounded workers, with 0 for the detected allocation. Excessive or nested budgets raise. The final feature table and PCA workspace still grow with sample count and feature width. See CPU/container limits.

Development

bash setup.sh --dev-parents --tests
source .venv/bin/activate
uv pip install -e ".[docs]"
pytest tests/python -q -m "not slow and not heavy and not benchmark"
env -C docs make html

Uses a repo-local uv environment and a C++ toolchain. See the API reference for public functions and the model workshop for native model workflows.

Citing

For the v2 rewrite, cite this repository. For the original tool, cite Shugay et al., PLoS Computational Biology 2015. The VDJtrack recapture model in vdjtools.dynamics is Pavlova, Zvyagin and Shugay (2024).

License

GPL-3.0-or-later. The legacy Groovy/Java v1.x tool lives on the legacy-1.x branch, with its releases under the repository tags v0.0.1 … 1.2.1.

Releases

Used by

Contributors

Languages