Instructions to use multimolecule/bpnet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MultiMolecule
How to use multimolecule/bpnet with MultiMolecule:
pip install multimolecule
from multimolecule import AutoModel, AutoTokenizer tokenizer = AutoTokenizer.from_pretrained("multimolecule/bpnet") model = AutoModel.from_pretrained("multimolecule/bpnet") - Notebooks
- Google Colab
- Kaggle
File size: 6,643 Bytes
fca42c1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | ---
language: dna
tags:
- Biology
- DNA
license: agpl-3.0
datasets:
- multimolecule/bpnet-oskn
library_name: multimolecule
---
# BPNet
Base-resolution convolutional neural network for predicting transcription-factor binding profiles from DNA sequence.
## Disclaimer
This is an UNOFFICIAL implementation of [Base-resolution models of transcription-factor binding reveal soft motif syntax](https://doi.org/10.1038/s41588-021-00782-6) by Žiga Avsec, Melanie Weilert et al.
The OFFICIAL repository of BPNet is at [kundajelab/bpnet](https://github.com/kundajelab/bpnet).
> [!TIP]
> The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
**The team releasing BPNet did not write this model card for this model so this model card has been written by the MultiMolecule team.**
## Model Details
BPNet is a convolutional neural network (CNN) trained to predict base-resolution transcription-factor binding signal (ChIP-nexus) from primary DNA sequence. It uses a convolutional motif stem followed by a stack of dilated residual convolutions that aggregate ~1 kb of genomic context.
BPNet predicts a single base-resolution signal task whose output is factorized into two terminal branches that share the dilated-convolution backbone:
- a **profile** branch predicting the _shape_ of the binding signal as per-position multinomial logits, trained with a multinomial negative log-likelihood;
- a **count** branch predicting the _total magnitude_ of the signal as a scalar per task and strand (in log space), trained with mean-squared error.
The usable base-resolution prediction recombines the two branches as `softmax(profile_logits, positions) * exp(count_logits)`, exposed via `BPNetForProfilePrediction.postprocess`. Please refer to the [Training Details](#training-details) section for more information on the training process.
### Model Specification
| Num Layers | Hidden Size | Num Parameters (M) | FLOPs (G) | MACs (G) |
| ---------- | ----------- | ------------------ | --------- | -------- |
| 10 | 64 | 0.13 | 0.24 | 0.12 |
### Links
- **Code**: [multimolecule.bpnet](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/bpnet)
- **Weights**: [multimolecule/bpnet](https://huggingface.co/multimolecule/bpnet)
- **Data**: [BPNet manuscript data](https://zenodo.org/records/4294904)
- **Paper**: [Base-resolution models of transcription-factor binding reveal soft motif syntax](https://doi.org/10.1038/s41588-021-00782-6)
- **Developed by**: Žiga Avsec, Melanie Weilert, Avanti Shrikumar, Sabrina Krueger, Amr Alexandari, Khyati Dalal, Robin Fropf, Charles McAnany, Julien Gagneur, Anshul Kundaje, Julia Zeitlinger
- **Original Repository**: [kundajelab/bpnet](https://github.com/kundajelab/bpnet)
## Usage
The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
```bash
pip install multimolecule
```
### Direct Use
You can use this model directly to predict transcription-factor binding profiles of a DNA sequence:
```python
>>> from multimolecule import DnaTokenizer, BPNetForProfilePrediction
>>> tokenizer = DnaTokenizer.from_pretrained("multimolecule/bpnet")
>>> model = BPNetForProfilePrediction.from_pretrained("multimolecule/bpnet")
>>> output = model(**tokenizer("ACGTNACGTN", return_tensors="pt"))
>>> output.keys()
odict_keys(['profile_logits', 'count_logits'])
>>> output["profile_logits"].shape
torch.Size([1, 10, 8])
>>> output["count_logits"].shape
torch.Size([1, 8])
>>> track = model.postprocess(output)
>>> track.shape
torch.Size([1, 10, 8])
```
The recombined `track` is the usable base-resolution prediction. The last dimension stacks `num_tasks` (Oct4, Sox2, Nanog, Klf4) by `num_strands` (forward, reverse).
## Training Details
BPNet was trained to predict the base-resolution ChIP-nexus binding profiles of the pluripotency transcription factors Oct4, Sox2, Nanog and Klf4 in mouse embryonic stem cells.
### Training Data
The published BPNet-OSKN model was trained on ChIP-nexus profiles for Oct4, Sox2, Nanog and Klf4, using 1 kb genomic windows centered on detected binding peaks. The training regions and trained Keras checkpoint are distributed as part of the [BPNet manuscript data](https://zenodo.org/records/4294904).
### Training Procedure
#### Training
The model was trained with a composite loss: a multinomial negative log-likelihood on the per-position profile shape plus a mean-squared-error regression on the log total counts.
- Backbone: 1 motif convolution (64 filters, kernel 25, ReLU) + 9 dilated residual convolutions (64 filters, kernel 3, dilations 2, 4, 8, …, 512, ReLU)
- Profile head: per-task transposed convolution (kernel 25) producing per-position logits
- Count head: per-task global average pooling + linear layer producing log-count scalars
- Optimizer: Adam
## Citation
```bibtex
@article{avsec2021baseresolution,
author = {Avsec, {\v{Z}}iga and Weilert, Melanie and Shrikumar, Avanti and Krueger, Sabrina and Alexandari, Amr and Dalal, Khyati and Fropf, Robin and McAnany, Charles and Gagneur, Julien and Kundaje, Anshul and Zeitlinger, Julia},
title = {Base-resolution models of transcription-factor binding reveal soft motif syntax},
journal = {Nature Genetics},
volume = 53,
number = 3,
pages = {354--366},
year = 2021,
publisher = {Nature Publishing Group},
doi = {10.1038/s41588-021-00782-6}
}
```
> [!NOTE]
> The artifacts distributed in this repository are part of the MultiMolecule project.
> If you use MultiMolecule in your research, you must cite the MultiMolecule project as follows:
```bibtex
@software{chen_2024_12638419,
author = {Chen, Zhiyuan and Zhu, Sophia Y.},
title = {MultiMolecule},
doi = {10.5281/zenodo.12638419},
publisher = {Zenodo},
url = {https://doi.org/10.5281/zenodo.12638419},
year = 2024,
month = may,
day = 4
}
```
## Contact
Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
Please contact the authors of the [BPNet paper](https://doi.org/10.1038/s41588-021-00782-6) for questions or comments on the paper/model.
## License
This model implementation is licensed under the [GNU Affero General Public License](license.md).
For additional terms and clarifications, please refer to our [License FAQ](license-faq.md).
```spdx
SPDX-License-Identifier: AGPL-3.0-or-later
```
|