Skip to main content
`Ctrl`+`K`

# skbio.tree.TreeNode.remove_deleted

TreeNode.remove_deleted(func, uncache=True)

  Remove nodes of a tree that meet certain criteria.

  Changed in version 0.6.3: Renamed from `remove_deleted`. The old name is kept as an alias but is deprecated.

  Parameters:
    func callable

      A function that accepts a `TreeNode` and returns True or False, where True indicates the node is to be deleted.

    uncache bool, optional

      Whether to clear caches of the tree if present (default: True). See `details`.

      Added in version 0.6.3.

  See also

  `pop`
  `remove`

  Notes

  This method has the potential to drop entire clades. That is, if an internal node is removed, all its descendants are no longer connected to the tree, even if they are not explicitly removed.

  This method has the potential to leave single-child internal nodes in the tree, which can be further collapsed by `prune`.

  Examples

      >>> from skbio import TreeNode
      >>> tree = TreeNode.read(["(a,b)c;"])
      >>> tree.remove_by_func(lambda x: x.name == 'b')
      >>> print(tree)
      (a)c;