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.3.0b4.tar.gz (13.5 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.3.0b4-cp310-abi3-win_amd64.whl (18.5 MB view details)

Uploaded CPython 3.10+Windows x86-64

tcrio-0.3.0b4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.2 MB view details)

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

tcrio-0.3.0b4-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.3.0b4-cp310-abi3-macosx_11_0_arm64.whl (18.2 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tcrio-0.3.0b4-cp310-abi3-macosx_10_12_x86_64.whl (18.5 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file tcrio-0.3.0b4.tar.gz.

File metadata

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

File hashes

Hashes for tcrio-0.3.0b4.tar.gz
Algorithm Hash digest
SHA256 8836979e5940403164fc5c9b0cdeb0c2441db3d4d5b630b92a2528452a04a8d5
MD5 7c957ea72b96147a2f741fe24a08995f
BLAKE2b-256 0646fda929ed24238b613ddff46d29047df0ed1f69c1f647a6c8f0ecf010e418

See more details on using hashes here.

File details

Details for the file tcrio-0.3.0b4-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: tcrio-0.3.0b4-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 18.5 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.3.0b4-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9677065f0ab560eea5d85cfa4a74ffb68bfcb8ae4d7117eea38ca297dec57de4
MD5 204f03cb2ccb5b532c0d6b39a4932abd
BLAKE2b-256 a16b3f80f38b3dc6653dda140f3ff4ec9ca85e90ee384999b25d775c9fed01b9

See more details on using hashes here.

File details

Details for the file tcrio-0.3.0b4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tcrio-0.3.0b4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd8514dc7e02a3ffea24d7b72f0d7cbcf8f9fe85c1eee8bf1665db837ccdbd56
MD5 eb2a57b58a148bc2e69702956d95c729
BLAKE2b-256 61c03c796215203e09b94658757a986288079a11ce60ce3d6b19983e1fe62403

See more details on using hashes here.

File details

Details for the file tcrio-0.3.0b4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tcrio-0.3.0b4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 de54be275e1e5add8ef0c4c937021bdf282ef2e5ffc7a94f1f407ff93e700c7a
MD5 28fa0bde015cffecbca79ecd17d35891
BLAKE2b-256 174e165259114f721f5ddcde7512e9d0dba0b14e3a5600f8817af25edc53bb7a

See more details on using hashes here.

File details

Details for the file tcrio-0.3.0b4-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tcrio-0.3.0b4-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d628f0baa44282a21c393ed2caff5193832d3ee513ded703e04181a3bbe3711
MD5 68644a98128f578acfe79f228521ccf3
BLAKE2b-256 413ae7d24913df637d805140afcffe3fbca4547dc8a8bb2097f29664e81c536f

See more details on using hashes here.

File details

Details for the file tcrio-0.3.0b4-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tcrio-0.3.0b4-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b7a50641a808722bf100a2bc11b9671425acec95d49bbe45a79c1a6da24e0f7d
MD5 a54beffe7ae69e6430cb15d869dc4035
BLAKE2b-256 859a194450b2567fb85ef3ddd831b70bc23d41637b89401457459bc58ae3301f

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