Package: ezancestry
ezancestryEasily visualize your direct-to-consumer genetics next to 2500+ samples from the 1000 genomes project. Evaluate the performance of a custom set of ancestry-informative snps (AISNPs) at classifying the genetic ancestry of the 1000 genomes samples using a machine learning model.A subset of 1000 Genomes Project samples' single nucleotide polymorphism(s), or, SNP(s) have been parsed from thepublicly available.bcffiles.The subset ofSNPs, AISNPs (ancestry-informative snps), were chosen from two publications:Set of 55 AISNPs.Progress toward an efficient panel of SNPs for ancestry inference. Kidd et al. 2014Set of 128 AISNPs.Ancestry informative marker sets for determining continental origin and admixture proportions in common populations in America.. Kosoy et al. 2009 (Seldin Lab)ezancestry ships with pretrained k-nearest neighbor models for all combinations of following:* Kidd (55 AISNPs)
* Seldin (128 AISNPs)

* continental-level population (superpopulation)
* regional population (population)

* principal component analysis (PCA)Table of ContentsInstallationConfigUsagecommand line toolfetchpredictplottrainPython APIVisualizationContributingInstallationInstall ezancestry with pip:pipinstallezancestryOr clone the repository and runpip installfrom the directory:gitclonegit@github.com:arvkevi/ezancestry.gitcdezancestry
pipinstall.ConfigThe first timeezancestryis run it will generate aconfig.inifile anddata/directory in your home directory under${HOME}/.ezancestry.
You can editconf.inito change the default settings, but it is not necessary to use ezancestry. The settings are just a utility for the user so they don't have to be verbose when interacting with the software. The settings are also keyword arguments to each of the commands in the ezancestry API, so you can always override the default settings.These will be created in your home directory:${HOME}/.ezancestry/conf.ini${HOME}/.ezancestry/data/Explanations of each setting is described in the Options section of the--helpof each command, for example:ezancestrypredict--help

Usage:ezancestrypredict[OPTIONS]INPUT_DATAPredictancestryfromgeneticdata.*Defaultargumentsarefromthe~/.ezancestry/conf.inifile.*

Arguments:INPUT_DATACanbeafilepathtorawgeneticdata(23andMe,ancestry.com,.vcf)file,apathtoadirectorycontainingseveralrawgeneticfiles,ora(taborcomma)delimitedfilewithsampleidsasrowsandsnpsascolumns.[required]Options:--output-directoryTEXTThedirectorywheretowritethepredictionresultsfile--write-predictions/--no-write-predictionsIfTrue,writethepredictionstoafile.IfFalse,returnthepredictionsasadataframe.[default:True]--models-directoryTEXTThepathtothedirectorywherethemodelfilesarelocated.--aisnps-directoryTEXTThepathtothedirectorywheretheAISNPsfilesarelocated.--aisnps-setTEXTThenameoftheAISNPsettouse.Tostart,chooseeither'Kidd'or'Seldin'.Thedefaultvalueinconf.iniis'Kidd'.*IfusingyourAISNPset,thisvaluewillbetheinthenamingconventionforallthenewmodelfilesthatarecreated*--helpShowthismessageandexit.Usageezancestry can be used as a command-line tool or as a Python library.ezancestry predictcomes with pre-trained models when--aisnps-set=kiddor--aisnps-set=seldin.`command-line interfaceThere are four commands available:fetch: generate a csv file with all the 1000 Genome samples (rows) at the specified AISNPs locations (columns).predict: predict the genetic ancestry of a sample or cohort of samples using the nearest neighbors model.plot: plot the genetic ancestry of samples using the output ofpredict.train: build a k-nearest neighbors model from the 1000 genomes data using a custom set of AISNPs.Use the commands in the following way:predictezancestry can predict the genetic ancestry of a sample or cohort of samples using the nearest neighbors model.
Theinput_datacan be a file path to raw genetic data (23andMe, ancestry.com, .vcf) file, a path to a directory containing several raw genetic files, or a (tab or comma) delimited file with sample ids as rows and snps as columns.This writes a file,predictions.csvto theoutput_directory(defaults to current directory). This file contains predicted ancestry for each sample.Direct-to-consumer genetic data file (23andMe, ancestry.com, etc.):ezancestrypredictmygenome.txtDirectory of direct-to-consumer genetic data files or .vcf files:ezancestrypredict/path/to/genetic_datafilescomma-separated file with sample ids as rows and snps as columns, filled with genotypes as valuesezancestrypredict${HOME}/.ezancestry/data/aisnps/thousand_genomes.KIDD.dataframe.csvplotVisualize the output ofpredictusing theplotcommand. This will open a 3d scatter plot in a browser.ezancestryplotpredictions.csvfetchThis command will download all of the data required to build a new nearest neighbors model for a custom set of AISNPs. If you want to use existing models, seepredictandplot.Without any arguments this command will download all necessary data to build new models and put it in the${HOME}/.ezancestry/data/directory.ezancestryfetchNow you are ready to build a new model withtrain.trainTest the discriminative power of your custom set of AISNPs.This command will build all the necessary models to visualize and predict the 1000 genomes samples as well as user-uploaded samples. A model performace evaluation report will be generated for a five-fold cross-validation on the training set of the 1000 genomes samples as well as a report for the holdout set.Create a custom AISNP file here:~/.ezancestry/data/aisnps/custom.AISNP.txt. The prefix of the filename,custom, can be whatever you want. Note that this value is used as theaisnps-setkeyword argument for other ezancestry commands.The file should look like this:id      chromosome      position
rs731257        7       12669251
rs2946788       11      24010530
rs3793451       9       71659280
rs10236187      7       139447377
rs1569175       2       201021954ezancestrytrain--aisnps-set=customPython APISee thenotebookVisualizationOpen in StreamlitContributingContributions are welcome! Please feel free to create an issue for discussion or make a pull request.