Skip to main content

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


Download files

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

Source Distribution

hapnet-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

hapnet-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

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

Hashes for hapnet-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1c1d2738bef939a57f41e7b9b18dc089cb0a204a7c7ffd645a5c9ff2f333016c
MD5 ec35bb982fd6f8c29529d6584e3eacab
BLAKE2b-256 fd2baba5c98856570ccf8d3fdc5616c92a1fe00120ca0c05a1df0b2a51e400b9

See more details on using hashes here.

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

Hashes for hapnet-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e2c7cbc792d1ed35abb489cf0b8d347fff8fe3bb6a20745477c6974b9a86b37
MD5 8e1c0d374f2f7dcb64ded952155991a8
BLAKE2b-256 33f6dcc3a8a1f66b6ba3307b82bf41db34fb7d153c7da82db1174534b323c4f7

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