Package: loter
Loter Python packageLoter can be used for haplotype phasing and local ancestry inference.Loter is available under the MIT license. Copyright 2017 - Inria, UGA, CNRS.If you encounter any problem or if you have questions regarding Loter,
please open an issue onGithub,
or you can contact us atloter.dev@inria.fr.RequirementsThe package requires BLAS/LAPACK libraries, OpenMP (optional but recommended for parallel computing), a C++ compiler (tested with g++) and Python 3 (for the Python package). In addition, a version for R is under development.:information_source: When using Python precompiled package for Linux 64bits, only Python 3 is required (other required libraries are included in the precompiled package).InstallationPython packageFrom PyPIRun:pipinstallloter:warning: Precompiled package is only available for Linux 64bits system. On other systems (Linux 32bits, MacOS, Windows), the package will need to be compiled at installation. You must prepare your system by installing all requirements (c.f.previous section) including OpenMP (mandatory for installation withpip, seebelowif you do not have OpenMP).From precompiled package (only for Linux 64bits)Go to the release page onGithuband download theloter-*.whlfile corresponding to your Python version, then install Loter by running:pipinstallloter-*.whlNote:replaceloter-*.whlby the full name of the file you downloaded.From sourcesTo get Loter sources:gitclonehttps://github.com/bcm-uga/Loter.gitTo install theloterPython package:# go to package source dircdLoter/python-package/# installpipinstall-e.# orpythonsetup.pyinstallThe following Python packages will be installed during the process as dependencies:numpy,pandas,scikit-learn,scipy. If not, you may have to install them before installingloter, for instance with the commandpip install numpy pandas scikit-learn scipy.To installloterlocally and avoid messing with your system, you can do:pythonsetup.pyinstall--useror you can use a Python virtual environment (recommended) or a specific Python distribution like Anaconda.If you do not have OpenMP on your system (especially for MacOS users), you can do:pythonsetup.pyinstall--no_openmp# orpythonsetup.pyinstall--user--no_openmpR packageA version of Loter will be soon available for R.:warning: The development of the version for R is currently paused.Using Loter Python packageHere are some details about how to run Loter for local ancestry inference (LAI) [1] and haplotype phasing [2].Local Ancestry Inference (LAI)Local ancestry inference with Loter (see [1] for details) in Python is explained in the following Jupyter notebook tutorial:Local Ancestry Exampleand correspondingmarkdown transcription.To access it, you can do:# install jupyter (if not available)pipinstalljupyter# go to package source dircdLoter/python-package/# run jupyterjupyternotebookNote:The tutorial requires the following additional Python packages:matplotlibandscikit-allel(you can runpip install matplotlib scikit-allelto get them).In addition, here is a small example of local ancestry inference with Loter:importosimportnumpyasnp# admixed haplotypesH_adm=np.load(os.path.expanduser("FILE1"))# replace FILE1 by your data file name# ref 1 haplotypesH_ref1=np.load(os.path.expanduser("FILE2"))# replace FILE2 by your data file name# ref 2 haplotypesH_ref2=np.load(os.path.expanduser("FILE3"))# replace FILE3 by your data file name# Loter local ancestry inference moduleimportloter.locanc.local_ancestryaslc## Loter with bagging and phase correction moduleres_loter=lc.loter_smooth(l_H=[H_ref1,H_ref2],h_adm=H_adm,num_threads=8)## set the number of threads## Loter with bagging onlyres_loter=lc.loter_local_ancestry(l_H=[H_ref1,H_ref2],h_adm=H_adm,num_threads=8)## set the number of threadsNote:More details are given in thenotebook,
especially how to load data from VCF files if your data are not available as Numpy arrays.Simulations of admixed individuals:informations about data simulation are availablehere.Comand line toolWith the Python package installation comes a command line interfaceloter_cliforlocal ancestry inferencethat allows you to directly call Loter
from the command line without writing your own Python script.It requires that your haplotype input data are stored as saved Numpy arrays,
in csv text files (experimental) or in VCF files. In any case, your input
haplotype matrices should be organised as follows: with haplotypes (samples)
in rows and SNPs in columns. Ancestries of admixed haplotypes inferred by Loter
will be stored in the same way.# helploter_cli-h# examples run in Loter project root directorycdLoter# Loter with baggingloter_cli-rdata/H_ceu.npydata/H_yri.npy-adata/H_mex.npy-fnpy-otmp.npy-n8-v# Loter with bagging and phase correctionloter_cli-rdata/H_ceu.npydata/H_yri.npy-adata/H_mex.npy-fnpy-otmp.npy-n8-pc-vImportant:When using text format (csv) for input data, missing values should be encoded as 255 or NA.PhasingTwo methods to run the package to phase genotypes into haplotypes (see [2] for details):importosimportnumpyasnp# Directly run the C++ functionimporthaplophase.wrapper_cppashapG=np.load(os.path.expanduser("FILE"))# replace FILE by your data file nameG_res=np.copy(G)H=hap.wrapper_all(G=G_res,k=k,nb_iter=20,nb_run=10,w=100,penalty=2.0)# You get the imputed genotype matrix in G_res and H the haplotypes.# You can create your own pipeline or select one already existingimporthaplophase.pipelineaspipelineG=np.load(os.path.expanduser("FILE"))l_res=pipeline.pipelines["classic_pipeline"].run(np.copy(G),nbrun=10,nb_iter=20,nb_run=10,w=100,penalty=2.0)# You get a list of results that you can combine.G_res=combine.combiner_G["G vote"](l_res)H_res=combine.combiner_H["H_mean"](l_res)References[1] Dias-Alves, T., Mairal, J., Blum, M.G.B., 2018. Loter: A Software Package to Infer Local Ancestry for a Wide Range of Species. Mol Biol Evol 35, 2318–2326.https://doi.org/10.1093/molbev/msy126[2] Dias Alves, T., 2017. Modélisation du déséquilibre de liaison en génomique des  populations par méthodes l’optimisation. PhD manuscript. Grenoble Alpes University.http://www.theses.fr/2017GREAS052