Skip to main content

SNPio is a Python API for population genetic file processing, filtering, and analysis. It is designed to be a user-friendly tool for the manipulation of population genetic data in a variety of formats. SNPio can be used to filter data based on missingness, MAF and MAC, singletons, biallelic, and monomorphic sites. It can also generate summary statistics for population genetic analyses.

Project description

SNPio: A Python API for Population Genomic Data I/O, Filtering, Analysis, and Encoding

SNPio Logo

SNPio is a Python package designed to streamline the process of reading, filtering, encoding, and analyzing genotype alignments. It supports VCF, PHYLIP, STRUCTURE, and GENEPOP file formats, and provides high-level tools for visualization, downstream machine learning analysis, and population genetic inference.

SNPio Includes:

  • File I/O (VCFReader, PhylipReader, StructureReader, GenePopReader)
  • Genotype filtering (NRemover2)
  • Genotype encoding for AI & machine learning applications (GenotypeEncoder)
  • Population genetic statistics & Principal Component Analysis (PopGenStatistics)
  • Experimental: Phylogenetic tree parsing (TreeParser)

📖 Full Documentation

Detailed API usage, tutorials, and examples are available in the Documentation


🔧 Installation

You can install SNPio using one of the following methods:

✅ Pip Installation

python3 -m venv snpio-env
source snpio-env/bin/activate
pip install snpio

✅ Conda Installation

conda create -n snpio-env python=3.12
conda activate snpio-env
conda install -c btmartin721 snpio

🐳 Docker

To run the Docker image interactively in a terminal, run the following commands:

docker pull btmartin721/snpio:latest
docker run -it btmartin721/snpio:latest

If you'd like to run SNPio in a jupyter notebook, instructions to do so in the docker container will be printed to the terminal.

Note: All three installation versions (pip, conda, docker) are actively maintained and kept up-to-date with CI/CD routines.

Note: SNPio supports Unix-based systems. Windows users should install via WSL.


🚀 Getting Started

Import Modules

from snpio import (
    NRemover2, VCFReader, PhylipReader, StructureReader,
    GenePopReader, GenotypeEncoder, PopGenStatistics
)

Load Genotype Data (VCF Example)

vcf = "snpio/example_data/vcf_files/phylogen_subset14K_sorted.vcf.gz"
popmap = "snpio/example_data/popmaps/phylogen_nomx.popmap"

gd = VCFReader(
    filename=vcf,
    popmapfile=popmap,
    force_popmap=True,
    verbose=True,
    plot_format="png",
    prefix="snpio_example"
)

You can also specify include_pops and exclude_pops to control population-level filtering.


🧪 Development Notes

To run unit all tests:

pip install snpio[dev]
pytest tests/

🧾 License and Citation

SNPio is licensed under the GPL-3.0 License.

Please cite any publication(s) when using SNPio in your research. A manuscript is currently in development, and this section will be updated upon acceptance.


🤝 Contributing

We welcome community contributions!


🙏 Acknowledgments

Thanks for using SNPio. We hope it facilitates your population genomic research. Feel free to reach out with questions or feedback!

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

snpio-1.6.16.tar.gz (254.7 kB view details)

Uploaded Source

Built Distribution

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

snpio-1.6.16-py3-none-any.whl (263.3 kB view details)

Uploaded Python 3

File details

Details for the file snpio-1.6.16.tar.gz.

File metadata

  • Download URL: snpio-1.6.16.tar.gz
  • Upload date:
  • Size: 254.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for snpio-1.6.16.tar.gz
Algorithm Hash digest
SHA256 9d3903a3b5aa4aa85385ff44cc463b3001a0beb75d0d9de3f178a7b2e0b8a55a
MD5 dfc93073405da81f77de416e8298c281
BLAKE2b-256 7e116ffd70e0c526c62ae8e82b0b01186153b45fcfc165a811c856cb5cce27c4

See more details on using hashes here.

File details

Details for the file snpio-1.6.16-py3-none-any.whl.

File metadata

  • Download URL: snpio-1.6.16-py3-none-any.whl
  • Upload date:
  • Size: 263.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for snpio-1.6.16-py3-none-any.whl
Algorithm Hash digest
SHA256 bffe5e989fbc8680fd7886510bafca48ad7bcf10825f3238f69c1bdffcd90fa8
MD5 4485fe940e46da403a44f952d54b31ce
BLAKE2b-256 8021ef56bbeebe2f3afa3ee3168d105b9bcb70a041cb6fe67bbad13a9237f5dd

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