Skip to contents

Create a subtree by specifying tips to keep.

Usage

tree_subset(tree, tips)

Arguments

tree

A phylo object, as returned from read_tree().

tips

A character, numeric, or logical vector of tips to keep.

Value

A phylo object for the subtree.

See also

Other phylogeny: read_tree()

Examples

    library(rbiom)
    
    infile <- system.file("extdata", "newick.tre", package = "rbiom")
    tree <- read_tree(infile)
    tree
#> 
#> Phylogenetic tree with 20 tips and 19 internal nodes.
#> 
#> Tip labels:
#>   Pa5Bac29, AtlPorci, AciSp313, MxlBact8, MxlBacte, PseS1107, ...
#> 
#> Rooted; includes branch lengths.
    
    subtree <- tree_subset(tree, tips = head(tree$tip.label))
    subtree
#> 
#> Phylogenetic tree with 6 tips and 5 internal nodes.
#> 
#> Tip labels:
#>   Pa5Bac29, AtlPorci, AciSp313, MxlBact8, MxlBacte, PseS1107
#> 
#> Rooted; includes branch lengths.