Skip to main content

Tree-based visualization for high-dimensional data

Project description

Tests PyPI Python 3.11+

TMAP2

Tree-based visualization for high-dimensional data. Organizes similar items into interactive tree structures — ideal for chemical space, protein embeddings, single-cell data, or any high-dimensional dataset.

A modernized reimplementation of the original TMAP with an sklearn-style API, multiple distance metrics, and interactive visualization.

Your Data
   ├─→ MinHash → LSHForest        (Jaccard)
   └─→ USearch                    (Cosine / Euclidean / other metrics)
                ↓
             k-NN Graph → MST → OGDF Tree Layout → Interactive Visualization

Installation

pip install tmap2

Optional extras:

pip install rdkit          # chemistry helpers (fingerprints_from_smiles, molecular_properties)
pip install jupyter-scatter # notebook interactive widgets

Note: The import name is tmap, not tmap2.

Quick Start

import numpy as np
from tmap import TMAP

# Binary fingerprints (Jaccard)
X = np.random.randint(0, 2, (1000, 2048), dtype=np.uint8)
model = TMAP(metric="jaccard", n_neighbors=20, seed=42).fit(X)
model.to_html("map.html")
# Dense embeddings (cosine / euclidean)
X = np.random.random((1000, 128)).astype(np.float32)
model = TMAP(metric="cosine", n_neighbors=20).fit(X)
new_coords = model.transform(X[:10])

Visualization

Interactive HTML Export

Interactive HTML features

  • Lasso selection (Shift + drag)
  • Light / dark theme toggle
  • Filter and search side panels
  • Pinned cards for metadata, structures, and links
  • Binary mode for large datasets

Notebook Widgets

Notebook controls demo

Color switching, categorical filtering, and lasso selection with pandas-backed metadata:

viz = model.to_tmapviz()
viz.add_color_layout("Molecular Weight", mw.tolist(), categorical=False)
viz.add_color_layout("Scaffold", scaffolds, categorical=True, color="tab10")
viz.add_label("SMILES", smiles_list)
viz.show(width=1000, height=620, controls=True)

Lasso Selection + DataFrame Integration

Lasso and dataframe integration

Domain Utilities

Built-in helpers for common scientific workflows:

from tmap.utils.chemistry import fingerprints_from_smiles, molecular_properties
from tmap.utils.proteins import fetch_uniprot, sequence_properties
from tmap.utils.singlecell import from_anndata
Domain Metric Utilities
Chemoinformatics jaccard fingerprints_from_smiles, molecular_properties, murcko_scaffolds
Proteins cosine / euclidean fetch_uniprot, fetch_alphafold, read_pdb, sequence_properties
Single-cell cosine / euclidean from_anndata, cell_metadata, marker_scores
Generic embeddings cosine / euclidean / precomputed No domain utils needed

Lower-Level Pipeline

For direct control over MinHash, LSH Forest, and layout stages:

from tmap import MinHash, LSHForest
from tmap.layout import LayoutConfig, layout_from_lsh_forest

mh = MinHash(num_perm=128, seed=42)
signatures = mh.batch_from_binary_array(X)

lsh = LSHForest(d=128, l=64)
lsh.batch_add(signatures)
lsh.index()

cfg = LayoutConfig(k=20, kc=50, deterministic=True, seed=42)
x, y, s, t = layout_from_lsh_forest(lsh, cfg)
# x, y = coordinates; s, t = tree edge indices

Key Features

  • Deterministic: same input + seed = same output
  • Multiple metrics: jaccard, cosine, euclidean, precomputed
  • Incremental: add_points() and transform() for new data
  • Model persistence: save() / load()
  • Three viz backends: interactive HTML, jupyter-scatter, matplotlib

Development

git clone https://github.com/afloresep/TMAP.git
cd TMAP
pip install ".[dev]"
pytest -v

License

MIT License - see LICENSE for details.

Based on the original TMAP by Daniel Probst and Jean-Louis Reymond.

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

tmap2-0.1.0.tar.gz (4.4 MB view details)

Uploaded Source

Built Distributions

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

tmap2-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

tmap2-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (903.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

tmap2-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

tmap2-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (903.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

tmap2-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

tmap2-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (903.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file tmap2-0.1.0.tar.gz.

File metadata

  • Download URL: tmap2-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tmap2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f69f6e43a13009599ef28f5e8f03221778df205ae440ee0b5009db96cefc81db
MD5 03b6df63632a6f03cfb1b05f4ec73801
BLAKE2b-256 8e332e7bbbdc09e7506c78b1187e786b8e14b3eaed218d133fab2270b3b57cc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tmap2-0.1.0.tar.gz:

Publisher: publish.yml on afloresep/TMAP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tmap2-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tmap2-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3506b98d0ca18b23eeeca3bed1d40ad4e913cf4e07c39a900b604e876befded6
MD5 2e4a4fa07f6d11c15a9f192e17b9b12d
BLAKE2b-256 c7f14d3b1b88622590974894e1f59dbc21f7b2d83555e6b4c76af556499d837c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tmap2-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish.yml on afloresep/TMAP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tmap2-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tmap2-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0a7ae813c00d66b56894c9b58a23b71c6ac950caad2fa41cec11521f05c8ad6
MD5 91bb355993d635e3251541823d5f7a0d
BLAKE2b-256 a3dbbffa17f2a9a6d2286c5a5b4d8b9575388f637b517619a18edb8d50894f1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tmap2-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on afloresep/TMAP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tmap2-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tmap2-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d869fb8d3279e8e38bb9ebf4d843356bce9804ffe97e4a005136eb6443fc4d5f
MD5 2b69342b4ad8ccc930ba7736b847589a
BLAKE2b-256 48100627be6e878222fda538d7e7bbfc0691f1c5c4df86f27828a8936bdbf267

See more details on using hashes here.

Provenance

The following attestation bundles were made for tmap2-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish.yml on afloresep/TMAP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tmap2-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tmap2-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 493013623fbc3168c506f2138ff28f827fdb3d2bcb9b89c1c8395d36fc2600b9
MD5 9c059c37e5471baf7402ac1bf872c2c2
BLAKE2b-256 6fb88dd65b26f1a1c2c182825d8d503b4d627a43c1019d1478c934b668bfa490

See more details on using hashes here.

Provenance

The following attestation bundles were made for tmap2-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on afloresep/TMAP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tmap2-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tmap2-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7d67596b18c0335f8b0513b8ed0d786b0407423d0b10778b2151db194c07be30
MD5 676a8f24fad0e2bd4cd65e5cbd369d5a
BLAKE2b-256 ea5412c547433d2a76b515d622aab8a70ed8b3d44d58ffa5997175755f9dd17d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tmap2-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish.yml on afloresep/TMAP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tmap2-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tmap2-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7489ac1ad7fbe8a85820ce649514de192a50128e294db535cb24984061f0dd03
MD5 06fffb540c6b1f648552e333beaccfe4
BLAKE2b-256 377692b304895efde47b2a78ddfc7fea37f561f944ae2dd41940d5d934337b9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tmap2-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on afloresep/TMAP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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