extract_deep_frame: Extract tips representing a tree's deep splits.

View source: R/extract_deep_frame.R

extract_deep_frameR Documentation

Extract tips representing a tree's deep splits.

Description

Given a rooted phylogenetic tree, extract a subset of tips representing the tree's deepest splits (nodes), thus obtaining a rough "frame" of the tree. For example, if Nsplits=1 and the tree is bifurcating, then two tips will be extracted representing the two clades splitting at the root.

Usage

extract_deep_frame(tree,
                   Nsplits    = 1,
                   only_tips  = FALSE)

Arguments

tree

A rooted tree of class "phylo".

Nsplits

Strictly positive integer, specifying the maximum number of splits to descend from the root. A larger value generally implies that more tips will be extracted, representing a larger number of splits.

only_tips

Boolean, specifying whether to only return the subset of extracted tips, rather than the subtree spanned by those tips. If FALSE, a subtree is returned in addition to the tips (this comes at a computational cost).

Details

The tree may include multi-furcations (i.e. nodes with more than 2 children) as well as mono-furcations (i.e. nodes with only one child). No guarantee is made as to the precise subset of tips extracted.

Value

A named list with the following elements:

tips

Integer vector with values from 1 to Ntips, listing the indices of the extracted tips.

subtree

A new tree of class "phylo", the subtree spanned by the extracted tips. Only included if only_tips==FALSE.

Author(s)

Stilianos Louca

See Also

get_pairwise_mrcas, get_tips_for_mrcas

Examples

# generate a random tree
Ntips = 100
tree = generate_random_tree(list(birth_rate_factor=0.1),Ntips)$tree

# extract a subtree representing the deep splits
subtree = extract_deep_frame(tree, Nsplits=3)$subtree


castor documentation built on Aug. 18, 2023, 1:07 a.m.