Borzoi

Contents

Borzoi#

The Borzoi model is a large model trained on bulk ENCODE and FANTOM DNase, ChIP-seq, CAGE and RNA-seq data from a wide variety of human and mouse tissues. It predicts 6144 bins of 32bp, corresponding to the core 196608 bp of the input sequence.

It was originally provided based on the Baskerville package, and its weights and architecture have been ported to CREsted. The model was trained on sequences tiled across the genome, which can be found in the original repository, with fold 4 as validation set, test 3 as test set, and the rest as training set. All replicates are trained on the same data folds. The original model has a shared trunk and two organism-specific heads, which are provided as two specific models for human and mouse here, resulting in models borzoi_human_rep0-borzoi_human_rep3 and borzoi_mouse_rep0-borzoi_mouse_rep3. 'borzoi_human' and 'borzoi_mouse' are aliases for 'rep0'.

The model is a CNN+Transformer+Upsampling model using the borzoi() architecture.

Details of the data and the model can be found in the original publication.


Warning

The Borzoi architecture uses custom layers that are serialized inside the CREsted package. To ensure that the model is loaded correctly, make sure that CREsted and specifically crested.tl is imported before loading the model. If it still refuses to load, add MultiheadAttention as a custom object, as in the example.

Citation

Linder, J. et al. Predicting RNA-seq coverage from DNA sequence as a unifying model of gene regulation. Nature Genetics (2025). https://doi.org/10.1038/s41588-024-02053-6

License

The original model is licensed under the Apache License, version 2.0.

Usage#

 1import crested
 2import keras
 3
 4# download model
 5model_path, output_names = crested.get_model("borzoi_human_rep0")
 6
 7# load model
 8model = crested.utils.load_model(model_path)
 9
10# load the model with custom_objects as fallback
11# from crested.tl.zoo.utils._attention import MultiheadAttention
12# model = crested.utils.load_model(
13#     model_path,
14#     custom_objects={
15#         'MultiheadAttention': MultiheadAttention
16#     }
17# )
18
19# make predictions
20sequence = "A" * 524288
21predictions = crested.tl.predict(sequence, model)
22print(predictions.shape)