Population-aware haplotype network analysis and visualization in Python.
Project description
hapnet
hapnet is a Python package for building population-aware haplotype networks from aligned FASTA files.
It integrates haplotype inference, population membership, and visualization into a reproducible, command-line workflow.
hapnet constructs minimum spanning tree (MST) haplotype networks in which node size reflects haplotype frequency and shared haplotypes are represented as population-colored pie charts.
Features
- Aligned FASTA input
- Population parsed directly from FASTA headers
- Minimum spanning tree (MST) haplotype networks
- Haplotype nodes sized by frequency
- Population-aware pie charts for shared haplotypes
- Mutation tick marks on network edges
- Reproducible TSV logs and summary statistics
Installation
pip install hapnet
Python 3.9 or newer is required
---
USAGE
hapnet input.fasta --out network.png --log-prefix run1
This command produces:
network.png - haplotype network visualization
run1_haplotypes.tsv - haplotype definitions and frequencies
run1_membership.tsv - sequence-to-haplotype membership
run1_shared_haplotypes.tsv - haplotypes shared among populations
run1_summary.tsv - summary statistics (total haplotypes, shared vs private, etc.)
FASTA HEADER FORMAT
Population identity must be encoded as the final underscore-delimited token in each FASTA header.
Examples:
Ind1_Pop1
Ind7_SiteA_2019_Pop3
MN605578_Pneocaeca_RI
In all cases, the population is interpreted as the final token (Pop1, Pop3, RI).
Sequences must be aligned and of equal length.
SCALABILITY and VISUALIZATION NOTES
Hapnet scales computationally with the number of distinct haplotypes, not the number of input sequences. Static network visualizations are typically most interpretable for datasets containing tens to low hundreds of haplotypes, depending on network structure and frequency distribution. All haplotypes and population memberships are retained in the output logs regardless of visualization complexity.
LICENSE
Hapnet is released under the MIT License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hapnet-0.1.0.tar.gz.
File metadata
- Download URL: hapnet-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c1d2738bef939a57f41e7b9b18dc089cb0a204a7c7ffd645a5c9ff2f333016c
|
|
| MD5 |
ec35bb982fd6f8c29529d6584e3eacab
|
|
| BLAKE2b-256 |
fd2baba5c98856570ccf8d3fdc5616c92a1fe00120ca0c05a1df0b2a51e400b9
|
File details
Details for the file hapnet-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hapnet-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e2c7cbc792d1ed35abb489cf0b8d347fff8fe3bb6a20745477c6974b9a86b37
|
|
| MD5 |
8e1c0d374f2f7dcb64ded952155991a8
|
|
| BLAKE2b-256 |
33f6dcc3a8a1f66b6ba3307b82bf41db34fb7d153c7da82db1174534b323c4f7
|