Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Likelihood ideas #8

Open
jhellewell14 opened this issue Dec 4, 2024 · 2 comments
Open

Likelihood ideas #8

jhellewell14 opened this issue Dec 4, 2024 · 2 comments

Comments

@jhellewell14
Copy link
Collaborator

Currently we use full Felsenstein likelihood for the tree (for comparison against phyML). We could try to implement some of calculation saving tricks used in MAPLE or we could also think about how to further integrate PoPPUNK and this tree program.

@jhellewell14
Copy link
Collaborator Author

Profiling suggests nearly all computation time is spent in the log and exp functions in the child_likelihood here:

pub fn child_likelihood_i(i: usize, ll: ndarray::ArrayBase<ndarray::ViewRepr<&f64>, ndarray::Dim<[usize; 1]>>, p: &na::Matrix4<f64>) -> f64 {

image

@jhellewell14
Copy link
Collaborator Author

I wonder if you could parallelise the section that iterates over nodes that need their likelihoods updating:

trees_rs/src/treestate.rs

Lines 149 to 166 in f1fdbdf

for node in nodes {
let (lchild, rchild) = (node.get_lchild().unwrap(), node.get_rchild().unwrap());
let seql = match temp_likelihoods.contains_key(&lchild) {
true => {temp_likelihoods.get(&lchild).unwrap().slice(s![.., ..])},
false => {slice_data(lchild, self.gen_data)},
};
let seqr = match temp_likelihoods.contains_key(&rchild) {
true => {temp_likelihoods.get(&rchild).unwrap().slice(s![.., ..])},
false => {slice_data(rchild, self.gen_data)},
};
let node_ll = node_likelihood(seql, seqr,
&matrix_exp(&rate_mat, new_ts.top.nodes[lchild].get_branchlen()),
&matrix_exp(&rate_mat, new_ts.top.nodes[rchild].get_branchlen()));
temp_likelihoods.insert(node.get_id(), node_ll);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant