Tree reconstruction of ancestry using incomplete lineage sorting
Project description
TRAILS
Define demographic model and calculate transition and emission probabilities:
from trails.optimizer import trans_emiss_calc
from trails.cutpoints import cutpoints_ABC
import pandas as pd
n_int_AB = 3
n_int_ABC = 3
mu = 2e-8
N_AB = 25000*2*mu
N_ABC = 25000*2*mu
t_1 = 240000*mu
t_2 = 40000*mu
t_3 = 800000*mu
t_upper = t_3-cutpoints_ABC(n_int_ABC, 1/N_ABC)[-2]
t_out = t_1+t_2+t_3+2*N_ABC
r = 1e-8/mu
transitions, emissions, starting, hidden_states, observed_states = trans_emiss_calc(
t_1, t_1, t_1+t_2, t_2, t_upper, t_out,
N_AB, N_ABC, r, n_int_AB, n_int_ABC)
Print transition probability matrix:
df_transitions = pd.DataFrame(transitions).melt(ignore_index = False).reset_index(level=0)
df_transitions.columns = ['from', 'to', 'value']
df_transitions['from'] = [hidden_states[i] for i in df_transitions['from']]
df_transitions['to'] = [hidden_states[i] for i in df_transitions['to']]
df_transitions = df_transitions.sort_values(['from', 'to']).reset_index(drop=True)
print(df_transitions)
from to value
0 (0, 0, 0) (0, 0, 0) 9.986414e-01
1 (0, 0, 0) (0, 0, 1) 2.717854e-04
2 (0, 0, 0) (0, 0, 2) 2.717854e-04
3 (0, 0, 0) (0, 1, 0) 1.831404e-04
4 (0, 0, 0) (0, 1, 1) 5.365867e-08
.. ... ... ...
724 (3, 2, 2) (3, 0, 1) 5.593765e-08
725 (3, 2, 2) (3, 0, 2) 2.437075e-04
726 (3, 2, 2) (3, 1, 1) 2.767875e-08
727 (3, 2, 2) (3, 1, 2) 2.706694e-04
728 (3, 2, 2) (3, 2, 2) 9.974707e-01
[729 rows x 3 columns]
Print emission probability matrix:
df_emissions = pd.DataFrame(emissions).melt(ignore_index = False).reset_index(level=0)
df_emissions.columns = ['hidden', 'observed', 'value']
df_emissions['hidden'] = [hidden_states[i] for i in df_emissions['hidden']]
df_emissions['observed'] = [observed_states[i] for i in df_emissions['observed']]
df_emissions = df_emissions.sort_values(['hidden', 'observed']).reset_index(drop=True)
print(df_emissions)
hidden observed value
0 (0, 0, 0) AAAA 0.236472
1 (0, 0, 0) AAAC 0.003146
2 (0, 0, 0) AAAG 0.003146
3 (0, 0, 0) AAAT 0.003146
4 (0, 0, 0) AACA 0.000459
... ... ... ...
6907 (3, 2, 2) TTGT 0.000905
6908 (3, 2, 2) TTTA 0.002240
6909 (3, 2, 2) TTTC 0.002240
6910 (3, 2, 2) TTTG 0.002240
6911 (3, 2, 2) TTTT 0.232358
[6912 rows x 3 columns]
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
trails-rivasiker-0.0.1.tar.gz
(34.3 kB
view details)
Built Distribution
File details
Details for the file trails-rivasiker-0.0.1.tar.gz
.
File metadata
- Download URL: trails-rivasiker-0.0.1.tar.gz
- Upload date:
- Size: 34.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 654188fc965a0491b6656d401a76b19f02f3ad24876bfd58d26bfe5c77ea4410 |
|
MD5 | 7df704a7a4688879e7e3fb9db40ec075 |
|
BLAKE2b-256 | a4dd16af7af1de0109b7b163c631748cc8118f9e16ea5bacc69037dacc1a1faa |
File details
Details for the file trails_rivasiker-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: trails_rivasiker-0.0.1-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf111a219d24285389c1dbc4fc39d72634434cdf47e95c9937c68bbff24e0f55 |
|
MD5 | d0cfbdb33ce6edc9dff2f58b7eca5cf3 |
|
BLAKE2b-256 | f9fbcd7601107379f652d82af001da030dcab7f49eb7804edcb5c420504cc10c |