Skip to content

phylim should accept likelihood functions #23

Description

@GavinHuttley

The current implementation of the phylim app only accepts a model_result object. This does not work if the model result has come from a split_codon=True model. In the latter case, there is no single likelihood function so the line

tree = model_result.lf.tree

fails because model_result.lf is an ordered dictionary instead of a likelihood function.

Here are several possible solutions.

solution 1

To this is to implement a separate method that uses singledispatchmethod decorator to split the inference based on whether the input data is a model_result or a likelihood function object. A user could then extract the individual likelihood functions from a split_codon model result and pass each separately to the app.

This allows a user to handle custom cases themselves, but puts the burden of that solution on them.

solution 2

We examine whether the model result has multiple values and if it does we iterate over those values producing a single PhyloLimitRec as the output.

This is the lowest barrier to the user and does not require a change on the current phylim.main() method.

solution 3

We do both of the above. I think this is what's going to be required.

the workaround

For current users, if you encounter this problem here's the work around. In brief, you will need to create a separate model_result from each likelihood function in your split_codon=True result.

from cogent3.app.result import model_result
from cogent3.app.composable import define_app
from phylim.apps import phylim, PhyloLimitRec

@define_app
def phylim_split_codon(result: model_result, check_one: phylim) -> PhyloLimitRec:
    """checks individual likelihood functions from a split_codon model_result"""
    for k in range (1, 4):
        value = result[k]
        one = model_result(name=result.name, source=result.source)
        one['value'] = value
        checked = check_one(one)
        if not checked.is_identifiable:
            return checked
    return checked

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions