Commit 9a5ce92
Alexandra (Tally) Balaban
Changed ForwardProbMIG name to ForwardProbA. Now ForwardProbMIG calculates eq. 30.
in cjumpchain one of the comments for SampleFromIS is wrong.
For the next level, (i.e., level 3) the initial character state
assignment will be: {1:0, 4:1, 5:1} (since 2 & 3 were in state
1, their parent 5 also will be in state 1).
{1:0, 4:1, 5:1} as the initial character state assignment
I changed this to
For the next level, (i.e., level 3) the initial character state
assignment will be: {1:0, 4:1, 5:1} (since 2 & 3 were in state
0, their parent 5 also will be in state 0).
{1:0, 4:1, 5:0} as the initial character state assignment
Re-wrote def GetInfoForForwardProbMIG(A,level): into a multiple functions compatible with A's tree structure:
GetNumberOfLevels(A):
GetBranchLength(A,level):
GetNumberOfMigrationEvents(A,level):
GetQ_bbAndQ_bt(A,level):
I need help with this one
Different inputs, but same function:
ProbKMigrationInL(level,l,k,q_bb,q_bt,sigma)
PhiJK(j,k,(r_t,q_bb,q_b_arrow_t,q_bt),sigma)
Phi(i,(r_t,q_bb,q_b_arrow_t,q_bt),sigma):
Implemented GetH(X,i,A,sigma): Gives the rate of event X in the ith level
Implemented GetHBar(i,A,sigma): gives the sum of the rates of all possible speciation events in the level i
Implemented GetYi(A,i): returns the speciation event that ends level i
Theoretically, ForwardProbA should be working now, (which may mean all of is_likelihood is implemented and working)
Added to MakeTransitionMatrixForLevel documentation
Didn't like PickNextStateofChain implementation. May work, but not intuitive to me, so re-wrote.
I think there is an error in the last lines of code of ChooseLineageAndUpdateDelta. If lineages are already in state 1, they shouldn't be included in the random_list.
As code was:
for i in range(len(current_delta)):
if (i != next_coalescing_lineages[0].index and i != next_coalescing_lineages[1].index):
random_list.append(i)
random.shuffle(random_list)
lineage_to_migrate = random_list[0]
if (current_delta[lineage_to_migrate] == 1):
#the if statement is really redundant
current_delta[lineage_to_migrate] = 0
return random_list[0]
So I changed the line to
if (i != next_coalescing_lineages[0].index and i != next_coalescing_lineages[1].index and current_delta[i]!=1):
I also added an assert statement to ChooseLineageAndUpdateDelta
changed delta structure to reflect the fact that delta is appended to event history and should be consistent with the event_history description in is_classes. So I changed current_delta from " a list of of character states (boreal or tropical)"
to " a map of lineage indices to character states". Made modifications in the code to reflect the fact that delta is a map, not a list.
added all_delta, a map of all lineages at all levels to their states. As it is updated as A is created, it will eventually be a map of all lineages to their states right after they came into existence
MoveToNextLevel finished
Edited PrepareTree
in SampleFromIS
if(index_of_next_state==len(transition_matrix_for_the_level):
whether_in_the_same_level == False
#whether_in_the_same_level = WhetherInTheSameLevel(state_of_cond_jump_chain,next_state_of_cond_jump_chain)
Since next_state_of_cond_jump_chain = index_in_transition_matrix_to_state[len(index_in_transition_matrix_to_state)] is undefined. A kappa event has an index of len(index_in_transition_matrix_to_state) which is outside of the range of index_in_transition_matrix_to_state.
created a Test function to get the inputs for SampleFromIS
SampleFromIS when called from the Test function in cjumpchain is returning a value and is filling out the event_histories for each level
I haven't gotten around to debugging is_likelihood yet.1 parent a83b9c0 commit 9a5ce92
File tree
6 files changed
+515
-335
lines changed6 files changed
+515
-335
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
24 | 78 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | 79 | | |
50 | 80 | | |
51 | 81 | | |
| |||
56 | 86 | | |
57 | 87 | | |
58 | 88 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 89 | + | |
| 90 | + | |
62 | 91 | | |
63 | | - | |
64 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
65 | 96 | | |
66 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
67 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
68 | 159 | | |
69 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
70 | 163 | | |
71 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
72 | 200 | | |
73 | 201 | | |
| 202 | + | |
74 | 203 | | |
75 | 204 | | |
76 | 205 | | |
77 | 206 | | |
78 | | - | |
79 | | - | |
| 207 | + | |
| 208 | + | |
80 | 209 | | |
81 | 210 | | |
82 | 211 | | |
83 | 212 | | |
| 213 | + | |
| 214 | + | |
84 | 215 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 216 | + | |
88 | 217 | | |
89 | | - | |
90 | 218 | | |
91 | | - | |
92 | | - | |
| 219 | + | |
93 | 220 | | |
94 | 221 | | |
95 | | - | |
| 222 | + | |
96 | 223 | | |
97 | 224 | | |
98 | 225 | | |
| |||
101 | 228 | | |
102 | 229 | | |
103 | 230 | | |
104 | | - | |
105 | | - | |
| 231 | + | |
| 232 | + | |
106 | 233 | | |
107 | 234 | | |
108 | 235 | | |
109 | 236 | | |
110 | 237 | | |
111 | 238 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | 239 | | |
116 | 240 | | |
117 | | - | |
118 | 241 | | |
119 | 242 | | |
120 | | - | |
121 | | - | |
122 | 243 | | |
123 | 244 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 245 | + | |
| 246 | + | |
134 | 247 | | |
135 | 248 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 249 | + | |
143 | 250 | | |
144 | 251 | | |
145 | 252 | | |
146 | | - | |
| 253 | + | |
147 | 254 | | |
148 | 255 | | |
149 | 256 | | |
150 | 257 | | |
151 | 258 | | |
152 | | - | |
153 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
154 | 262 | | |
155 | 263 | | |
156 | 264 | | |
| |||
159 | 267 | | |
160 | 268 | | |
161 | 269 | | |
162 | | - | |
| 270 | + | |
163 | 271 | | |
164 | 272 | | |
165 | 273 | | |
| |||
364 | 472 | | |
365 | 473 | | |
366 | 474 | | |
367 | | - | |
| 475 | + | |
368 | 476 | | |
369 | 477 | | |
370 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | | - | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
133 | | - | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
137 | | - | |
| 138 | + | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
0 commit comments