Skip to main content

Sequence UNET 1.0.3

DOI Documentation Status

Sequence UNET is a fully convolutional neural network variant effect predictor, able to predict the pathogenicity of protein coding variants and the frequency they occur across large multiple sequence alignments. A description and discussion of the model is available on bioRxiv (Dunham et al. 2022). It uses a U-shaped architecture inspired by the U-NET medical image segmentation network (Ronneberger et al. 2015), with an optional Graph CNN section to incorporate information from protein structure:

Sequence UNET model schematic

This repo contains a python package for downloading and using the trained models as well as code used to train, explore and analyse the models. The package can download, load and predict with 8 variant trained models, which are also available for manual download on BioStudies. The python package is contained in the sequence_unet directory, with documentation in the docs directory. It is also possible to use the modules and scripts used for training and exploring different models, found in analysis, bin and source. The python scripts and modules require adding the src directory to your python path.

Installation

In most cases pip should be able to handle all the dependancies, meaning installation is simple:

pip install sequence_unet

Or the latest development version from GitHub:

pip install git+https://github.com/allydunham/sequence_unet

Manual installation

If pip can't resolve the correct dependancies the requirements might be able to be installed manually:

  1. Install Tensorflow (or tensorflow-macos on M1 Macs): pip install tensorflow or pip install tensorflow-macos
  2. Install other PyPi requirements: pip install numpy pandas biopython tqdm proteinnetpy
  3. Install Sequence UNET: pip install --no-deps sequence_unet

This was needed on M1 Macs before I updated pyproject.toml to use tensorflow-macos for those systems since no versions of Tensorflow were available which matched the requirements. It might help similar compatibility issues too.

Requirements

The python package requires:

  • Python 3+
  • Tensorflow 2.6+
  • Numpy
  • Pandas
  • Biopython
  • TQDM
  • ProteinNetPy

I have tried to maintain as broad requirements as possible but future changes, particularly in Tensorflow, may result in more restrictive version support.

Figure generation and performance analysis was performed in R 4.0, largely using Tidyverse packages. All R packages used are loaded in src/config.R or the top of the respective script.

Basic Usage

Detailed documentation of the modules functions and scripts are available on ReadTheDocs.

Loading Models

Trained models are downloaded and loaded using the sequence_unet.models module, which also provides functions to initialise untrained models. The loaded model is a TensorFlow Keras model, so easily interfaces with other code.

from sequence_unet import models

# Download a trained model
model_path = models.download_trained_model("freq_classifier", root="models", model_format="tf")

# Load the downloaded model via its path. This function can also download the model if not found
model = models.load_trained_model(model=model_path)

# or via name and root
model = models.load_trained_model(model="freq_classifier", root="models")
model.summary()

Prediction

The sequence_unet.predict module provides functions to predict from sequences or ProteinNet files. Other input data can easily be parsed into one of these formats or transformed in Python to fit the models input shapes (described in the models.sequence_unet function).

from pandas import concat
from Bio import SeqIO
from proteinnetpy.data import ProteinNetDataset

from sequence_unet.models import load_trained_model
from sequence_unet.predict import predict_sequence, predict_proteinnet

# load a model
model = load_trained_model(model="freq_classifier", download=True)

# Predict from a fasta file
fasta = SeqIO.parse("path/to/fasta.fa", format="fasta")
preds = concat([p for p in predict_sequence(model, sequences=fasta, wide=True)])

# Predict from a ProteinNet file
data = ProteinNetDataset(path="path/to/proteinnet", preload=False)
preds = concat([p for p in predict_proteinnet(model, data, wide=True)])

The package also binds the sequence_unet command, which allows users to make predictions from the command line. It supports predicting scores for proteins in a fasta or ProteinNet file. A full description is available in the documentation and can be accessed using -h.

Training

The sequence_unet package does not include specific code for training new models, as the best way to do this will be specific to the users needs. However, the loaded models are TensorFlow Keras models and inherently support straightforward and extensible training. I used the training.py script to train the models, based on a saved model and data loading function saved by the make_experiment_dir function in src/utils.py. Usage of the script is documented in it's docstring and can be accessed using -h. The training scripts in subdirectories of models give examples of the model training procedures I used to train the various forms of the model. This setup can be adapted for other users needs reasonably easily.

Metadata

Release files for sequence-unet 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sequence-unet 1.0.3
File Size Uploaded Provenance
sequence_unet-1.0.3.tar.gz 24.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sequence-unet 1.0.3
File Interpreter ABI Platform
sequence_unet-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 49.9 kB

Release files / sequence_unet-1.0.3.tar.gz

Download URL sequence_unet-1.0.3.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
47fe1b875384e55cdce7bf74291e780e06141d2edf09d3e0b928b1220afd429d
BLAKE2b-256 checksum
How to use checksums
1da0c13aa301226742a3b69a83a1a89d42980977e344cfb5284d3437a2560ae5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / sequence_unet-1.0.3-py3-none-any.whl

Download URL sequence_unet-1.0.3-py3-none-any.whl
Size 25.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68d6cd1fe0aefffff533f44f9a39765b8dd7f434cfa2742c1aee4e861573d733
BLAKE2b-256 checksum
How to use checksums
d82b841f3c9eef740fe33f0297acef56011215514cbb8cf30bf0c66a05008fe9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for sequence-unet 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page