Library for the Development and Use of Phylogenetic Network Methods
Validated population allele-count data and pulse-admixture graph semantics.
Raised when population-genetic data or graph semantics are invalid.
Biallelic allele counts arranged as populations by sites. The numerator and denominator are stored separately. This avoids treating missing genotypes as reference alleles and supports different sample sizes among populations and sites. A callable count of zero denotes a missing population/site observation. This is an analysis container, not a ``phynetpy.data.Data`` inference-axis type; :func:`phynetpy.infer.infer` and :func:`phynetpy.infer.score` do not consume it.
Population labels in matrix-row order.
Site labels in matrix-column order, if supplied.
Number of populations.
Number of sites.
Read-only population-by-site alternate-allele counts.
Read-only population-by-site callable-allele counts.
Create a population-by-site allele-count table.
| Parameter | Type | Description |
|---|---|---|
| alternate_allele_counts | Two-dimensional nonnegative integer counts. | |
| called_allele_counts | Matching counts of callable gene copies. | |
| populations | Unique population labels, one per matrix row. | |
| sites | Optional unique site labels, one per matrix column. |
PopulationGeneticsError: If dimensions, labels, or counts are inconsistent.Calculate alternate-allele frequencies without imputing missing data.
| Parameter | Type | Description |
|---|---|---|
| population | Optional population label. If omitted, return the full population-by-site matrix. |
PopulationGeneticsError: If *population* is unknown.Aggregate a sample-by-site matrix into population allele counts. Genotypes are alternate-allele copy counts. ``None``, ``NaN``, ``"."``, ``"?"``, ``"-"``, ``"./."``, and ``".|."`` are treated as missing. Every sample must belong to exactly one population.
| Parameter | Type | Description |
|---|---|---|
| genotypes | Two-dimensional sample-by-site genotype-count matrix. | |
| samples | Unique sample labels in matrix-row order. | |
| population_members | Population label -> member sample labels. | |
| ploidy | Positive ploidy shared by all samples, or one value per sample. | |
| sites | Optional site labels. |
PopulationGeneticsError: If genotypes, ploidy, or membership are malformed.Aggregate PhyNetPy biallelic-marker rows by their population mapping. The marker object's species-to-allele mapping supplies population membership. Callable gene-copy counts must be supplied explicitly: ``BiallelicMarkers`` defaults its ``samples`` values to one even when a VCF row contains diploid genotype dosages, so that default is not a reliable denominator.
| Parameter | Type | Description |
|---|---|---|
| markers | A :class:`phynetpy.data.BiallelicMarkers` object. | |
| called_alleles | A positive count shared by all marker rows, or a row-label -> count mapping. Pass ``markers.samples`` explicitly when those values are known to have been supplied correctly. |
PopulationGeneticsError: If *markers* is the wrong type or callable-copy counts are absent or incomplete.Validated pulse-admixture topology and proportions over a ``Network``. ``Network``, ``Node``, and ``Edge`` remain the graph implementation. This wrapper adds only population-genetic invariants: * one rooted directed acyclic component; * nodes with multiple parents are explicitly marked as reticulations; * their incoming inheritance proportions are strictly between zero and one and sum to one. The wrapper intentionally does not interpret ``Edge.length``. PhyNetPy networks currently carry sequence or coalescent units, while classical allele-frequency admixture graphs use genetic-drift lengths. Conflating those quantities would be scientifically incorrect. Divergence nodes may be unary or multifurcating, and admixture may involve more than two sources. Thus the wrapper does not impose the bin...
The wrapped graph. Call :meth:`validate` after mutating it.
The unique ancestral root.
Terminal population nodes in deterministic label order.
Nodes with ancestry from two or more parent populations.
Attach admixture-graph semantics to an existing network.
| Parameter | Type | Description |
|---|---|---|
| network | The directed graph to validate and wrap. | |
| tolerance | Absolute tolerance for inheritance proportions summing to one and for recognizing an unused zero gamma. |
PopulationGeneticsError: If the graph is not a valid admixture history.Map each parent population to its contribution at an admixture node.
| Parameter | Type | Description |
|---|---|---|
| node | An admixture node or its label. |
PopulationGeneticsError: If the node is absent or is not an admixture node.Validate topology, reticulation flags, and inheritance proportions.
PopulationGeneticsError: At the first violated invariant.