Authors: Dongwon Lee

License: MIT

Contributed by: Roman Kreuzhuber

Cite as: https://doi.org/10.1093/bioinformatics/btw142

Type: None

Postprocessing: None

Trained on: ENCODE ChIP-seq peaks. For training all chromosomes except chr8 and chr9 were used.

Source files

lsgkm-SVM model trained on the ENCODE datasets - no sample number limitation as opposed to gkm-SVM publication. Datasets downloaded from http://ftp.ebi.ac.uk/pub/databases/ensembl/encode/integration_data_jan2011/byDataType/peaks/jan2011/spp/optimal/hub/. All files were then processed using genNullSeqs(...,nMaxTrials=20,xfold=1,genomeVersion="hg19") from the gkmSVM package version 0.79.0. For training all chromosomes except chr8 and chr9 were used.

Create a new conda environment with all dependencies installed
kipoi env create lsgkm-SVM
source activate kipoi-lsgkm-SVM
Test the model
kipoi test lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std --source=kipoi
Make a prediction
kipoi get-example lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std -o example
kipoi predict lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std \
  --dataloader_args='{"intervals_file": "example/intervals_file", "fasta_file": "example/fasta_file"}' \
  -o '/tmp/lsgkm-SVM|Tfbs|Cjun|Huvec|Sydh_Std.example_pred.tsv'
# check the results
head '/tmp/lsgkm-SVM|Tfbs|Cjun|Huvec|Sydh_Std.example_pred.tsv'
Create a new conda environment with all dependencies installed
kipoi env create lsgkm-SVM
source activate kipoi-lsgkm-SVM
Get the model
import kipoi
model = kipoi.get_model('lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std')
Make a prediction for example files
pred = model.pipeline.predict_example(batch_size=4)
Use dataloader and model separately
# Download example dataloader kwargs
dl_kwargs = model.default_dataloader.download_example('example')
# Get the dataloader and instantiate it
dl = model.default_dataloader(**dl_kwargs)
# get a batch iterator
batch_iterator = dl.batch_iter(batch_size=4)
for batch in batch_iterator:
    # predict for a batch
    batch_pred = model.predict_on_batch(batch['inputs'])
Make predictions for custom files directly
pred = model.pipeline.predict(dl_kwargs, batch_size=4)
Get the model
library(reticulate)
kipoi <- import('kipoi')
model <- kipoi$get_model('lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std')
Make a prediction for example files
predictions <- model$pipeline$predict_example()
Use dataloader and model separately
# Download example dataloader kwargs
dl_kwargs <- model$default_dataloader$download_example('example')
# Get the dataloader
dl <- model$default_dataloader(dl_kwargs)
# get a batch iterator
it <- dl$batch_iter(batch_size=4)
# predict for a batch
batch <- iter_next(it)
model$predict_on_batch(batch$inputs)
Make predictions for custom files directly
pred <- model$pipeline$predict(dl_kwargs, batch_size=4)
Get the docker image
docker pull kipoi/kipoi-docker:sharedpy3keras2tf1-slim
Get the full sized docker image
docker pull kipoi/kipoi-docker:sharedpy3keras2tf1
Get the activated conda environment inside the container
docker run -it kipoi/kipoi-docker:sharedpy3keras2tf1-slim
Test the model
docker run kipoi/kipoi-docker:sharedpy3keras2tf1-slim kipoi test lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std --source=kipoi
Make prediction for custom files directly
# Create an example directory containing the data
mkdir -p $PWD/kipoi-example 
# You can replace $PWD/kipoi-example with a different absolute path containing the data 
docker run -v $PWD/kipoi-example:/app/ kipoi/kipoi-docker:sharedpy3keras2tf1-slim \
kipoi get-example lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std -o /app/example 
docker run -v $PWD/kipoi-example:/app/ kipoi/kipoi-docker:sharedpy3keras2tf1-slim \
kipoi predict lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std \
--dataloader_args='{'intervals_file': '/app/example/intervals_file', 'fasta_file': '/app/example/fasta_file'}' \
-o '/app/lsgkm-SVM_Tfbs_Cjun_Huvec_Sydh_Std.example_pred.tsv' 
# check the results
head $PWD/kipoi-example/lsgkm-SVM_Tfbs_Cjun_Huvec_Sydh_Std.example_pred.tsv
    
Install apptainer
https://apptainer.org/docs/user/main/quick_start.html#quick-installation-steps
Make prediction for custom files directly
kipoi get-example lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std -o example
kipoi predict lsgkm-SVM/Tfbs/Cjun/Huvec/Sydh_Std \
--dataloader_args='{"intervals_file": "example/intervals_file", "fasta_file": "example/fasta_file"}' \
-o 'lsgkm-SVM_Tfbs_Cjun_Huvec_Sydh_Std.example_pred.tsv' \
--singularity 
# check the results
head lsgkm-SVM_Tfbs_Cjun_Huvec_Sydh_Std.example_pred.tsv

Schema

Inputs

Single numpy array

Name: seq

    Shape: () 

    Doc: DNA input sequence


Targets

Single numpy array

Name: lsgkmsvm_scr

    Shape: (1,) 

    Doc: lsgkm-SVM score


Dataloader

Defined as: kipoiseq.dataloaders.StringSeqIntervalDl

Doc: Dataloader for a combination of fasta and tab-delimited input files such as bed files. The dataloader extracts regions from the fasta file as defined in the tab-delimited `intervals_file`. Returned sequences are of the type np.array([str]).

Authors: Ziga Avsec , Roman Kreuzhuber

Type: Dataset

License: MIT


Arguments

intervals_file : bed3+<columns> file path containing intervals + (optionally) labels

fasta_file : Reference genome FASTA file path.

num_chr_fasta (optional): True, the the dataloader will make sure that the chromosomes don't start with chr.

label_dtype (optional): None, datatype of the task labels taken from the intervals_file. Example - str, int, float, np.float32

auto_resize_len (optional): None, required sequence length.

use_strand (optional): reverse-complement fasta sequence if bed file defines negative strand. Requires a bed6 file

force_upper (optional): Force uppercase output of sequences

ignore_targets (optional): if True, don't return any target variables


Model dependencies
conda:
  • bioconda::ls-gkm=0.0.1
  • numpy
  • python=3.7
  • numpy=1.19.2
  • pip=20.3.3
  • pysam=0.15.3
  • cython=0.29.23

pip:
  • h5py==2.10.0

Dataloader dependencies
conda:
  • bioconda::pybedtools
  • bioconda::pyfaidx
  • bioconda::pyranges
  • numpy
  • pandas

pip:
  • kipoiseq