BPNet ONNX

11,695 models in ONNX format for predicting protein binding to DNA (ChIP-seq). There are five models (folds) for each of 2,339 experiments.

Original models: Kundaje Lab, using ENCODE data.

Run with ONNX Runtime in Python or ONNX Runtime Web in a browser (WebGPU or WASM). The example below uses Python.

Main files

models/<model-name>/fold_<n>/*.onnx
accepted-manifest.json  # available models and file names
source/  # original model descriptions and results
LICENSE

Inputs and outputs

DNA uses four float32 channels in A, C, G, T order: 1 for the matching base, 0 otherwise. Unknown bases use four zeros. N is the number of sequences.

Name Shape Meaning
sequence [N, 4, 2114] DNA input
profile_controls [N, 2, 1000] Plus/minus control counts at each position
count_controls [N, 2] Natural-log control totals, plus/minus
profile_logits [N, 2, 1000] Scores for each output position
log_counts [N, 1] Log predicted total count (natural log)

The 1,000 predicted bases start 557 bases into the input sequence (human hg38). The two output channels are plus/minus strands sharing one total count. Use measured controls when available, or zeros for sequence-only prediction.

Example

Install huggingface_hub, onnxruntime and numpy.

import json
from pathlib import Path
import numpy as np
import onnxruntime as ort
from huggingface_hub import HfApi, hf_hub_download

repo = "genome-spy/BPNet-ONNX"
revision = HfApi().model_info(repo).sha
listing = hf_hub_download(repo, "accepted-manifest.json", revision=revision)
model = json.loads(Path(listing).read_text())["models"][0]
weights = hf_hub_download(repo, model["artifact"]["path"], revision=revision)

# Replace this example with your 2,114-base DNA sequence.
dna = ("ACGT" * 529)[:2114]
sequence = np.array([[b == a for b in dna] for a in "ACGT"], dtype=np.float32)[None]
feeds = {"sequence": sequence}
feeds["profile_controls"] = np.zeros((1, 2, 1000), dtype=np.float32)
feeds["count_controls"] = np.zeros((1, 2), dtype=np.float32)

session = ort.InferenceSession(weights, providers=["CPUExecutionProvider"])
scores, log_counts = session.run(["profile_logits", "log_counts"], feeds)

# Turn position scores and the total count into expected counts per base.
profile = np.exp(scores - scores.max(axis=(1, 2), keepdims=True))
profile /= profile.sum(axis=(1, 2), keepdims=True)
signal = profile * np.exp(log_counts)[:, :, None]
print(signal.shape)  # (1, 2, 1000)

License

Model weights: MIT. See LICENSE. Original model details and citations are kept in source/.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Collection including genome-spy/BPNet-ONNX