Skip to main content

Phylogenetic placement via BiosphereAtlas hyperbolic coordinates

Project description

atlas-place

Phylogenetic placement via BiosphereAtlas hyperbolic coordinates.

Drop-in replacement for pplacer / GTDB-Tk classify_wf. Every query sequence gets a BiosphereAtlas (r, θ) coordinate and a conformal three-zone decision (accept / escalate / fallback) with formal coverage guarantees.

How it works

sequence → embedding → nearest-prototype → calibrated placement
  1. Encode: DNA sequence → Poincaré ball embedding via BiosphereCodec
  2. Index: O(log n) nearest-prototype lookup via hyperbolic VP-tree
  3. Place: Ranked candidates with geodesic distance and margin
  4. Calibrate: Conformal prediction → three-zone decision with coverage guarantee P(correct) ≥ 1−ε

Quick start

from atlas_place import place_sequences, ReferenceDB

ref = ReferenceDB.load("reference.pkl")
results = place_sequences("input.fasta", ref)

for r in results:
    print(f"{r.sequence_id}\t{r.best_placement.taxon_id}\t{r.zone}\t{r.confidence:.3f}")

CLI

# Basic placement
atlas-place place input.fasta -r reference.pkl -o placements.tsv

# V13 checkpoint placement (end-to-end FASTA -> embedding)
atlas-place place input.fasta -r reference.pkl \
  --model /zfs_raid/SentryBio/working/checkpoints/v13_living_geometry/best.pt \
  --tokenizer /zfs_raid/SentryBio/working/inference_data/bpe_vocab.json \
  --device cuda

# pplacer-compatible output
atlas-place place input.fasta -r reference.pkl --format jplace -o placements.jplace

# Hierarchical mode (top-down through ranks)
atlas-place place input.fasta -r reference.pkl --mode hierarchical

# Reference database info
atlas-place info -r reference.pkl

# Build reference DB from manifest + V13 checkpoint
atlas-place build-ref \
  --manifest /zfs_raid/SentryBio/working/v10_1_tokenized/v10_1_manifest.csv \
  --model /zfs_raid/SentryBio/working/checkpoints/v13_living_geometry/best.pt \
  --tokenizer /zfs_raid/SentryBio/working/inference_data/bpe_vocab.json \
  --split train \
  --rank family \
  --device cuda \
  --output v13_reference_family.pkl

Output columns

Column Description
sequence_id Query identifier
classification Best-match taxon
rank Taxonomic rank of best match
lineage Full lineage string (;-separated)
distance Geodesic distance to nearest prototype
margin Gap between 1st and 2nd nearest (discrimination signal)
zone Conformal zone: accept / escalate / fallback
confidence Calibrated placement confidence ∈ [0, 1]
prediction_set_size Conformal prediction set size (1 = singleton)
atlas_r Hyperbolic radial coordinate (distance from LUCA)
atlas_theta Angular coordinate in BiosphereAtlas (r, θ) space
n_candidates Number of candidate placements returned

Three-zone decisions

Zone Condition Meaning
accept A ≤ q_accept High-confidence singleton placement
escalate q_accept < A ≤ q_fallback Prediction set of plausible taxa
fallback A > q_fallback Abstain — escalate to coarser rank

The nonconformity score A combines nearest distance, margin, and evolutionary depth:

A = d_best − η·margin + ρ·r_evolutionary

Conformal quantiles use finite-sample correction: q = ⌈(n+1)(1−ε)⌉ / n

Geometry

All operations use the Poincaré ball model with curvature κ = 1.247 (Fenn & Fenn 2025). Ball radius R = 1/√κ ≈ 0.896.

The coordinate system is shared with atlas-chimera and atlas-hplg:

  • r = hyperbolic distance from origin (LUCA)
  • θ = angular coordinate (phylogenetic direction)

Architecture

atlas_place/
├── hyperbolic.py    # Poincaré ball geometry (κ=1.247)
├── reference.py     # Reference database (prototype store + taxonomy)
├── index.py         # VP-tree + brute-force spatial index
├── placer.py        # Core nearest-prototype placement engine
├── calibrator.py    # Conformal calibration (three-zone decisions)
├── encoder.py       # BiosphereCodec/V13 wrapper (+ k-mer dev proxy)
├── place.py         # Main pipeline orchestration
├── build_reference.py # Manifest -> reference prototype builder
├── io.py            # FASTA/TSV/JSON/.jplace I/O
└── cli.py           # Command-line interface

Installation

pip install atlas-place

With atlas-hplg integration:

pip install atlas-place[hplg]

Requirements

  • Python ≥ 3.9
  • PyTorch ≥ 2.0
  • NumPy ≥ 1.24
  • BioPython ≥ 1.80

License

MIT — Sentry Bio Inc.

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

atlas_place-1.0.0.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

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

atlas_place-1.0.0-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file atlas_place-1.0.0.tar.gz.

File metadata

  • Download URL: atlas_place-1.0.0.tar.gz
  • Upload date:
  • Size: 33.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for atlas_place-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0b8d7096994172bf12ac3febaca99df1732ec6a06e74b3189176f81c0b1655fd
MD5 8809313695449f0bcb66f73422a16285
BLAKE2b-256 b367e91513f43d3b667fb2fee6216f2bc54ac25e6151ddbc33b974ac52452db7

See more details on using hashes here.

File details

Details for the file atlas_place-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: atlas_place-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for atlas_place-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73ca8c29693585588a82a0817ae423a3c73388fe5430e09c1b609136596752f5
MD5 59bff4b27742d068ea958d9573b5078e
BLAKE2b-256 546d0de0291f7e224accacfd9468adc66ce002013550ae7d21a693804cef733c

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