{"id":45919942,"url":"https://github.com/edgardomortiz/vcf2phylip","last_synced_at":"2026-02-28T08:36:49.376Z","repository":{"id":37382067,"uuid":"106477340","full_name":"edgardomortiz/vcf2phylip","owner":"edgardomortiz","description":"Convert SNPs in VCF format to PHYLIP, NEXUS, binary NEXUS, or FASTA alignments for phylogenetic analysis","archived":false,"fork":false,"pushed_at":"2023-07-07T08:28:47.000Z","size":139,"stargazers_count":232,"open_issues_count":5,"forks_count":80,"subscribers_count":8,"default_branch":"master","last_synced_at":"2023-10-25T17:13:56.687Z","etag":null,"topics":["alignment","binary","convert-snps","diploid","fasta","haploid","nexus","outgroup","phylip","phylip-matrix","phylogenetic-analysis","phylogenetics","polyploid","snapp","snps","vcf","vcf-files","vcf-format"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edgardomortiz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-10-10T22:16:01.000Z","updated_at":"2023-10-24T05:55:13.000Z","dependencies_parsed_at":"2022-07-08T07:39:55.810Z","dependency_job_id":"d94c281e-5f17-46d0-9ba7-1d41f3937b25","html_url":"https://github.com/edgardomortiz/vcf2phylip","commit_stats":null,"previous_names":[],"tags_count":7,"template":null,"template_full_name":null,"purl":"pkg:github/edgardomortiz/vcf2phylip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgardomortiz%2Fvcf2phylip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgardomortiz%2Fvcf2phylip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgardomortiz%2Fvcf2phylip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgardomortiz%2Fvcf2phylip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edgardomortiz","download_url":"https://codeload.github.com/edgardomortiz/vcf2phylip/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgardomortiz%2Fvcf2phylip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29929025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"online","status_checked_at":"2026-02-28T02:00:07.010Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alignment","binary","convert-snps","diploid","fasta","haploid","nexus","outgroup","phylip","phylip-matrix","phylogenetic-analysis","phylogenetics","polyploid","snapp","snps","vcf","vcf-files","vcf-format"],"created_at":"2026-02-28T08:36:49.279Z","updated_at":"2026-02-28T08:36:49.357Z","avatar_url":"https://github.com/edgardomortiz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vcf2phylip\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2540861.svg)](https://doi.org/10.5281/zenodo.2540861)  \nConvert SNPs in VCF format to PHYLIP, NEXUS, binary NEXUS, or FASTA alignments for phylogenetic analysis\n\n## _Brief description_\nThis script works with Python 3, it takes as input a VCF file and will use the SNP genotypes to create a matrix for phylogenetic analysis in the PHYLIP (relaxed version), FASTA, NEXUS, or binary NEXUS formats. For heterozygous SNPs the consensus is made and the IUPAC nucleotide ambiguity codes are written to the final matrix(ces), any ploidy level is allowed and automatically detected. The code is optimized for large VCF matrices (hundreds of samples and millions of genotypes), for example, in our tests it processed a 20GB VCF (~3 million SNPs x 650 individuals) in ~27 minutes. The initial version of the script just produced a PHYLIP matrix but now we have added other popular formats, including the binary NEXUS file to run SNPs analysis with the SNAPP plugin in BEAST (only for diploid genotypes).\n\nAdditionally, you can choose a minimum number of samples per SNP to control the final amount of missing data. Since phylogenetic software usually root the trees at the first sequence in the alignment (e.g. RAxML, IQTREE, and MrBayes), the script also allows you to specify an OUTGROUP sequence that will be written in the first place in the alignment.\n\nCompressed VCF files can be directly analyzed but the extension must be `.vcf.gz`.\n\nThe script has been tested with VCF files produced by [*pyrad v.3.0.66*](https://github.com/dereneaton/pyrad), [*ipyrad v.0.7.x*](http://ipyrad.readthedocs.io/), [*Stacks v.1.47*](http://catchenlab.life.illinois.edu/stacks/), [*dDocent*](http://ddocent.com/), [*GATK*](https://software.broadinstitute.org/gatk/), [*freebayes*](https://github.com/ekg/freebayes), and [*graphtyper*](https://github.com/edgardomortiz/vcf2phylip/issues/38)\n\nPlease don't hesitate to open an [`Issue`](https://github.com/edgardomortiz/vcf2phylip/issues) if you find any problem or suggestions for a new feature.\n\n## _Usage_\nJust type `python vcf2phylip.py -h` to show the help of the program:\n\n```\nusage: vcf2phylip.py [-h] -i FILENAME [--output-folder FOLDER]\n                     [--output-prefix PREFIX] [-m MIN_SAMPLES_LOCUS]\n                     [-o OUTGROUP] [-p] [-f] [-n] [-b] [-r] [-w] [-v]\n\nThe script converts a collection of SNPs in VCF format into a PHYLIP, FASTA,\nNEXUS, or binary NEXUS file for phylogenetic analysis. The code is optimized\nto process VCF files with sizes \u003e1GB. For small VCF files the algorithm slows\ndown as the number of taxa increases (but is still fast).\n\nAny ploidy is allowed, but binary NEXUS is produced only for diploid VCFs.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -i FILENAME, --input FILENAME\n                        Name of the input VCF file, can be gzipped\n  --output-folder FOLDER\n                        Output folder name, it will be created if it does not\n                        exist (same folder as input by default)\n  --output-prefix PREFIX\n                        Prefix for output filenames (same as the input VCF\n                        filename without the extension by default)\n  -m MIN_SAMPLES_LOCUS, --min-samples-locus MIN_SAMPLES_LOCUS\n                        Minimum of samples required to be present at a locus\n                        (default=4)\n  -o OUTGROUP, --outgroup OUTGROUP\n                        Name of the outgroup in the matrix. Sequence will be\n                        written as first taxon in the alignment.\n  -p, --phylip-disable  A PHYLIP matrix is written by default unless you\n                        enable this flag\n  -f, --fasta           Write a FASTA matrix (disabled by default)\n  -n, --nexus           Write a NEXUS matrix (disabled by default)\n  -b, --nexus-binary    Write a binary NEXUS matrix for analysis of biallelic\n                        SNPs in SNAPP, only diploid genotypes will be\n                        processed (disabled by default)\n  -r, --resolve-IUPAC   Randomly resolve heterozygous genotypes to avoid IUPAC\n                        ambiguities in the matrices (disabled by default)\n  -w, --write-used-sites\n                        Save the list of coordinates that passed the filters\n                        and were used in the alignments (disabled by default)\n  -v, --version         show program's version number and exit\n```\n\n## _Examples_\nIn the following examples you can omit `python` if you change the permissions of `vcf2phylip.py` to executable.\n\n_Example 1:_ Use default parameters to create a PHYLIP matrix with a minimum of 4 samples per  SNP:\n```bash\npython vcf2phylip.py --input myfile.vcf\n# Which i equivalent to:\npython vcf2phylip.py -i myfile.vcf\n# This command will create a PHYLIP called myfile_min4.phy\n```\n\n_Example 2:_ Create a PHYLIP and a FASTA matrix using a minimum of 60 samples per SNP:\n```bash\npython vcf2phylip.py --input myfile.vcf --fasta --min-samples-locus 60\n# Which is equivalent to:\npython vcf2phylip.py -i myfile.vcf -f -m 60\n# This command will create a PHYLIP called myfile_min60.phy and a FASTA called myfile_min60.fasta\n```\n\n_Example 3:_ Create all output formats, and select \"sample1\" as outgroup:\n```bash\npython vcf2phylip.py --input myfile.vcf --outgroup sample1 --fasta --nexus --nexus-binary\n# Which is equivalent to:\npython vcf2phylip.py -i myfile.vcf -o sample1 -f -n -b\n# This command will create a PHYLIP called myfile_min4.phy, a FASTA called myfile_min4.fasta, a NEXUS called myfile_min4.nexus, and a binary NEXUS called myfile_min4.bin.nexus\n```\n\n_Example 4:_ If, for example, you wish to disable the creation of the PHYLIP matrix and only create a NEXUS matrix:\n```bash\npython vcf2phylip.py --input myfile.vcf --phylip-disable --nexus\n# Which is equivalent to:\npython vcf2phylip.py -i myfile.vcf -p -n\n# This command will create only a NEXUS matrix called myfile_min4.nexus\n```\n\n_Example 5:_ If for some reason you don't want to have IUPAC ambiguities representing heterozygous genotypes:\n```bash\npython vcf2phylip.py --input myfile.vcf --resolve-IUPAC\n# Which is equivalent to:\npython vcf2phylip.py -i myfile.vcf -r\n# This command will create only a PHYLIP matrix called myfile_min4.phy where IUPAC ambiguites have been randomly resolved\n```\n\n_Example 6:_ Specify output folder and output prefix:\n```bash\npython vcf2phylip.py -i myfile.vcf.gz --output-folder /data/results --output-prefix mymatrix\n# This command will create the file `myfile.min4.phy` in the folder `/data/results`\n```\n\n_Example 7:_ Write a list of the sites that were used in the alignments:\n```bash\npython vcf2phylip.py -i myfile.vcf.gz -w\n# This command will create the file `myfile.min4.phy` and the list `myfile.min4.used_sites.tsv`\n```\n\n## _Credits_\n- Code: [Edgardo M. Ortiz](mailto:e.ortiz.v@gmail.com)\n- Data and testing: [Juan D. Palacio-Mejía](mailto:jdpalacio@gmail.com)\n\n## _Citation_\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2540861.svg)](https://doi.org/10.5281/zenodo.2540861)  \n**Ortiz, E.M. 2019.** vcf2phylip v2.0: convert a VCF matrix into several matrix formats for phylogenetic analysis. DOI:10.5281/zenodo.2540861\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgardomortiz%2Fvcf2phylip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedgardomortiz%2Fvcf2phylip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgardomortiz%2Fvcf2phylip/lists"}