Skip to main content

PyTFBS

A Python package for predicting transcription factor binding sites.

Installation

pip install torch numpy pandas scipy PyTFBS

Usage

from PyTFBS import motif, predict, clink
import random
random.seed(42)

# download PyTFBS data, only need to run once!!!
motif.download_data()

# list available models
motif.list_models(species='Homo sapiens', accuracy=0.9, sensitivity=0.8, specificity=0.9, precision=0.8, f1=0.8)

# get avaiable motifs
motifs = motif.get_motifs(species='Homo sapiens', accuracy=0.9, sensitivity=0.8, specificity=0.9, precision=0.8, f1=0.8)
print(motifs)

# get models based on motif name
models = motif.get_models('RFX2_HUMAN.H11MO.0.A')
print(models)

# predict one model
predict.script('CEBPB_HUMAN.H11MO.0.A', 'CEBPB_HUMAN.H11MO.0.A', 'input_seq_file.fasta', 'out_file.txt')

# speed up using mutil-threading (for Windows OS only)
predict.win_bin('CEBPB_HUMAN.H11MO.0.A', 'CEBPB_HUMAN.H11MO.0.A', 'input_seq_file.fasta', 64, 'out_file.txt')

# run prediction with user motif data
# the my_motif_dir should be organized as [[motif], [trace], [par]]
predict.script('CEBPB_HUMAN.H11MO.0.A', 'CEBPB_HUMAN.H11MO.0.A', 'input_seq_file.fasta', data_dir='my_motif_dir')
predict.win_bin('CEBPB_HUMAN.H11MO.0.A', 'CEBPB_HUMAN.H11MO.0.A', 'input_seq_file.fasta', 64, data_dir='my_motif_dir')

# create the CLink TF-target set

# rexp_files = get_rexp_files()
# print(rexp_files)

df_rexps = clink.read_rexp_file()
tf_cnames = clink.read_tf_cname()
tf_code = 'CREB1_HUMAN.H11MO.0.A_RC'
tf_tars = clink.read_PyTFBS_output(tf_code + '_output.txt')

for tf_cname in tf_cnames[tf_code]:
	if tf_cname[1] not in df_rexps.index:
		continue
	else:
		tf_exp = df_rexps.loc[tf_cname[1]].values.tolist()
	df_rexps_tars = df_rexps[df_rexps.index.isin(tf_tars)]
	tar_exps = {idx: row.tolist() for idx, row in df_rexps_tars.iterrows()}
	rcis = clink.rci(tar_exps, tf_exp)
	for rci in rcis:
		score = rci[1] * (1 + (random.uniform(1E-5, 1.0) / 1E10))
		print(tf_cname[0] + '\t' + rci[0] + '\t' + str(score))

Metadata

Release files for PyTFBS 1.0.9

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

Source distribution (sdist)

Source distribution for PyTFBS 1.0.9
File Size Uploaded
pytfbs-1.0.9.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyTFBS 1.0.9
File Interpreter ABI Platform
pytfbs-1.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / pytfbs-1.0.9.tar.gz

Download URL pytfbs-1.0.9.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8709f052ad21a9dce672bd8672cac3f4b3733a7619bbf8c80626d8ac27542a07
BLAKE2b-256 checksum
How to use checksums
9f137496436440955184bbab24b47a1d7e1d74e9d53fa61c09d15b47e41ab4cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / pytfbs-1.0.9-py3-none-any.whl

Download URL pytfbs-1.0.9-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23f8a37ef15bc396ae3eb09f726cbf9cc36db23f90382df3a16d64d52d19b872
BLAKE2b-256 checksum
How to use checksums
f87489cdd88c1a3eb43dc943b386d44cf9b3ffc8769754b1621ca12138166941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release history Release notifications | RSS feed

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

This release

1.0.9 This release

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release 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