itrails 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- itrails-0.1.0/.github/workflows/pypi-release.yml +32 -0
- itrails-0.1.0/.github/workflows/testpypi-release.yml +32 -0
- itrails-0.1.0/.gitignore +177 -0
- itrails-0.1.0/.readthedocs.yaml +17 -0
- itrails-0.1.0/LICENSE +21 -0
- itrails-0.1.0/PKG-INFO +116 -0
- itrails-0.1.0/README.md +69 -0
- itrails-0.1.0/docs/Makefile +20 -0
- itrails-0.1.0/docs/_static/custom.css +7 -0
- itrails-0.1.0/docs/_static/rtd_version.js +14 -0
- itrails-0.1.0/docs/api.rst +26 -0
- itrails-0.1.0/docs/cli.rst +28 -0
- itrails-0.1.0/docs/conf.py +71 -0
- itrails-0.1.0/docs/index.rst +33 -0
- itrails-0.1.0/docs/make.bat +35 -0
- itrails-0.1.0/docs/modules/combine_states.rst +7 -0
- itrails-0.1.0/docs/modules/cutpoints.rst +7 -0
- itrails-0.1.0/docs/modules/deepest_ti.rst +7 -0
- itrails-0.1.0/docs/modules/expm.rst +7 -0
- itrails-0.1.0/docs/modules/get_emission_prob_mat.rst +7 -0
- itrails-0.1.0/docs/modules/get_joint_prob_mat.rst +7 -0
- itrails-0.1.0/docs/modules/get_trans_emiss.rst +7 -0
- itrails-0.1.0/docs/modules/helper_omegas.rst +7 -0
- itrails-0.1.0/docs/modules/ncpu.rst +7 -0
- itrails-0.1.0/docs/modules/optimizer.rst +7 -0
- itrails-0.1.0/docs/modules/read_data.rst +7 -0
- itrails-0.1.0/docs/modules/run_markov_chain_AB.rst +7 -0
- itrails-0.1.0/docs/modules/run_markov_chain_ABC.rst +7 -0
- itrails-0.1.0/docs/modules/trans_mat.rst +7 -0
- itrails-0.1.0/docs/modules/vanloan.rst +7 -0
- itrails-0.1.0/docs/modules/workflow_optimize.rst +7 -0
- itrails-0.1.0/docs/modules/workflow_posterior.rst +7 -0
- itrails-0.1.0/docs/modules/workflow_print_example.rst +7 -0
- itrails-0.1.0/docs/modules/workflow_viterbi.rst +7 -0
- itrails-0.1.0/docs/modules/yaml_helpers.rst +7 -0
- itrails-0.1.0/pyproject.toml +56 -0
- itrails-0.1.0/setup.cfg +4 -0
- itrails-0.1.0/src/itrails/__init__.py +4 -0
- itrails-0.1.0/src/itrails/_version.py +21 -0
- itrails-0.1.0/src/itrails/combine_states.py +140 -0
- itrails-0.1.0/src/itrails/cutpoints.py +65 -0
- itrails-0.1.0/src/itrails/deepest_ti.py +256 -0
- itrails-0.1.0/src/itrails/examples/example_config.yaml +21 -0
- itrails-0.1.0/src/itrails/expm.py +166 -0
- itrails-0.1.0/src/itrails/get_emission_prob_mat.py +1435 -0
- itrails-0.1.0/src/itrails/get_joint_prob_mat.py +187 -0
- itrails-0.1.0/src/itrails/get_trans_emiss.py +175 -0
- itrails-0.1.0/src/itrails/helper_omegas.py +123 -0
- itrails-0.1.0/src/itrails/ncpu.py +33 -0
- itrails-0.1.0/src/itrails/optimizer.py +633 -0
- itrails-0.1.0/src/itrails/read_data.py +137 -0
- itrails-0.1.0/src/itrails/run_markov_chain_AB.py +269 -0
- itrails-0.1.0/src/itrails/run_markov_chain_ABC.py +796 -0
- itrails-0.1.0/src/itrails/trans_mat.py +598 -0
- itrails-0.1.0/src/itrails/vanloan.py +425 -0
- itrails-0.1.0/src/itrails/workflow_optimize.py +467 -0
- itrails-0.1.0/src/itrails/workflow_posterior.py +490 -0
- itrails-0.1.0/src/itrails/workflow_print_example.py +29 -0
- itrails-0.1.0/src/itrails/workflow_viterbi.py +497 -0
- itrails-0.1.0/src/itrails/yaml_helpers.py +118 -0
- itrails-0.1.0/src/itrails.egg-info/PKG-INFO +116 -0
- itrails-0.1.0/src/itrails.egg-info/SOURCES.txt +64 -0
- itrails-0.1.0/src/itrails.egg-info/dependency_links.txt +1 -0
- itrails-0.1.0/src/itrails.egg-info/entry_points.txt +5 -0
- itrails-0.1.0/src/itrails.egg-info/requires.txt +13 -0
- itrails-0.1.0/src/itrails.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*' # Runs only when a version tag is pushed
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Check out repository
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: actions/setup-python@v4
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.11"
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: pip install build twine setuptools setuptools-scm
|
|
23
|
+
|
|
24
|
+
- name: Build package
|
|
25
|
+
run: python -m build
|
|
26
|
+
|
|
27
|
+
- name: Publish to PyPI
|
|
28
|
+
if: github.ref == 'refs/tags/v0.1.0'
|
|
29
|
+
env:
|
|
30
|
+
TWINE_USERNAME: __token__
|
|
31
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
32
|
+
run: twine upload --non-interactive --repository pypi dist/*
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish to TestPyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*' # Runs only when a version tag is pushed
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Check out repository
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: actions/setup-python@v4
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.9"
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: pip install build twine setuptools setuptools-scm
|
|
23
|
+
|
|
24
|
+
- name: Build package
|
|
25
|
+
run: python -m build
|
|
26
|
+
|
|
27
|
+
- name: Publish to TestPyPI
|
|
28
|
+
if: contains(github.ref, 'a') || contains(github.ref, 'b') || contains(github.ref, 'rc')
|
|
29
|
+
env:
|
|
30
|
+
TWINE_USERNAME: __token__
|
|
31
|
+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
32
|
+
run: twine upload --repository testpypi dist/*
|
itrails-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# Ruff stuff:
|
|
171
|
+
.ruff_cache/
|
|
172
|
+
|
|
173
|
+
# PyPI configuration file
|
|
174
|
+
.pypirc
|
|
175
|
+
|
|
176
|
+
# Alignment files
|
|
177
|
+
*.maf
|
itrails-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Iker Rivas-González & David Martin-Pestana
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
itrails-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: itrails
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tree reconstruction of ancestry using incomplete lineage sorting
|
|
5
|
+
Author-email: David Martin-Pestana <dmape@birc.au.dk>
|
|
6
|
+
Maintainer-email: Iker Rivas-González <iker_rivas_gonzalez@eva.mpg.de>, David Martin-Pestana <dmape@birc.au.dk>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2025 Iker Rivas-González & David Martin-Pestana
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/trails-phylogeny/itrails
|
|
30
|
+
Project-URL: BugTracker, https://github.com/trails-phylogeny/itrails/issues
|
|
31
|
+
Requires-Python: >=3.6
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
Requires-Dist: numpy==1.26.4
|
|
35
|
+
Requires-Dist: scipy==1.13.0
|
|
36
|
+
Requires-Dist: joblib==1.4.2
|
|
37
|
+
Requires-Dist: numba==0.59.1
|
|
38
|
+
Requires-Dist: biopython==1.84
|
|
39
|
+
Requires-Dist: pyyaml==6.0.2
|
|
40
|
+
Requires-Dist: h5py
|
|
41
|
+
Provides-Extra: docs
|
|
42
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
43
|
+
Requires-Dist: furo; extra == "docs"
|
|
44
|
+
Requires-Dist: myst-parser; extra == "docs"
|
|
45
|
+
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
# iTRAILS
|
|
49
|
+
|
|
50
|
+
## Software
|
|
51
|
+
|
|
52
|
+
iTRAILS is a framework to jointly model incomplete lineage sorting (ILS) and gene flow (GF). iTRAILS uses the multispecies coalescent to approximate the ancestral recombination history of three populations and an outgroup. In brief, iTRAILS infers the ancestral tree from a multiple genome alignment, unbiasedly estimating ancestral effective population sizes, speciation times, and introgression time and proportions. iTRAILS also performs posterior decoding.
|
|
53
|
+
|
|
54
|
+
iTRAILS can be installed as both a PyPi and a conda package, and it's codebase is available at:
|
|
55
|
+
|
|
56
|
+
[https://github.com/trails-phylogeny/itrails](https://github.com/trails-phylogeny/itrails)
|
|
57
|
+
|
|
58
|
+
Once the package is installed, iTRAILS is initiaited and controlled through 2 main console commands.
|
|
59
|
+
|
|
60
|
+
### Optimization of Parameters
|
|
61
|
+
|
|
62
|
+
iTRAILS estimates key demographic parameters—such as speciation times, ancestral effective population sizes (Ne), and recombination rate (ρ)—by maximizing the log-likelihood computed from the coalescent HMM. iTRAILS takes into account the following parameters:
|
|
63
|
+
- Population size parameters:
|
|
64
|
+
- N_AB: Effective size of the ancestral population between the two most closely related species.
|
|
65
|
+
- N_ABC: Effective size of the ancestral population between the three species.
|
|
66
|
+
- Time parameters (generations):
|
|
67
|
+
- T_1: Assuming ultrametric model, time from sample to coalescence of species A and B.
|
|
68
|
+
- T_2: Time between coalescence of species A and B and coalescence of AB ancestral with species C.
|
|
69
|
+
- T_3: Time between coalescence of species ABC and coalescence of ABC ancestral with outgroup species.
|
|
70
|
+
- T_A: Time from sample of species A until coalescence with species B.
|
|
71
|
+
- T_B: Time from sample of species B until coalescence with species A.
|
|
72
|
+
- T_C: Time from sample of species C until coalescence with AB ancestral.
|
|
73
|
+
- T_Upper: Time from start of last discretized time interval in ABC ancestral until coalescence with outgroup.
|
|
74
|
+
- T_Out: Time from sample of outgorup until coalescence with ABC ancestral.
|
|
75
|
+
- Other parameters:
|
|
76
|
+
- Recombination rate (ρ): NUmber of recombinations per site per generation.
|
|
77
|
+
- Mutation rate (μ): Number of mutations per site per generation.
|
|
78
|
+
|
|
79
|
+
Not all of the previously described parameters are independent from each other. Therefore, definition of parameters should comply with the following restrictions:
|
|
80
|
+
- T_2, N_AB, N_ABC, ρ must always be defined as a fixed parameter os as a parameter to optimize.
|
|
81
|
+
- μ must always be defined as a fixed parameter.
|
|
82
|
+
- T_Upper and T_3: At least one of them should be defined (fixed or optimized). If only one of them is defined, the other one will be automatically calculated.
|
|
83
|
+
- T_out: Can be defined or omitted, if defined it must be fixed, if omitted it will be automatically calculated.
|
|
84
|
+
- T_A, T_B, T_C and T_1 should be defined (fixed or optimized) in the following combinations, the non defined parameters will take values as defined in the following table:
|
|
85
|
+
|
|
86
|
+
| Specified parameters | Used T_A | Used T_B | Used T_C |
|
|
87
|
+
|:---------------------|:---------------------------:|:---------------------------:|:---------------------------:|
|
|
88
|
+
| T_A / T_B / T_C | T_A | T_B | T_C |
|
|
89
|
+
| T_1 / T_A | T_A | T_1 | T_1 + T_2 |
|
|
90
|
+
| T_1 / T_B | T_1 | T_B | T_1 + T_2 |
|
|
91
|
+
| T_1 / T_C | T_1 | T_1 | T_C |
|
|
92
|
+
| T_A / T_B | T_A | T_B | $\frac{T_A + T_B}{2} + T_2$ |
|
|
93
|
+
| T_A / T_C | T_A | $\frac{T_A + T_C - T_2}{2}$ | T_C |
|
|
94
|
+
| T_B / T_C | $\frac{T_B + T_C - T_2}{2}$ | T_B | T_C |
|
|
95
|
+
| T_1 | T_1 | T_1 | T_1 + T_2 |
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
In order to run an optimization, iTRAILS needs two input files.
|
|
99
|
+
- A four-way genome alignment (MAF file) between three species and an outgroup.
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
$ cat alignment.maf
|
|
103
|
+
|
|
104
|
+
##maf version=1 scoring=none
|
|
105
|
+
# generated by Biopython
|
|
106
|
+
|
|
107
|
+
a score=3.25073e+06
|
|
108
|
+
s gorGor5.CYUI01015145v1 8162515 3382 + 8455952 tcaaaaaactatttcttgagcattcattaagtgcaaa
|
|
109
|
+
s hg38.chr1 24998515 3414 + 248956422 TCAAAAAACTATTTCTTGAGCATTCATTAAGTGCAAA
|
|
110
|
+
s panTro5.chr1 24190887 3415 + 228573443 tcaaaaaactatctcttgagcattcattaagtgcaaa
|
|
111
|
+
s ponAbe2.chr1 24531025 3415 - 229942017 tcaaaaaactctttcttgagcattcattaagtgcaaa
|
|
112
|
+
|
|
113
|
+
a score=4.56614e+06
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- A configuration file (.yaml) that specifies fixed parameters, parameters to optimize, as well as the alignment file path (optional) and output path (optional). An example configuration file is found in the package and can be seen in console with the following function:
|
itrails-0.1.0/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# iTRAILS
|
|
2
|
+
|
|
3
|
+
## Software
|
|
4
|
+
|
|
5
|
+
iTRAILS is a framework to jointly model incomplete lineage sorting (ILS) and gene flow (GF). iTRAILS uses the multispecies coalescent to approximate the ancestral recombination history of three populations and an outgroup. In brief, iTRAILS infers the ancestral tree from a multiple genome alignment, unbiasedly estimating ancestral effective population sizes, speciation times, and introgression time and proportions. iTRAILS also performs posterior decoding.
|
|
6
|
+
|
|
7
|
+
iTRAILS can be installed as both a PyPi and a conda package, and it's codebase is available at:
|
|
8
|
+
|
|
9
|
+
[https://github.com/trails-phylogeny/itrails](https://github.com/trails-phylogeny/itrails)
|
|
10
|
+
|
|
11
|
+
Once the package is installed, iTRAILS is initiaited and controlled through 2 main console commands.
|
|
12
|
+
|
|
13
|
+
### Optimization of Parameters
|
|
14
|
+
|
|
15
|
+
iTRAILS estimates key demographic parameters—such as speciation times, ancestral effective population sizes (Ne), and recombination rate (ρ)—by maximizing the log-likelihood computed from the coalescent HMM. iTRAILS takes into account the following parameters:
|
|
16
|
+
- Population size parameters:
|
|
17
|
+
- N_AB: Effective size of the ancestral population between the two most closely related species.
|
|
18
|
+
- N_ABC: Effective size of the ancestral population between the three species.
|
|
19
|
+
- Time parameters (generations):
|
|
20
|
+
- T_1: Assuming ultrametric model, time from sample to coalescence of species A and B.
|
|
21
|
+
- T_2: Time between coalescence of species A and B and coalescence of AB ancestral with species C.
|
|
22
|
+
- T_3: Time between coalescence of species ABC and coalescence of ABC ancestral with outgroup species.
|
|
23
|
+
- T_A: Time from sample of species A until coalescence with species B.
|
|
24
|
+
- T_B: Time from sample of species B until coalescence with species A.
|
|
25
|
+
- T_C: Time from sample of species C until coalescence with AB ancestral.
|
|
26
|
+
- T_Upper: Time from start of last discretized time interval in ABC ancestral until coalescence with outgroup.
|
|
27
|
+
- T_Out: Time from sample of outgorup until coalescence with ABC ancestral.
|
|
28
|
+
- Other parameters:
|
|
29
|
+
- Recombination rate (ρ): NUmber of recombinations per site per generation.
|
|
30
|
+
- Mutation rate (μ): Number of mutations per site per generation.
|
|
31
|
+
|
|
32
|
+
Not all of the previously described parameters are independent from each other. Therefore, definition of parameters should comply with the following restrictions:
|
|
33
|
+
- T_2, N_AB, N_ABC, ρ must always be defined as a fixed parameter os as a parameter to optimize.
|
|
34
|
+
- μ must always be defined as a fixed parameter.
|
|
35
|
+
- T_Upper and T_3: At least one of them should be defined (fixed or optimized). If only one of them is defined, the other one will be automatically calculated.
|
|
36
|
+
- T_out: Can be defined or omitted, if defined it must be fixed, if omitted it will be automatically calculated.
|
|
37
|
+
- T_A, T_B, T_C and T_1 should be defined (fixed or optimized) in the following combinations, the non defined parameters will take values as defined in the following table:
|
|
38
|
+
|
|
39
|
+
| Specified parameters | Used T_A | Used T_B | Used T_C |
|
|
40
|
+
|:---------------------|:---------------------------:|:---------------------------:|:---------------------------:|
|
|
41
|
+
| T_A / T_B / T_C | T_A | T_B | T_C |
|
|
42
|
+
| T_1 / T_A | T_A | T_1 | T_1 + T_2 |
|
|
43
|
+
| T_1 / T_B | T_1 | T_B | T_1 + T_2 |
|
|
44
|
+
| T_1 / T_C | T_1 | T_1 | T_C |
|
|
45
|
+
| T_A / T_B | T_A | T_B | $\frac{T_A + T_B}{2} + T_2$ |
|
|
46
|
+
| T_A / T_C | T_A | $\frac{T_A + T_C - T_2}{2}$ | T_C |
|
|
47
|
+
| T_B / T_C | $\frac{T_B + T_C - T_2}{2}$ | T_B | T_C |
|
|
48
|
+
| T_1 | T_1 | T_1 | T_1 + T_2 |
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
In order to run an optimization, iTRAILS needs two input files.
|
|
52
|
+
- A four-way genome alignment (MAF file) between three species and an outgroup.
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
$ cat alignment.maf
|
|
56
|
+
|
|
57
|
+
##maf version=1 scoring=none
|
|
58
|
+
# generated by Biopython
|
|
59
|
+
|
|
60
|
+
a score=3.25073e+06
|
|
61
|
+
s gorGor5.CYUI01015145v1 8162515 3382 + 8455952 tcaaaaaactatttcttgagcattcattaagtgcaaa
|
|
62
|
+
s hg38.chr1 24998515 3414 + 248956422 TCAAAAAACTATTTCTTGAGCATTCATTAAGTGCAAA
|
|
63
|
+
s panTro5.chr1 24190887 3415 + 228573443 tcaaaaaactatctcttgagcattcattaagtgcaaa
|
|
64
|
+
s ponAbe2.chr1 24531025 3415 - 229942017 tcaaaaaactctttcttgagcattcattaagtgcaaa
|
|
65
|
+
|
|
66
|
+
a score=4.56614e+06
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- A configuration file (.yaml) that specifies fixed parameters, parameters to optimize, as well as the alignment file path (optional) and output path (optional). An example configuration file is found in the package and can be seen in console with the following function:
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = .
|
|
9
|
+
BUILDDIR = _build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
window.onload = function () {
|
|
2
|
+
const injectVersionSelector = () => {
|
|
3
|
+
const el = document.createElement('div');
|
|
4
|
+
el.innerHTML = document.getElementById('readthedocs-version')?.innerHTML;
|
|
5
|
+
if (el.innerHTML) {
|
|
6
|
+
el.className = 'rtd-version-selector';
|
|
7
|
+
const sidebar = document.querySelector('nav[role="navigation"]');
|
|
8
|
+
if (sidebar) {
|
|
9
|
+
sidebar.appendChild(el);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
injectVersionSelector();
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
API Reference
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
.. toctree::
|
|
5
|
+
:maxdepth: 1
|
|
6
|
+
|
|
7
|
+
modules/combine_states
|
|
8
|
+
modules/cutpoints
|
|
9
|
+
modules/deepest_ti
|
|
10
|
+
modules/expm
|
|
11
|
+
modules/get_emission_prob_mat
|
|
12
|
+
modules/get_joint_prob_mat
|
|
13
|
+
modules/get_trans_emiss
|
|
14
|
+
modules/helper_omegas
|
|
15
|
+
modules/ncpu
|
|
16
|
+
modules/optimizer
|
|
17
|
+
modules/read_data
|
|
18
|
+
modules/run_markov_chain_AB
|
|
19
|
+
modules/run_markov_chain_ABC
|
|
20
|
+
modules/trans_mat
|
|
21
|
+
modules/vanloan
|
|
22
|
+
modules/workflow_optimize
|
|
23
|
+
modules/workflow_posterior
|
|
24
|
+
modules/workflow_print_example
|
|
25
|
+
modules/workflow_viterbi
|
|
26
|
+
modules/yaml_helpers
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Command-Line Interface
|
|
2
|
+
======================
|
|
3
|
+
|
|
4
|
+
itrails provides several command-line entry points:
|
|
5
|
+
|
|
6
|
+
**itrails-optimize**
|
|
7
|
+
|
|
8
|
+
.. code-block:: bash
|
|
9
|
+
|
|
10
|
+
itrails-optimize --config config.yaml
|
|
11
|
+
|
|
12
|
+
Optimizes a tree based on ILS model parameters.
|
|
13
|
+
|
|
14
|
+
**itrails-viterbi**
|
|
15
|
+
|
|
16
|
+
.. code-block:: bash
|
|
17
|
+
|
|
18
|
+
itrails-viterbi --config config.yaml
|
|
19
|
+
|
|
20
|
+
Runs the Viterbi decoding to find the most likely state sequence.
|
|
21
|
+
|
|
22
|
+
**itrails-posterior**
|
|
23
|
+
|
|
24
|
+
.. code-block:: bash
|
|
25
|
+
|
|
26
|
+
itrails-posterior --config config.yaml
|
|
27
|
+
|
|
28
|
+
Computes posterior probabilities across the tree.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# For the full list of built-in configuration values, see the documentation:
|
|
4
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
5
|
+
|
|
6
|
+
# -- Project information -----------------------------------------------------
|
|
7
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
8
|
+
|
|
9
|
+
import datetime
|
|
10
|
+
import os
|
|
11
|
+
import re
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
# Add your package to sys.path
|
|
15
|
+
sys.path.insert(0, os.path.abspath("../src"))
|
|
16
|
+
|
|
17
|
+
# -- Project information -----------------------------------------------------
|
|
18
|
+
|
|
19
|
+
project = "itrails"
|
|
20
|
+
authors = ["David Martin-Pestana", "Iker Rivas-González"]
|
|
21
|
+
author = ", ".join(authors)
|
|
22
|
+
copyright = f"{datetime.datetime.now().year}, {author}"
|
|
23
|
+
|
|
24
|
+
# -- Version handling -------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
from itrails import __version__
|
|
28
|
+
except ImportError:
|
|
29
|
+
__version__ = "unknown"
|
|
30
|
+
|
|
31
|
+
# Strip off any Git commit or local metadata using regex
|
|
32
|
+
# e.g. "0.1.0a73.dev1+ge16dbd8" → "0.1.0a73"
|
|
33
|
+
base_version_match = re.match(r"^([0-9a-zA-Z.\-]+)", __version__)
|
|
34
|
+
clean_version = base_version_match.group(1) if base_version_match else "dev"
|
|
35
|
+
|
|
36
|
+
release = clean_version # full version, cleaned
|
|
37
|
+
version = ".".join(clean_version.split(".")[0:2]) # e.g. "0.1"
|
|
38
|
+
|
|
39
|
+
html_title = f"itrails v{release} documentation"
|
|
40
|
+
html_short_title = f"itrails v{release}"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# -- General configuration ---------------------------------------------------
|
|
44
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
45
|
+
|
|
46
|
+
extensions = [
|
|
47
|
+
"sphinx.ext.autodoc",
|
|
48
|
+
"sphinx.ext.napoleon",
|
|
49
|
+
"sphinx.ext.viewcode",
|
|
50
|
+
"sphinx.ext.autosummary",
|
|
51
|
+
"sphinx_autodoc_typehints",
|
|
52
|
+
"myst_parser",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
autosummary_generate = True
|
|
56
|
+
autodoc_default_options = {
|
|
57
|
+
"members": True,
|
|
58
|
+
"undoc-members": True,
|
|
59
|
+
"show-inheritance": True,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# Theme
|
|
63
|
+
html_theme = "furo"
|
|
64
|
+
templates_path = ["_templates"]
|
|
65
|
+
exclude_patterns = []
|
|
66
|
+
html_static_path = ["_static"]
|
|
67
|
+
html_css_files = ["custom.css"]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def setup(app):
|
|
71
|
+
app.add_js_file("rtd_version.js")
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
iTRAILS Documentation
|
|
2
|
+
=====================
|
|
3
|
+
|
|
4
|
+
Welcome to **iTRAILS**, a Python toolkit for ancestral state reconstruction using incomplete lineage sorting (ILS).
|
|
5
|
+
|
|
6
|
+
Features
|
|
7
|
+
--------
|
|
8
|
+
|
|
9
|
+
- Command-line tools for tree optimization, Viterbi decoding, and posterior inference.
|
|
10
|
+
- Full API documentation per module.
|
|
11
|
+
- YAML-based configuration for reproducible workflows.
|
|
12
|
+
|
|
13
|
+
Get Started
|
|
14
|
+
-----------
|
|
15
|
+
|
|
16
|
+
Install it:
|
|
17
|
+
|
|
18
|
+
.. code-block:: bash
|
|
19
|
+
|
|
20
|
+
pip install itrails
|
|
21
|
+
|
|
22
|
+
Try the optimizer:
|
|
23
|
+
|
|
24
|
+
.. code-block:: bash
|
|
25
|
+
|
|
26
|
+
itrails-optimize --config config.yaml
|
|
27
|
+
|
|
28
|
+
.. toctree::
|
|
29
|
+
:maxdepth: 2
|
|
30
|
+
:hidden:
|
|
31
|
+
|
|
32
|
+
cli
|
|
33
|
+
api
|