Skip to main content

TFClassPredict

Python Version TensorFlow License PyPI Docs

Description

TFClassPredict predicts transcription factor binding sites (TFBSs) on the human genome according to their DNA-binding domain, encapsulated in 23 DBD-classes defined by the TFClass class-level hierarchy. By leveraging the DNABERT model, TFClassPredict achieves high predictive performance across all DBD-classes.

Package Workflow Structure

::: {style="text-align:center"} ./workflow_schema.drawio.png :::

Installation

pysam and pyBigWig require system-level build tools. On Ubuntu/Debian, verify their installation before running pip install tfclass_predict:

sudo apt-get install build-essential libcurl4-openssl-dev libssl-dev \
    zlib1g-dev libbz2-dev liblzma-dev libncurses5-dev

The package can be installed via pip:

pip install tfclass_predict

Installation time: typically 1–3 minutes depending on your internet connection and system, as several large dependencies (tensorflow, pysam, pyBigWig) need to be compiled from source.

Required Data

To use TFClassPredict, at least one of the following data sources must be provided:


Option A – Precompiled hg38 Dataset (Recommended)

Using the precompiled dataset is strongly recommended as it drastically reduces runtime and works on virtually any system without requiring a GPU.

Download TFCP_precompiled


Option B – TFClassPredict Model + Reference Genome

Alternatively, the full deep learning model can be used directly together with the human reference genome (hg38).

Download HG38 from UCSC

Download TFCP_model


Note: All downloads must be unzipped before use. Pass the path to the TFCP_precompiled directory, or both the hg38.fa file and the TFCP_model directory, to the command-line tool or PredictionManager. The genome file must be indexed:

samtools faidx hg38.fa

Usage

Command-Line Interface

tfclass_predict [-h] [--genome GENOME] [--precompiled PRECOMPILED]
                [--model MODEL] [--detailed] [--no-normalize]
                [--gpus GPUS] [--cpus CPUS]
                bed_file output_dir

Positional Arguments

Argument Description
bed_file Path to BED file of ATAC-seq or other NGS experiment
output_dir Path to output directory

Optional Arguments

Argument Description
--genome GENOME Path to human genome reference (recommended: hg38) .fa
--precompiled PRECOMPILED Path to precompiled hg38 predictions (unzipped folder)
--model MODEL Path to TFClassPredict model archive (unzipped folder)
--detailed Return per-window predictions instead of per-peak/region predictions
--no-normalize Save raw DBD-class binding site counts instead of standardized TFBPD scores
--gpus GPUS Number of GPUs to use in parallel (default: 1)
--cpus CPUS Maximum number of CPUs to use in parallel (default: 1)

If both --precompiled and --model are specified, the precompiled dataset takes precedence.

Examples

# Using the precompiled dataset (recommended)
tfclass_predict sample.bed results/ --precompiled path/to/TFCP_precompiled

# Using the model and reference genome
tfclass_predict sample.bed results/ --genome hg38.fa --model path/to/TFCP_model

# With multiple GPUs and CPUs
tfclass_predict sample.bed results/ --genome hg38.fa --model path/to/TFCP_model \
    --gpus 4 --cpus 8

# Save raw counts instead of normalized TFBPD scores
tfclass_predict sample.bed results/ --precompiled path/to/TFCP_precompiled --no-normalize

# Return per-window predictions
tfclass_predict sample.bed results/ --precompiled path/to/TFCP_precompiled --detailed

Python API

from tfclass_predict import PredictionManager

bed_file            = "path/to/experiment.bed"
genome_file         = "path/to/hg38.fa"
tfclass_model       = "path/to/TFCP_model"
tfclass_precompiled = "path/to/TFCP_precompiled"
res_dir             = "results/"

# ── Option A: precompiled dataset (recommended) ────────────────────────────
pm = PredictionManager(bed_file, res_dir, precompiled=tfclass_precompiled)
pm.predict()
pm.get_TFBPDs()           # compute normalized TFBPD scores
pm.save_results()         # saves <bed_file>_TFBPDs.csv

# save raw counts instead
pm.save_results(normalized=False)   # saves <bed_file>_DBDcounts.csv

# ── Option B: model + reference genome ────────────────────────────────────
pm = PredictionManager(
    bed_file,
    res_dir,
    genome_file = genome_file,
    tfcp_model  = tfclass_model,
    ngpus       = 1,
    ncpus       = 4,
)
pm.predict()
pm.get_TFBPDs()
pm.save_results()

# ── Detailed mode: per-window predictions ─────────────────────────────────
pm = PredictionManager(bed_file, res_dir, precompiled=tfclass_precompiled, detailed=True)
pm.predict()
pm.save_results(normalized=False)

Output Files

File Description
<name>_TFBPDs.csv Standardized TFBPD scores per region and DBD-class (default)
<name>_DBDcounts.csv Raw DBD-class binding site counts per region

Both files include the original BED coordinates (chr, start, end) as the first three columns, followed by one column per DBD-class.


Tutorial and Further Documentation

Full API documentation including a tutorial is available at ReadTheDocs.


Performance Notes

  • When using TFCP_model, predictions are automatically distributed across multiple GPUs via tf.distribute.MirroredStrategy if --gpus > 1.
  • Setting --cpus > 1 enables parallel sequence tokenization and can significantly reduce preprocessing time for large BED files.
  • The precompiled dataset does not require a GPU and is suitable for standard compute environments.

System Requirements

Precompiled Dataset - Minimum Requirements

Component Requirement
OS Linux
Python 3.9 – 3.11
CPU 4+ cores
RAM 8 GB
Disk ~20 GB (precompiled dataset)
GPU Not required

Full Model - Minimum Requirements)

Component Requirement
OS Linux
Python 3.9 – 3.11
CPU 8+ cores
RAM 32+ GB
Disk ~15 GB (model + genome)
GPU Recommended

Software Dependencies

Package Version
tensorflow >=2.13.0
transformers 4.46.3
numpy
pandas
pysam
pyBigWig
scikit-learn

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tfclass_predict-1.1.6.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

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

tfclass_predict-1.1.6-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file tfclass_predict-1.1.6.tar.gz.

File metadata

  • Download URL: tfclass_predict-1.1.6.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for tfclass_predict-1.1.6.tar.gz
Algorithm Hash digest
SHA256 c07a424b2f7bf51ff49b0a5a6a8e3e920bfde5f52fb2fb3cd9e89d7a02e08724
MD5 c2fcad145c579d3b31668db975433641
BLAKE2b-256 5ba3c2373e5992ca89682640475714185939df46dff42d0e8470131dc23d3b6e

See more details on using hashes here.

File details

Details for the file tfclass_predict-1.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for tfclass_predict-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bbf612b825f432b1bde7c369efa3e26ae553a8a3e5e23a7d7e600b58f9b47938
MD5 6b1334798e791050566bde6c0a4d6fb3
BLAKE2b-256 b61825061432123359db22ff0a26974accf6b7bb8fe4a3bbd0f7d014f51b7dcd

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.7

2 files

This release

1.1.6 This release

2 files

1.1.5

2 files

1.1.4

2 files

1.1.3

2 files

1.1.0

2 files

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