Skip to content

Simplifying when keeping unary nodes but excluding input roots #3450

@hyanwong

Description

@hyanwong

The simplify docs say:

keep_unary (bool) – If True, preserve unary nodes (i.e., nodes with exactly one child) that exist on the path from samples to root. (Default: False)

and also

keep_input_roots (bool) – Whether to retain history ancestral to the MRCA of the samples. If False, no topology older than the MRCAs of the samples will be included. If True the roots of all trees in the returned tree sequence will be the same roots as in the original tree sequence. (Default: False)

However, on testing the interacting between these, it seems as if, contrary to the docs, even when keep_input_roots=False, topology older than the MRCAs of the samples is still included if keep_unary=True:

ts = tskit.Tree.generate_comb (10).tree_sequence
ts = ts.simplify([6, 7, 8, 9], keep_input_roots=True)
ts = ts.simplify(keep_unary=True, keep_input_roots=False)  # I think this should remove node 7, but it doesn't
ts.draw_svg()

This is either a bug, or a documentation issue. If we keep the current behaviour and document it, then I am looking for a way to keep unary nodes except those above the local roots, and I can't think of an easy way to do that, without going through the trees one-by-one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions