Skip to main content

Polars-based I/O and QC toolkit for T-cell receptor (TCR) repertoire datasets.

Project description

tcrio

Polars-based I/O and QC toolkit for T-cell receptor (TCR) repertoire datasets. Fast ingestion of many sequencing formats into a standardized dataset layout, plus QC operations (filtering, diversity, gene-usage, VDJ statistics, overlap, HLA inference, CMV hits).

Install (closed beta)

Beta wheels are attached to GitHub Releases (not on PyPI yet):

pip install <url-to-the-release-wheel>

The wheel bundles the compiled Rust extension and the HLA/CMV model data, so no build tools or extra downloads are needed.

Quick start

import tcr_io

# Build a dataset from a directory of repertoire files
ingester = tcr_io.DatasetIngester(
    db_dir="./my_datasets",
    db_name="example",
    repertoire_mapper=tcr_io.FileNameMapper(),
    patient_mapper=tcr_io.FileNameMapper(),
)
ds = ingester.run("path/to/repertoire/files/*.tsv")

# Run a QC operation
from tcr_io.operations import GeneCountsSummary
ds.run_operation(GeneCountsSummary())
print(ds.get_operation_result("gene_counts_summary"))

Dataset layout

A dataset is a directory with this on-disk structure:

my_dataset/
├── processed_repertoires/      # One parquet per repertoire. Atomic unit.
│   ├── sample_001.parquet      # Standardized schema, repertoire_id column
│   └── sample_002.parquet
│
├── tabulated/                  # Hive-partitioned. Generated, deletable, rebuildable.
│   ├── v_gene=TRBV7-2/
│   │   └── j_gene=TRBJ2-1/
│   │       └── my_dataset.parquet
│   └── ...
│
├── meta/
│   ├── generation.json         # One row per dataset generation. When, how, source, etc.
│   ├── operations.json         # One row per operation performed on this dataset.
│   ├── repertoire/
│   │   ├── repertoire.parquet       # One row per repertoire. IDs, counts, source files, patient_ids.
│   │   └── repertoire_meta.parquet  # Optional extra metadata (join on repertoire_id).
│   ├── patient/
│   │   ├── patient.parquet           # One row per patient. Aggregated stats.
│   │   ├── patient_meta.parquet      # Optional extra metadata (join on patient_id).
│   │   ├── hla.parquet               # Optional. Known HLA typing.
│   │   └── inferred_hla.parquet      # Optional. Computationally inferred.
│   └── publication/
│       ├── publication_ids.json      # DOI(s) / pubmed_id(s) for associated publications.
│       ├── pdfs/                     # Optional publication PDFs.
│       └── publication.parquet       # Generated, fetched metadata cached here.
│
├── qc/                         # Generated. QC metric tables + plots.
│   ├── repertoire_stats.parquet
│   ├── gene_usage.parquet
│   ├── overlap.parquet
│   └── repertoire_stats.png
│
└── README.md                   # Optional. Auto-generated dataset card.

Beta limitations

  • HLA inference (HlaInference, RepertoireHlaInference) and CMV hits (ECOClusterHits) work out of the box — their model data is bundled.
  • MaitHits is not bundled in the beta; pass your own parquet: MaitHits(model_checkpoint="path/to/mait.parquet").

Development

make venv          # create .venv from requirements.txt (dev lockfile)
make install       # maturin develop (build the Rust extension)
make test          # pytest
make pre-commit    # fmt + clippy + ruff + mypy

Bundled resources are generated from raw model sources with python scripts/build_resources.py --build (see model_sources/README.md).

Project details


Download files

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

Source Distribution

tcrio-0.1.0b1.tar.gz (13.3 MB view details)

Uploaded Source

Built Distributions

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

tcrio-0.1.0b1-cp310-abi3-win_amd64.whl (18.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

tcrio-0.1.0b1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

tcrio-0.1.0b1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (18.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

tcrio-0.1.0b1-cp310-abi3-macosx_11_0_arm64.whl (18.0 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tcrio-0.1.0b1-cp310-abi3-macosx_10_12_x86_64.whl (18.3 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file tcrio-0.1.0b1.tar.gz.

File metadata

  • Download URL: tcrio-0.1.0b1.tar.gz
  • Upload date:
  • Size: 13.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for tcrio-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 3af62e74255d0730d205582be358246b2c3707350a224befa951bcce99fef34a
MD5 b1f4fd6bd54975d628d4e59b9f119cbe
BLAKE2b-256 0bfa0776e15fe6c13f3545ca7d51418b50b1d51fe72cef60f9be4f679ef2c871

See more details on using hashes here.

File details

Details for the file tcrio-0.1.0b1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: tcrio-0.1.0b1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 18.2 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for tcrio-0.1.0b1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 41f0ae5789d53c7a08504eb200454c5afefb5d4134206894038c32ef0f52435b
MD5 fa6e392fb88ef71b75c1f25551164c49
BLAKE2b-256 ce8262ee3b9f271388aabff5eb7d90227a868ee23e3e774fc50273463faa6cdc

See more details on using hashes here.

File details

Details for the file tcrio-0.1.0b1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tcrio-0.1.0b1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0553fa7dc874145caeb781c6b094074cca91342897017b740f10fc254efc16bf
MD5 280d5aa9f92aab9697fa587bad3b3a34
BLAKE2b-256 f9b93adfc15a030a3deea46a43e268835b3ac4ccf522ce4b31588b6086435c0f

See more details on using hashes here.

File details

Details for the file tcrio-0.1.0b1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tcrio-0.1.0b1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f62dcfae526c6d0d81e1992894a4ab8d619a5ea2b2de2b16fed13a42cdbca233
MD5 10aa1af763b7048c93c6c205d61bd5f4
BLAKE2b-256 3c1c53c547b9e41cf00d64bd5d0ee064987ca7be038861dba162cef2cae4cab0

See more details on using hashes here.

File details

Details for the file tcrio-0.1.0b1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tcrio-0.1.0b1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cfbd06d82ebb6fe63d8b77c3f6c7857ecac20b300469283a4bee3282c47cf427
MD5 70652da7a6e4fd74bb8c6bfc42994472
BLAKE2b-256 ccdb58fb98f412e10ad25b3b3fc7680e1e1150d9f816b32a4c71d3eaececc112

See more details on using hashes here.

File details

Details for the file tcrio-0.1.0b1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tcrio-0.1.0b1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7909856324adc7b9969ceb45c2643bc5977342c40de0e2926a08b1b3f5bb25ee
MD5 a1c06af4e922cc18bae8aa656f477c08
BLAKE2b-256 616d12dfda6f4a0e5710184aca5a7635c229194a51fdac7c2bc67dc133aee52c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page