Keras_dna: simplifying deep genomics
Description:
Keras_dna is an API that helps quick experimentation in applying deep learning to genomics. It enables quickly feeding a keras model (tensorflow) with genomic data without the need of laborious file conversions or storing tremendous amount of converted data. It reads the most common bioinformatics files and creates generators adapted to the keras models.
Use Keras_dna if you need a library that:
- Allows fast usage of standard bioinformatic data to feed a keras model (nowaday standard for tensorflow).
- Helps formatting the data to the model's needs.
- Facilitates the standard evaluation of a model with genomics data (correlation, AUPRC, AUROC)
Read the documentation at keras_dna.
Keras_dna is compatible with: Python 3.6.
Guiding principles:
-
Furnishing a simplified API to create generators of genomic data.
-
Reading the DNA sequence directly and effectively from fasta files, to discard the need of conversion.
-
Generating the DNA sequence corresponding to the desired annotation (can be sparse annotation or continuous), passed with standard bioinformatic files (gff, bed, bigWig, bedGraph).
-
Easily adapting to the type of annotations, their number, the number of different cell types or species.
Getting started:
The core classes of keras_dna are Generator, to feed the keras model with genomical data, and ModelWrapper to attach a keras model to its keras_dna Generator.
Generator creates batches of DNA sequences corresponding to the desired annotation.
First example, a Generator instance that yields DNA sequences corresponding to a given genomical function (here binding site) as the positive class and other sequences as the negative class. The genome is furnished through a fasta file and the annotation is furnished with a gff file (could have been a bed), the DNA is one-hot-encoded, the genomical functions that we want to target need to be passed in a list.
from keras_dna import Generator
generator = Generator(batch_size=64,
fasta_file='species.fa',
annotation_files=['annotation.gff'],
annotation_list=['binding site'])
Second example, a Generator for continuous annotation, this time the annotation is furnished through a bigWig file (it could have been a wig or a bedGraph, but then a file containing the chromosome sizes needs to be passed as size), the desired length of DNA sequences need to be passed. This Generator instance yields all the DNA sequences of length 100 in the genome and labels them with the coverage at the nucleotide at the center.
from keras_dna import Generator
generator = Generator(batch_size=64,
fasta_file='species.fa',
annotation_files=['annotation.bw'],
window=100)
Generator owns a lot of keywords to adapt the format of the data both to the keras model and to the task at hand (predicting the sequences' genomical function in different cellular types, classifying between several different functions, predicting from two different inputs, labelling DNA sequences with both their genomical functions and an experimental coverages...)
ModelWrapper is a class designed to unify a keras model to its generator in order to simplify further usage (prediction, evaluation) of the model.
from keras_dna import ModelWrapper, Generator
from tensorflow.keras.models import Sequential()
generator = Generator(batch_size=64,
fasta_file='species.fa',
annotation_files=['annotation.bw'],
window=100)
model = Sequential()
### the model need to be compiled
model.compile(loss='mse', optimizer='adam')
wrapper = ModelWrapper(model=model,
generator_train=generator)
Train the model with .train()
wrapper.train(epochs=10)
Evaluate the model on a chromosome with .evaluate()
wrapper.evaluate(incl_chromosomes=['chr1'])
Predict on a chromosome with .predict()
wrapper.predict(incl_chromosomes=['chr1'], chrom_size='species.chrom.sizes')
Save the wrapper in hdf5 with .save()
wrapper.save(path='./path/to/wrapper', save_model=True)
Installation:
Dependencies:
- pandas
- numpy
- pybedtools
- pyBigWig
- kipoiseq
- tensorflow 2
We also strongly advice installing genomelake for fast reading of fasta files.
- Install Keras_dna from PyPI:
Note: These installation steps assume that you are on a Linux or Mac environment.
If you are on Windows, you will need to remove sudo to run the commands below.
sudo pip install keras_dna
If you are using a virtualenv, you may want to avoid using sudo:
pip install keras_dna
Note that libcurl (and the curl-config command) are required for installation. This is typically already installed on many Linux and OSX systems (this is also easilya vailable using a conda env, in practise we advise installing pyBigWig with conda before installing keras_dna).
- Alternatively: install Keras_dna from the GitHub source:
First, clone Keras using git:
git clone https://github.com/etirouthier/keras_dna.git
Then, cd to the Keras_dna folder and run the install command:
cd keras_dna
sudo python setup.py install
Metadata
Release files for keras-dna 0.0.46
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| keras_dna-0.0.46.tar.gz | 41.1 kB | Without provenance | Details for keras_dna-0.0.46.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keras_dna-0.0.46-py3-none-any.whl | Python 3 | none | any | Details for keras_dna-0.0.46-py3-none-any.whl |
Total release size: 87.5 kB
Release files / keras_dna-0.0.46.tar.gz
| Download URL | keras_dna-0.0.46.tar.gz |
|---|---|
| Size | 41.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1018b79ec5db0e5e497043d98827239a374497e2116e74291b2798a56ab76376
|
|
BLAKE2b-256 checksum How to use checksums |
e63fd7547f57b696ad18f0b4aed35aed0492cc83d5fbd9cc9eaed96f534bacec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0.post20200209 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10
|
Release files / keras_dna-0.0.46-py3-none-any.whl
| Download URL | keras_dna-0.0.46-py3-none-any.whl |
|---|---|
| Size | 46.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
027b37795be7f2b37e9207c1815b2c41a6077de58e8f127c9187505e4dcbcfd0
|
|
BLAKE2b-256 checksum How to use checksums |
42fc0e22f8e2f53a389d782d504cffac1b975e068c07c4ff2a1bbc79faa950d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0.post20200209 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10
|
Security for keras-dna 0.0.46
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.