Metadata-Version: 2.4
Name: immundapter
Version: 0.2.0a1
Summary: tcrdist3 distances and clustering for Polars receptor tables.
Author-email: Vadim Nazarov <support@immunomind.com>
License-Expression: Apache-2.0
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.26
Requires-Dist: pandas
Requires-Dist: polars>=1.25.2
Requires-Dist: scipy
Requires-Dist: tcrdist3<0.4,>=0.3
Dynamic: license-file

# immundapter

`immundapter` calculates tcrdist3 distances and clusters from Polars receptor tables on Python 3.14 or later.

```sh
python -m pip install .
```

On Apple Silicon, the Parasail dependency builds from source. Install Xcode Command Line Tools and `autoconf`, `automake`, and `libtool` if the build tools are missing.

```python
import polars as pl

from immundapter import tcrdist3_cluster, tcrdist3_distances

receptors = pl.DataFrame({
    "receptor_id": ["r1", "r2"],
    "cdr3_b_aa": ["CASSLGQAYEQYF", "CSARDRGNTIYF"],
    "v_b_gene": ["TRBV7-9*01", "TRBV20-1*01"],
    "j_b_gene": ["TRBJ2-7*01", "TRBJ1-2*01"],
})

result = tcrdist3_distances(receptors)
clusters = tcrdist3_cluster(result, radius=20)
```

Give each receptor a unique, non-null `receptor_id`. Use the `cdr3_a_aa`, `v_a_gene`, and `j_a_gene` columns for alpha chains. For paired alpha and beta distances, put both chains on one row and pass `chains=["alpha", "beta"]`. The default is human beta. Pass `organism="mouse"` for mouse receptors.

`result.distances` is a dense NumPy matrix for up to 5,000 distinct feature rows. `result.receptor_to_row` is a Polars table that maps each receptor to its zero-based matrix row. Receptors with identical selected features share a matrix row.

`clusters` is a Polars table with one row per input receptor. Receptors in the same cluster connect through distances at or below `radius`.
