All the features, in one place.
TMAP is a small library with a lot of capabilities. This page is the complete catalog, grouped by what you'd use each feature for. Click [preview ▸] on any row to see it in action.
Interactive viewer.
Every TMAP compiles to a self-contained HTML file (or a local server for the really big ones). Here's everything in the viewer.
# stream a 100M-node map instead of a 2GB HTML file
model.serve(port=8080)A single class, sklearn-style.
The 2.0 API collapses the old multi-step pipeline into one model object. If you've ever used scikit-learn, you already know how to use TMAP.
from tmap import TMAP
model = TMAP(metric="cosine", seed=42).fit(X)TMAP(metric="jaccard") # binary fingerprints
TMAP(metric="cosine") # embeddings
TMAP(metric=my_callable) # custommodel.add_points(X_new)coords = model.transform(X_new) # (n, 2) arraymodel.save("map.pkl")
model = TMAP.load("map.pkl")model = TMAP().fit_from_knn(knn_graph)The tree is a graph you can query.
Because TMAP produces an actual spanning tree - not a lossy 2D projection - you can run exact graph queries on it.
d = model.distance("a", "b")tree = model.tree_
# boundary edges: tree edges whose endpoints fall in different classes
crossings = [(u, v) for u, v in tree.edges if y[u] != y[v]]
sizes = tree.subtree_sizes() # subtree size rooted at every nodeNotebook, paper, or dataframe.
Three output formats, one model. Pick whichever fits the stage you're at.
model.show() # interactive scatter in the celldf = model.to_dataframe()
# columns: x, y, parent, properties...Batteries included.
TMAP ships with helpers for three common domains, so you rarely need to write boilerplate. Skip this section if you're working with generic vectors.
from tmap.chem import mol_to_mhfp
X = [mol_to_mhfp(smi) for smi in smiles]from tmap.bio import fetch_alphafold, esm_embed
X = esm_embed(sequences)from tmap.sc import from_anndata
model = from_anndata(adata, metric="cosine")One command.
No more C++ build dance. OGDF ships as a prebuilt extension inside the Python package.
pip install tmap2