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.

Bundled models

All model-based operations work out of the box — their reference data ships inside the wheel and loads automatically with no arguments:

  • HlaInference / RepertoireHlaInference — HLA inference
  • ECOClusterHits — CMV EcoCluster hits
  • MaitHits — MAIT hits

Each also accepts model_checkpoint=<path> to override with your own model.

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.0b2.tar.gz (13.4 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.0b2-cp310-abi3-win_amd64.whl (18.4 MB view details)

Uploaded CPython 3.10+Windows x86-64

tcrio-0.1.0b2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.1 MB view details)

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

tcrio-0.1.0b2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (18.6 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

tcrio-0.1.0b2-cp310-abi3-macosx_11_0_arm64.whl (18.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tcrio-0.1.0b2-cp310-abi3-macosx_10_12_x86_64.whl (18.4 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for tcrio-0.1.0b2.tar.gz
Algorithm Hash digest
SHA256 5a495e6f7cddb0ff920a4db53157e0ebf8d55d314396015161f0dfd49d96963e
MD5 713a31763078a629459a2eca8a9fd9ae
BLAKE2b-256 45231ec9fe262b2e575b9d291e4efab8b6ae138695ff5cbdec363f1bae3812eb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tcrio-0.1.0b2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 18.4 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.0b2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f0a8b7f23bb992b5c96fc2c15a08b89bab025342d2eeb12e5dfc55b431b57e74
MD5 11f034e0c2c09f6772ed71dfa6b6f618
BLAKE2b-256 a9b2807ed87c9ab8bfc3a0a06677ccdd6f16752ba1d5028e7eea250e114ddaaf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tcrio-0.1.0b2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea634dcfa59eec6aaed8224a39b0e8027a70bd461e75f215abd5209b1d72c002
MD5 b54465e3d37143a854dadc9345956a58
BLAKE2b-256 16ad353cbad8322838e0e400ce34d7ba3f10d7d3b5cf902b5755bd8bbefdf31f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tcrio-0.1.0b2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e0e3026f6fb3692fab3baf29433b8759071f2ea01a2438c5983b97e9d7ffa173
MD5 ac525c5e5c991d7df29b23585183c650
BLAKE2b-256 4674257a79e99af10a7d628b200722317bf21beefb256a440bcb5cfa803e3091

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tcrio-0.1.0b2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f79628b0f304ab81c13b7de0508ef0301b69eb1646dec8ce3cf85144c08390de
MD5 05d6a9930b8262d05e98bf6ea0875365
BLAKE2b-256 1dfd42cc5255f46a5d9ce25c41e5387013645e596150b9f254a959628146cd44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tcrio-0.1.0b2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c12c67eda8aaf7a0dd85420adb528ae737440d89a236e49e967665c92b843ff9
MD5 b9ce8a4f1c4ea2b8f7579bfb7f43d7ee
BLAKE2b-256 79c55752f776bf4483ad5d259139c30e8f144c0e17b9c18b78f0567690727459

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