Skip to main content

boltznet

BoltzNet is a biophysically designed neural network that learns a quantitative model of TF-DNA binding energy from ChIP-Seq data. BoltzNet mirrors a quantitative biophysical model and provides directly interpretable predictions genome-wide at nucleotide resolution. We have performed ChIP-Seq mapping of genome-wide DNA binding for 139 E. coli TFs. From these data we have generated BoltzNet models for 124 TFs.

The Boltznet models are described in our publication and through the companion website:

https://boltznet.bu.edu

This python package provides a high-level object interface for downloading pretrained models, running predictions on DNA sequences, and visualizing results.

Installation

Create a conda environment and activate it. Then run:

pip install boltznet
boltznet-init

This installs the package and downloads available models to the package cache dir. To perform selftests, run

boltznet-selftest

This builds a model on all TFs, performs predictions on a set of E. coli promoter sequences, and then generates and saves a plot as selftest_pdhR,pdhR-aceE-aceF-lpd.png. Basically runs a version of the example code in Usage below.

USAGE

You can build a model to make predictions of all (or some) TFs on arbitrary sets of sequences

from boltznet import boltznet_tf

####################################
# create a tfmodel on all TFs that have been loaded into the package cache
####################################
tfmodel=boltznet_tf.create()


####################################################
# load sequences from fasta file and run predictions
# Returns a np.array of predicions at each position on both
# strands of each sequence for all TFs
#
# The numpy array has shape:
# (nseqs,2,seqlen,numtfs)
# - nseqs: number of sequences
# - 2: forward and reverse strands
# - seqlen: length of each sequence
# - numtf: number of models
####################################################
fa_name='test.fa'
y=tfmodel(fastafile=fa_name)


####################################################
# Get scores for each each sequence and tf  
# Scores are the sum of the exponentiated binding energies at every 
# position across both strands
####################################################
sc=tfmodel.getScores()


####################################################
# Get max binding site scores for each each sequence and tf
# The max of the sum of the exponentiated binding energies 
#in windows of length(weigth_matrix)
####################################################
mb=tfmodel.getMaxBindingSiteScores()


####################################################
# load annotations for the sequences for plotting
####################################################
gff_name='ecoli.gff'
tfmodel.loadGff(gff_name)


####################################################
# Plot the predictions for sequences by sequence index or sequence name patterns
# Below will plot sequence number 76 as well as any sequences that 
# contain pdhR in the name.  But will not plot the same sequence twice
# If savefilename is None, generate plots in a window
# If savefilename is given, generate plots named savefilename_<seqid>.png
# 
# Sequences are ranked and percentiled for each model in one of two ways
# according to ranking_mode
#  "full_sequence": TFs ranked by summing exp(wm+bias) over every position on both strands
#  "max_binding_site": sum exp(wm+bias) in ln(wm) windows over seq and take max 
#
# The plot will include tracks for each model in model_names.  If model_names
# is none, then plot the top maxN TFs by normalized score
# The plots include the normalized score and rank for each TF in the titles
####################################################
tfmodel.plotPrediction(inds=[76],seqnames=['aceE'],model_names=None,seqlogo=True,baseseq=False, maxN=5, ranking_mode='max_binding_site', savefilename='test')

You can also create a boltznet_genome object to make predictions on a genome where the genome is loaded as a genbank file or fasta/gff file combo


from boltznet import boltznet_genome

####################################################
# create the model - here using fasta/gff files
####################################################
genome_dict={}
genome_dict['fasta']=fa_name
genome_dict['gff']=gff_name

bngen=boltznet_genome.create(genome_dict)

####################################################
# Load a region
####################################################
start=121606 
stop=122506
bngen.load_region(start,stop)

####################################################
# plot predictions on the loaded region - here for the tf names given
####################################################
tf_names=['pdhR','deoR','tyrR']
bngen.plot_region(start, stop,seqlogo=True,maxN=3,tf_names=tf_names)

####################################################
# get the scores for the tfs on this region
####################################################
sc=bngen.score_region()

Test data

The package comes bundled with two datafiles that can be used for testing:

You can retrieve and use these data files with code like the following:

from importlib import resources
import boltznet.testdata as testdata_pkg

fa_name=resources.files(testdata_pkg).joinpath('promoters.fa')

gff_name=resources.files(testdata_pkg).joinpath('ecoli.gff')

Citation

The code for BoltzNet is freely available for academic use. BoltzNet can be used by molecular biologists seeking to quantitatively predict TF binding, by synthetic biologists seeking to predictively engineer new regulatory interactions, and by computational biologists seeking to develop biophysically motivated bioinformatic tools.

Download files

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

Source Distribution

boltznet-0.5.2.tar.gz (232.1 kB view details)

Uploaded Source

Built Distribution

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

boltznet-0.5.2-py3-none-any.whl (238.7 kB view details)

Uploaded Python 3

File details

Details for the file boltznet-0.5.2.tar.gz.

File metadata

  • Download URL: boltznet-0.5.2.tar.gz
  • Upload date:
  • Size: 232.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for boltznet-0.5.2.tar.gz
Algorithm Hash digest
SHA256 a02be839c677af05b97e732d8c305767c6385e584c4c6c88ac2a9aed4fc6f8f3
MD5 332555899e14f662d1d890b70e57d83f
BLAKE2b-256 899ae74ec6a831b7d3915152329f060bd48a3242bfe111e239eb0378b567376b

See more details on using hashes here.

File details

Details for the file boltznet-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: boltznet-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 238.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for boltznet-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 06e448227496fc140b556472279a760e4ae695c5b29873fd880208e7c59720b3
MD5 cb3739e071ddd4f40eadb61f87be744a
BLAKE2b-256 e298f3fec13ca21cba22b9ac1a68bba1b0bf7296644fb00d8550dbd0eab8ffdd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page