Skip to content

KeyError in difFUBAR_bayesian_postprocessing when background branches exist #76

@stevenweaver

Description

@stevenweaver

Bug

difFUBAR_bayesian_postprocessing crashes with KeyError(0.05) when the tree has untagged (background) branches.

Cause

In difFUBAR.jl:181-182, collapse_counts is called with cases=omegagrid for all omega components:

site_counts_ω1 = collapse_counts(ω1, alloc_grid[:, site], cases=omegagrid)
site_counts_ω2 = collapse_counts(ω2, alloc_grid[:, site], cases=omegagrid)

When is_background == true, ω2 = [c[3] for c in codon_param_vec] contains values from background_omega_grid (built via gridsetup(0.05, 6.0, 4, ...)), but the lookup dict is built from omegagrid (built via gridsetup(0.01, 13.0, 6, ...)). The value 0.05 exists in the background grid but not in the foreground grid → KeyError.

Fix

background_omega_grid needs to be threaded through to difFUBAR_bayesian_postprocessing and used as cases when collapsing background omega counts.

Reproduction

Run difFUBAR on any dataset with a single {Foreground} tag where some branches remain untagged (triggering background inference). Tested with CodonMolecularEvolution v0.1.0 on Julia 1.11.6.

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