This version has a fix for f_to_m, so now the produced matrices should be more accurate. Previous versions had a problem with the constraint functions sent to minimize. This caused the minimize function to fail and as a result the produced matrices were not accurate. This version has a fix for f_to_m, so now the produces matrices should be more accurate.
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 (2001).
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 (2001)
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
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
File details
Details for the file population_structure-0.0.6.tar.gz
.
File metadata
- Download URL: population_structure-0.0.6.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e328f3836efbad3e7d67b1d359c3b189411df81fe5db0272daddf21bd07d47f0 |
|
MD5 | e40ae9c43f9c0f50970d55f773edf32d |
|
BLAKE2b-256 | 79a169750e225df77f6f289800691684e2d2cc2b195b7ac7a2c7549b240aa0e7 |
File details
Details for the file population_structure-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: population_structure-0.0.6-py3-none-any.whl
- Upload date:
- Size: 36.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8428fccf9364116211fc42f5be863d2f802e83a887e17eb3569e5af39f172b1 |
|
MD5 | 6b8995fb921f1d448ea0b8fdf0418e1d |
|
BLAKE2b-256 | b33a4de62c42f64988696b68282d8f7680786c2190d99464cf8b5b03b1eddd65 |