Skip to main content

A lightweight variant caller for ONT data

Project description

SNP-stitch: lightweight variant calling for ONT data

SNP-stitch (SNP selection by tree-based inference tolerating complex heterogeneity) is a lightweight variant caller designed for use with ONT reads. Given a reference sequence, it uses a random forest regressor model to estimate expected base frequencies at a site in absence of true variation and assigns bases which are more than a tolerance value higher as variants.

Note: SNP-stitch has been primarily designed for, and tested on, data generated by the DDNS protocol for poliovirus detection. Provided pre-trained models have been trained to this protocol and performance may vary for other uses. It is possible given data where the source sequence is known with confidence to train new models with SNP-stitch and use these as input.

Installation

SNP-stitch is available from PyPI and can be installed with the following command:

pip install snp_stitch

Alternatively, the source code in this repository can be cloned and used to build/install locally

git clone
cd snp_stitch
pip install .

Usage

Variant calling

Variant calling requires a reference fasta and reads mapped to the same reference in BAM format. Basic calling is performed as follows:

snp_stitch call -b PATH_TO_BAM_FILE -r PATH_TO_REFERENCE_FASTA -o PATH_TO_OUTPUT directory

An output directory containing a vcf file of all variants will be produced.

Full arguments for variant calling:

usage: snp_stitch call [-h] [-b BAM_PATH] [-r REF] [-o OUTPUT_DIR] [-e TOL] [-f MIN_FREQ] [-m MODELS_PATH] [-p CORES]

  
options:

-h, --help              Show this help message and exit
-b --bam                Path to mapped reads in bam format
-r --reference_fasta    Reference fasta to call variants against
-o --out_dir            Path to directory for output. Default: snp_stitch_output_DATE
-e --tolerance          Tolerance for error when calling variants. Default:0.02
-m --models             Path to dir with model and encoder files
-p --cores              Number of cores to use. Default: 1

Model training

Model training requires reads that have been mapped to a reference you can be confident they represent - the samples sequenced should not contain any true variation relative to the reference sequence the reads have been mapped against. There is an option to include a file specifying sites to be excluded from training if variant sites are known.

The training data directory should be structured as follows:


training_data/
├── dataset1/
│ 	├──reference1.fa
│ 	├──excluded_sites1.bed (optional)
│ 	└──mapped_reads1/
│ 		├── reads1.bam
│ 		├── reads1.bam.bai
│ 		├── reads2.bam
│ 		└── reads2.bam.bai
└── dataset2/
	├──reference2.fa
	├──excluded_sites2.bed (optional)
	└──mapped_reads2/
		├── reads1.bam
		├── reads1.bam.bai
		├── reads2.bam
		└── reads2.bam.bai

Each 'dataset' subdirectory should correspond to a single reference sequence in the fasta file e.g. single chromosomes or single viral genomes

Training is run as follows:

snp_stitch train -d PATH_TO_TRAINING_DATA_DIRECTORY

Full options below, including those that influence the hyperparameters of the model

usage: snp_stitch train [-h] [-d DATA_DIR] [-mo USER_MODELS_PATH] [-mn USER_MODEL_NAME] [-p CORES]
                        [-rt ESTIMATOR_RANGE ESTIMATOR_RANGE] [-rd DEPTH_RANGE DEPTH_RANGE]
                        [-ms MIN_SPLIT_RANGE MIN_SPLIT_RANGE] [-ml MIN_LEAF_RANGE MIN_LEAF_RANGE]
                        [-mi MIN_IMP_RANGE MIN_IMP_RANGE] [-cv FOLDS]

options:
  -h, --help            Show this help message and exit
  -d  --data_dir        Path to datasets to be used in training; must contain reference sequence and mapped reads
  -mo --models_output   Path to dir to store model and encoder files. Default: user_models
  -mn --model_name      Name of subdirectory in models output dir storing this model. Default: new_model
  -p  --cores           Number of cores to use. Default: 1
  -rt --range_trees     Range of estimator counts to consider in the random forest during optimisation. Default 50 175
  -rd --tree_depth      Range of depths to consider in the random forest during optimisation. Default 50 175
  -ms --min_split       Range of values for minimum sample split to consider in the random forest during optimisation. Default: 5 10
  -ml --min_leaf        Range of values for minimum leaf samples to consider in the random forest during optimisation. Default: 3 5
  -mi --min_impurity    Range of values for the minimum impurity decrease to consider in the random forest during
                        optimisation - must be in [0,1]. Default: 0 0.5
  -cv --cv_folds        The number of folds to use for k-folds cross validation during optimisation. Default: 5

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snp_stitch-1.0.0.tar.gz (20.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snp_stitch-1.0.0-py3-none-any.whl (20.7 MB view details)

Uploaded Python 3

File details

Details for the file snp_stitch-1.0.0.tar.gz.

File metadata

  • Download URL: snp_stitch-1.0.0.tar.gz
  • Upload date:
  • Size: 20.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for snp_stitch-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e35c4912421db222567300eec85b672a75449e6dc026bd2a4c3f206783bbe04a
MD5 b5ed255cf88a2404ad5c5827c8e9a717
BLAKE2b-256 9027efadb06ee59f940a38861c53789535601e2bfc7b7209138c53f6f0e30000

See more details on using hashes here.

File details

Details for the file snp_stitch-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: snp_stitch-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for snp_stitch-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8a87ea1442cc3abd7249c67ec900e53b4e7327bf8a8c33f8bbca57b992e539c
MD5 b9bf97c9de9b48fcb403ed96e8ff1f8e
BLAKE2b-256 9c8930f9c035aea4a135469ab47f948a52baddd866e0409e4dfebd5f4ecee4ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page