knitr::opts_chunk$set(echo = TRUE)

Extracting and working with subtrees using ape

library(ape)
remote_dir="https://raw.githubusercontent.com/PacktPublishing/R-Bioinformatics-Cookbook/master"
newick <-read.tree(file.path(remote_dir, "datasets", "ch4", "mammal_tree.nwk"))

Plotting Trees

plot(newick)

Plotting A Subtree

l <- subtrees(newick)
plot(l[[4]], sub = "Node 4")

pick subtree graphically

#subtreeplot(newick)

Extract a tree manually

small_tree <- extract.clade(newick, 9)
new_tree <- bind.tree(newick, small_tree, 3)
plot(new_tree)


eckartbindewald/bfxapps2 documentation built on Feb. 6, 2025, 3:22 a.m.