SNPmatch is a Python toolkit which can be used to genotype a sample from as-low-as as 4000 markers from the database lines. SNPmatch can genotype samples efficiently and economically using a simple likelihood approach.
Installation & Usage
The below steps deal with running SNPmatch on a local machine. Also consider using Nextflow when implementing it on your cluster, we have provided best practices scripts here.
Installation using conda
SNPmatch can be easily installed either by conda (provided yml file) or pip. SNPmatch uses various python packages (NumPy, pandas, scikit-allel), which are automatically downloaded. Follow the commands below for successful installation.
## Conda installation, after cloning the repo conda env create -f environment.yml ## or installing SNPmatch from git hub repository pip install git+https://github.com/Gregor-Mendel-Institute/SNPmatch.git ## or PyPi pip install SNPmatch
Database files containing the known genotype information for many strains have to be provided as HDF5 formatted file. These can be generated with given markers or variants present in a VCF file. The database files can be generated with the functions given in SNPmatch. They are generated using the commands given below.
The below commands require BCFtools executable in the path environment. The database files are read using PyGWAS package. So the VCF files need to have biallelic SNPs only for now.
snpmatch makedb -i input_database.vcf -o db
The above command generates three files,
The two hdf5 files are the main database files used for further analysis. The files have the same information but are chunked for better efficiency. The files db.hdf5 and db.acc.hdf5 are given to the SNPmatch command under -d and -e options respectively.
For Arabidopsis thaliana users, we have made SNP database files for the
1001Genomes panel available and can be downloaded here.
If you are working with other genomes, the above command generates a JSON file containing chromosome information. Provide this JSON file in
genotype_cross functions under
As the input file, SNPmatch takes genotype information in two file formats (BED and VCF). Example input files are given in the folder sample_files. Briefly, BED files should be three tab-separated column with chromosome, position and genotype shown below.
1 125 0/0 1 284 0/0 1 336 0/0 1 346 1/1 1 353 0/0 1 363 0/0 1 465 0/0 1 471 0/1 1 540 0/0 1 564 0/0 1 597 0/0 1 612 1/1 1 617 0/1
VCF file in a default format in the link. The main arguments required for SNPmatch are CHROM and POS in header and GT in the INFO column. PL (Normalized Phred-scaled likelihoods of the possible genotypes), if present improves the efficiency of SNPmatch.
SNPmatch can be run as bash commands given below. A detailed manual for each command with -h.
snpmatch inbred -v -i input_file -d db.hdf5 -e db.acc.hdf5 -o output_file # or snpmatch parser -v -i input_file -o input_npz snpmatch inbred -v -i input_npz -d db.hdf5 -e db.acc.hdf5 -o output_file
SNPmatch can be run directly for A. thaliana researchers as a web tool, AraGeno
Output files for inbred
SNPmatch outputs two file,
output_file.scores.txt--- tab-separated file
The column information for the table is strain ID, Number of matched SNPs, Total informative SNPs, Probability of match, Likelihood, Likelihood ratio against best hit, Number of SNPs, Average depth of SNPs respectively. You can filter the strains that do not match the sample by the likelihood ratio value which is chi-square distributed.
output_file.matches.json--- JSON file It might be easier to parse this file using json editor. All the strains that might match to the sample is present in this file. Also a simple interpretation based on the SNPmatch result is provided.
Genotyping a hybrid
SNPmatch can be used to identify hybrid individuals when parental strains are present in database. For such individuals, SNPmatch can be run in windows across the genome. The commands used to run are given below
snpmatch cross -v -d db.hdf5 -e db.acc.hdf5 -i input_file -b window_size_in_bp -o output_file #to identify the windows matching to each parent in a hybrid
These scripts are implemented based on the A. thaliana genome sizes. But please change
--genome option by providing JSON file generated while working with other genomes.
Output files for cross
We have three output files for the cross match in SNPmatch
output_file.scores.txt--- tab-separated file The file is exactly same as explained before. Additionally, F1 simulated results are appended to the file.
output_file.windowscore.txt--- tab-separated file The file provides information on the strains that match to input sample for each window across the genome.
Here columns are strain ID, number of SNPs matched, Informative SNPs, Probability of match, Likelihood, Is the window identical to the line? used a simple binomial test, Number of strains that match at this window, window ID (number starting for 1 covering genome linearly). Filtering this table by column 7 having 1 would result in homozygous windows.
output_file.matches.json--- JSON file
The file containing the list of matched strains, list of homozygous windows and strains matched to them and along with a simple interpretation.
Identifying underlying haplotype for a experimental cross
For a given hybird sample and its parents, SNPmatch can determine the underlying haplotype structure (homozygous or heterozygous).
snpmatch genotype_cross -v -e db.acc.hdf5 -p "parent1xparent2" -i input_file -o output_file -b window_size # or if parents have VCF files individually snpmatch genotype_cross -v -p parent1.vcf -q parent2.vcf -i input_file -o output_file -b window_size
One can implement this by considering a Markhof chain (HMM, requires hmmlearn python package), by running above command using
--hmm. The starting probabilities are based on mendel segregation (1:2:1, for F2), might be necessary to change them when implementing for higher crosses. The transition probability matrix is adapted from R/qtl (Browman 2009, doi:10.1007/978-0-387-92125-9).
The output file is a tab delimited file as below.
The columns are Chromosome ID, start position of window, end position, number of SNPs from sample in a window, number of segregating SNPs, underlying genotype (0, 1, 2 for homozygous parent1, heterozygous and homozygous parent2), likelihood ratio test statistic for each genotype (or number of SNPs each genotype under HMM).
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
- Rahul Pisupati (rahul.pisupati[at]gmi.oeaw.ac.at)
- Ümit Seren (uemit.seren[at]gmi.oeaw.ac.at)
Pisupati, R. et al.. Verification of Arabidopsis stock collections using SNPmatch, a tool for genotyping high-plexed samples. Nature Scientific Data 4, 170184 (2017). doi:10.1038/sdata.2017.184