Skip to main content

Fixed a syntax error in matrix_generator.py imports which made it crash. Also added a functionin helper_funcs.py to calculate the average distance between two Fst matrices, and changedthe name of the function matrix_distance to migration_matrix_distance (as it actuallycalculated distance between migration two matrices).

Project description

Population Structure Package

A package for performing transformation between fst, coalescence, and migration matrices. The transformation between coalescence and migration is based on Wilkinson-Herbot's equations (2003). The transformation between fst and coalescence is based on the Slatkin's equations (1991).

Install package using pip

pip install population-structure

Example usuage

import population_structure.utils as psu
import numpy as np
m = np.array([[0, 1, 1], 
              [1, 0, 1], 
              [1, 1, 0]]) # A conservative migration matrix
t = psu.m_to_t(m) # The corresponding coalescence matrix according to W.H. (2003)
f = psu.m_to_f(m) # The corresponding fst matrix according to Slatkin (1991)
print(f"{t}\n{f}")
"""
prints:
[[3. 4. 4.]
 [4. 3. 4.]
 [4. 4. 3.]]
[[0.         0.14285714 0.14285714]
 [0.14285714 0.         0.14285714]
 [0.14285714 0.14285714 0.        ]]
"""
f = np.array([[0,0.1,0.2],
              [0.1,0,0.3],
              [0.2,0.3,0]]) # An fst matrix
psu.f_to_t(f) # Generates a possilbe corresponding coalescence matrix
psu.f_to_m(f) # Generate a possible corresponding migration matrix

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

population_structure-0.0.9.tar.gz (33.8 kB view details)

Uploaded Source

Built Distribution

population_structure-0.0.9-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file population_structure-0.0.9.tar.gz.

File metadata

  • Download URL: population_structure-0.0.9.tar.gz
  • Upload date:
  • Size: 33.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for population_structure-0.0.9.tar.gz
Algorithm Hash digest
SHA256 b08df6571a0e29a3c7517bb64f00f597eb1417fbabd39f1ad226dce5ca8ea34b
MD5 dfdb88682b1c3cc0145fc43132accf36
BLAKE2b-256 b3bcffde3cd643f05ff554423a4185768995fd0eb4c2d2543b370ac360359ac5

See more details on using hashes here.

File details

Details for the file population_structure-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for population_structure-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 656643f84a0b327bd4ae6da82a246a69c6bf4ba7b85cf492e7537659d957d725
MD5 837b718598177a6a7e09d421b3830782
BLAKE2b-256 e7021c849d2afd1571d5383b5632a90d7fdbec04fbfaa1a44f483a134fd05150

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page