-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,097 additions
and
1,525 deletions.
There are no files selected for viewing
277 changes: 258 additions & 19 deletions
277
.ipynb_checkpoints/Globins Experiment-checkpoint.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
1,324 changes: 604 additions & 720 deletions
1,324
.ipynb_checkpoints/Simulated Experiment-checkpoint.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,28 @@ | ||
@model function trajectory_reconstruction(Y, Z, M_YZ, Γ) | ||
@submodel X, M_XYZ = ancestor_chain_sampler(Y, Z, M_YZ) | ||
left = trajectory_reconstruction(Y, X, t/2) | ||
right = trajectory_reconstruction(X, Z, t/2) | ||
|
||
function trajectory_reconstruction(M_YZ::Alignment, | ||
Y::ObservedChain, Z::ObservedChain, | ||
ξ::MixtureProductProcess, t::Real, Λ; levels=1) | ||
# ______________________________________________________________________________ | ||
# Base case | ||
if levels == 0 | ||
return [Y, Z], M_YZ | ||
end | ||
|
||
# ______________________________________________________________________________ | ||
# Recursion | ||
|
||
# 1. Sample X midpoint of Y and Z, as well as the | ||
# alignment M_XYZ, given the alignment M_YZ | ||
X, M_XYZ = ancestor_sampling(M_YZ, Y, Z, t, ξ, Λ) | ||
|
||
# 2. Reconstruct trajectories recursively on each branch | ||
M_YX = subalignment(M_XYZ, [2, 1]) | ||
traj_YX, M_Y_toX = trajectory_reconstruction(M_YX, Y, X, ξ, t/2, Λ; levels-1) | ||
M_XZ = subalignment(M_XYZ, [1, 3]) | ||
traj_XZ, M_X_toZ = trajectory_reconstruction(M_XZ, X, Z, ξ, t/2, Λ; levels-1) | ||
|
||
# Combine the trajectories and alignments | ||
traj = [traj_YX; traj_XZ[2:end]] | ||
M = glue(M_Y_toX, M_X_toZ) | ||
return traj, M | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
@model function triple_alignment_sampler(Y, Z, W, Λ, ξ; max_N_X=200) | ||
# _____________________________________________________________________________ | ||
# Step 1 - Sample prior parameters | ||
|
||
# Time parameters | ||
t_Y ~ Exponential(1.0) | ||
t_Z ~ Exponential(1.0) | ||
t_W ~ Exponential(1.0) | ||
|
||
# Check parameter validity | ||
if t_Y ≤ 0 || t_Z ≤ 0 || t_W ≤ 0 | ||
reject_sample() | ||
end | ||
|
||
# _____________________________________________________________________________ | ||
# Step 2 - Observe data and simultaneously construct alignment | ||
|
||
# First, observe Y and Z and sample a triple alignment of X, Y and Z | ||
τ_XYZ = TKF92([t_Y, t_Z], Λ...; known_ancestor=false) | ||
(Y, Z) ~ ChainJointDistribution(ξ, τ_XYZ) | ||
M_XYZ ~ ConditionedAlignmentDistribution(τ_XYZ, ξ, Y, Z) | ||
|
||
# Construct X, the hidden ancestor chain, given alignment M_XYZ and data Y, Z | ||
X = hiddenchain_from_alignment(Y, Z, t_Y, t_Z, M_XYZ, ξ) | ||
|
||
# Finally, observe W given X and sample alignment of X and W | ||
τ_XW = TKF92([t_W], Λ...; known_ancestor=true) | ||
W ~ ChainTransitionDistribution(ξ, τ_XW, X) | ||
M_XW ~ ConditionedAlignmentDistribution(τ_XW, ξ, X, W) | ||
|
||
M_XYZW = combine(M_XYZ, M_XW) | ||
M_YZW = subalignment(M_XYZW, [2, 3, 4]) | ||
|
||
return t_Y, t_Z, t_W, M_YZW | ||
end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.