Skip to main content

TFTokenizer

TFTokenizer cuts a chromosome into variable-length tokens from transcription-factor motif hits. Each token records the expected occupancy of every motif inside it.

It builds on the interval tokenizer of Motif-aware Tokenization of the Genome: Towards Interpretable Modeling of Gene Regulation. That tokenizer marks each motif hit as 0/1. TFTokenizer instead weights each hit by its binding strength and merges overlapping hits of a motif into occupancy sites.

Method

  1. Binding strength. A hit of motif m with JASPAR score s gets strength a = exp(β (S − μm)), where S = s / 100 · ln 10 (= −ln p). μm is the 90th percentile of motif m's scores on the training chromosomes, and β = 0.5.
  2. Occupancy sites. Overlapping hits of the same motif (both strands) are merged into one site, with occupancy θ = Σa / (1 + Σa) (capped at 0.99) and load H = −ln(1 − θ). H is spread evenly over the site, so each base carries H / site length.
  3. Bins. The per-base load of all motifs is summed and smoothed (Gaussian, σ = 3). Every peak contributes its two crossings at half its prominence as bin edges. Stretches longer than 50 bp are cut every 25 bp.
  4. Tokens. For each bin and motif, the token value is Σ site load × fraction of the site inside the bin.

Install

pip install tftokenizer

Requires Python ≥ 3.11. Prebuilt wheels are published for Linux (x86_64, aarch64), macOS (Apple silicon, Intel) and Windows (x64), so no Rust toolchain is needed. On other platforms pip builds from source, which needs Rust.

Input

The motif hits of the UCSC JASPAR track, one table per chromosome. TFTokenizer downloads them itself:

tftokenizer download --chroms chr19 chr22      # writes hits/chr19.tsv.gz and hits/chr22.tsv.gz

The track file is large (196 GB for hg38 JASPAR2026), so only the chosen chromosomes are fetched: the records of a chromosome lie together in the file, are located through its index and downloaded in one range request (2.0 GiB for chr22). An interrupted download resumes where it stopped, and tables already there are skipped. Each table is what bigBedToBed -chrom=<chrom> -tsv writes; <chrom>.json next to it records the source, row count and SHA-256.

Options: --data (folder, default hits), --assembly (default hg38), --release (default JASPAR2026) and --mirror (default https://hgdownload.soe.ucsc.edu; the Europe mirror https://hgdownload-euro.soe.ucsc.edu can be faster, depending on the network).

Tables of your own are passed with --hits: tab-separated, optionally gzipped, with a header, sorted by chromStart. Columns used: chrom chromStart chromEnd name score.

Usage

Command line. Without --hits, fit and tokenize first download the missing tables into --data; tokenize downloads the assembly and release the model was fitted on:

tftokenizer fit      --chroms chr19 --model model.npz
tftokenizer tokenize --chroms chr19 chr22 --model model.npz --out tokens

With tables of your own ({chrom} is replaced by each chromosome name):

tftokenizer fit --chroms chr19 --model model.npz --hits 'my_hits/{chrom}.tsv.gz'

Python:

from tftokenizer import TFTokenizer, download

chr19, chr22 = download(["chr19", "chr22"], "hits")
tok = TFTokenizer().fit([(chr19, "chr19")])
tok.save("model.npz")
tok.tokenize(chr22, "chr22", "tokens/chr22")

All tunable values live in Params (tftokenizer/tokenizer.py). examples/quickstart.ipynb reproduces the whole run: download, fit on chr19, tokenize chr19 and chr22, and load the result.

Metadata

Release files for tftokenizer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tftokenizer 0.1.0
File Size Uploaded Provenance Actions
tftokenizer-0.1.0.tar.gz 24.1 kB With provenance Details for tftokenizer-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tftokenizer 0.1.0
File Actions
tftokenizer-0.1.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for tftokenizer-0.1.0-cp311-abi3-win_amd64.whl
tftokenizer-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details for tftokenizer-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl
tftokenizer-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details for tftokenizer-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl
tftokenizer-0.1.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for tftokenizer-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
tftokenizer-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for tftokenizer-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 1.4 MB

Release files / tftokenizer-0.1.0.tar.gz

Download URL tftokenizer-0.1.0.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
275aca1c81e01cb91e0b2955408b12077dbe5c75a03d4dbab8cd78c5f00944af
BLAKE2b-256 checksum
How to use checksums
cba9e798086470e5fb200dd605d2d09eeaf02590bbb6710facd2a127518a5a29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / tftokenizer-0.1.0-cp311-abi3-win_amd64.whl

Download URL tftokenizer-0.1.0-cp311-abi3-win_amd64.whl
Size 200.8 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1b223b0d2798fb1406872737474747314d77cd1503f80de563333911c1818307
BLAKE2b-256 checksum
How to use checksums
090817bdad41a6b66ebab707e47289d87b62757d483feb988df1989dfe52aac0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / tftokenizer-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL tftokenizer-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 310.2 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
cfbde78d43cc8b16b77969fb4bd550f18f2c54193e81c6c82f8cbeac5fd94bfe
BLAKE2b-256 checksum
How to use checksums
d278a1636917724cf51da0a08e8faa2cfe3e4f887e502b4abcc23ba17fc26e94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / tftokenizer-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL tftokenizer-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 306.3 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
f1ce245e888de95198990a6e9b8e70e682459d0adbda42125af7ef2c2e128781
BLAKE2b-256 checksum
How to use checksums
00f3b34487a37dc276cede19d306170d867723c36d7136d373980b5962f5bb9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / tftokenizer-0.1.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL tftokenizer-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Size 276.6 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
317fc747970d0202e891456e0c80e057df53a0f0e8029e7aa31726c721c15b8d
BLAKE2b-256 checksum
How to use checksums
86becd6d4981df7bd6fe5e241661363d8fa799a9f81a4a6f59a59fb7e24a1bc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / tftokenizer-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL tftokenizer-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 289.9 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1d8cb7f53d2183ec3d33465c0f209b14f76c6fb7ae99d94e333f185a23045a81
BLAKE2b-256 checksum
How to use checksums
6e95ef1a3dcd5f44f2359c7befa26edf0ef0c8192c6fc40fd183dd19289ca0b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for tftokenizer 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for tftokenizer-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page