Major changes in the the utils module. The f_to_m function previously used a numeric solver which oftenfailed due to constraining the solution with conservative migration constraints. Now, using the constraintsthe numerical solver adds the constraints as part of the equations to minimize, and it possible to runthe function without the conservative migration constraints.
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
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 population_structure-1.0.1.tar.gz.
File metadata
- Download URL: population_structure-1.0.1.tar.gz
- Upload date:
- Size: 34.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b91a42ff95bd07cf811a21948d0603735c781263ffa7ded3c06369d2c154667
|
|
| MD5 |
3e3219c15c0609e3b65344d8da162c23
|
|
| BLAKE2b-256 |
2cde37b8b14a8adda61f832a22a9b21af6a5d6d5a317f3adb8a453147b19c006
|
File details
Details for the file population_structure-1.0.1-py3-none-any.whl.
File metadata
- Download URL: population_structure-1.0.1-py3-none-any.whl
- Upload date:
- Size: 37.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ad68c1b2dc90a50c54d9db64e375d3e119e12079d3fc0e74c38fd20ff41b0b8
|
|
| MD5 |
e0716d5f9855b16d0dd4dd9a51bfde6c
|
|
| BLAKE2b-256 |
4003c8744cb586d6de20d82406cfac18b20bf57defdefab2e510fb0a1d538735
|