Biologically Informed Neural Network (BINN)
BINN documentation is avaiable here.
The BINN-package allows you to create a sparse neural network from a pathway and input file. The examples presented in docs use the Reactome pathway database and a proteomic dataset to generate the neural network. It also allows you to train and interpret the network using SHAP. Plotting functions are also available for generating sankey plots. The article presenting the BINN can currently be found here.
This repo is accompanied by a Colab notebook for easy use.
Installation
BINN can be installed via pip
pip install binn
The package can also be built from source and installed with git.
git clone git@github.com:InfectionMedicineProteomics/BINN.git
pip install -e BINN/
Usage
The complete pipeline to create, train and interpret a BINN is:
from binn import BINN, BINNDataLoader, BINNTrainer, BINNExplainer
import pandas as pd
# Load your data
data_matrix = pd.read_csv("../data/sample_datamatrix.csv")
design_matrix = pd.read_csv("../data/sample_design_matrix.tsv", sep="\t")
# Initialize BINN
binn = BINN(data_matrix=data_matrix, network_source="reactome", n_layers=4, dropout=0.2)
## Initialize DataLoader
binn_dataloader = BINNDataLoader(binn)
# Create DataLoaders
dataloaders = binn_dataloader.create_dataloaders(
data_matrix=data_matrix,
design_matrix=design_matrix,
feature_column="Protein",
group_column="group",
sample_column="sample",
batch_size=32,
validation_split=0.2,
)
# Train the model
trainer = BINNTrainer(binn)
trainer.fit(dataloaders=dataloaders, num_epochs=100)
# Explain the model
explainer = BINNExplainer(binn)
single_explanations = explainer.explain_single(dataloaders, split="val", normalization_method="subgraph")
single_explanations
The output can be visualized in a network:
from binn.plot.network import visualize_binn
layer_specific_top_n = {"0": 10, "1": 7, "2": 5, "3":5, "4":5}
plt = visualize_binn(single_explanations, top_n=layer_specific_top_n, plot_size=(20,10), sink_node_size=500, node_size_scaling = 200, edge_width=1, node_cmap="coolwarm")
plt.title("Interpreted network")
Cite
If you use this package, please cite: Hartman, E., Scott, A.M., Karlsson, C. et al. Interpreting biologically informed neural networks for enhanced proteomic biomarker discovery and pathway analysis. Nat Commun 14, 5359 (2023). https://doi.org/10.1038/s41467-023-41146-4
@article{BINN,
title = {Interpreting biologically informed neural networks for enhanced proteomic biomarker discovery and pathway analysis},
volume = {14},
ISSN = {2041-1723},
url = {http://dx.doi.org/10.1038/s41467-023-41146-4},
DOI = {10.1038/s41467-023-41146-4},
number = {1},
journal = {Nature Communications},
publisher = {Springer Science and Business Media LLC},
author = {Hartman, Erik and Scott, Aaron M. and Karlsson, Christofer and Mohanty, Tirthankar and Vaara, Suvi T. and Linder, Adam and Malmstr\"{o}m, Lars and Malmstr\"{o}m, Johan},
year = {2023},
month = sep
}
Contributors
Erik Hartman, infection medicine proteomics, Lund University Aaron Scott, infection medicine proteomics, Lund University
Release files for binn 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| binn-0.1.1.tar.gz | 7.4 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| binn-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.8 MB
Release files / binn-0.1.1.tar.gz
| Download URL | binn-0.1.1.tar.gz |
|---|---|
| Size | 7.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a5272b71216624dff1dd95b2b1b2a3829c15615f85d8ad00aba4a6bc5610386
|
|
BLAKE2b-256 checksum How to use checksums |
80c9f99129ff4b0d656f6dadfe40ef6dde7834b49e820b860cce13bc0de8af52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.15
|
Release files / binn-0.1.1-py3-none-any.whl
| Download URL | binn-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3932aa18f8c11adf5ac68aa3e11ccb6faac1a72df7c99f2e301558632497896c
|
|
BLAKE2b-256 checksum How to use checksums |
4e5610e0e2428f0696286b008c5be9cf4d50b43a01b03f4ea49d5ea6c94fe856
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.15
|