TFClassPredict
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.
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.
Option B – TFClassPredict Model + Reference Genome
For non-hg38 genomes, the full deep learning model can be run directly alongside the human reference genome (hg38) as an alternative approach.
Download HG38 from UCSC
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 should be indexed for faster processing, otherwise it will be created within the first run:
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 |
The bed file should contain chromosome names in the UCSC format (i.e. chr1). In case the precompiled model is used, alternative contigs need to be discarded beforehand.
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 viatf.distribute.MirroredStrategyif--gpus > 1. - Setting
--cpus > 1enables 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tfclass_predict-1.1.7.tar.gz.
File metadata
- Download URL: tfclass_predict-1.1.7.tar.gz
- Upload date:
- Size: 33.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8aa4e0ed1546fcb834f63b7efc7f14e76c27d897aa2510d74f47b8198c7072bf
|
|
| MD5 |
fdc15bcb35071f6e6020021fe493c623
|
|
| BLAKE2b-256 |
26d7a74858d448c44232ac6220643fbf9fa2e3e2f1ca42594db5b77214d4d48f
|
File details
Details for the file tfclass_predict-1.1.7-py3-none-any.whl.
File metadata
- Download URL: tfclass_predict-1.1.7-py3-none-any.whl
- Upload date:
- Size: 31.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
859b49714ac7f0bac7ae5acdbc036d61578f1add248cb27010093d0c5cbc82dc
|
|
| MD5 |
7d2f89b3b3773d3143b5adb2ce6b2e04
|
|
| BLAKE2b-256 |
b2292509d30fb30e95c60fec71df65e9f77bfb675b2f9f5b83b8746e75af6e0b
|