# a simple tree
data("tree5", package = "nichevol")
# a matrix of niche charactes (1 = present, 0 = absent, ? = unknown)
dataTable <- cbind("241" = rep("1", length(tree5$tip.label)),
"242" = rep("1", length(tree5$tip.label)),
"243" = c("1", "1", "0", "0", "0"),
"244" = c("1", "1", "0", "0", "0"),
"245" = c("1", "?", "0", "0", "0"))
rownames(dataTable) <- tree5$tip.label
# list with two objects (tree and character table)
treeWdata <- geiger::treedata(tree5, dataTable)
# Maximum parsimony reconstruction
rec_tab <- smooth_rec(bin_par_rec(treeWdata))
# plotting and adding labels and legend
ape::plot.phylo(tree5, label.offset = 0.04)
niche_labels(tree5, rec_tab, height = 0.6)
niche_legend(position = "topleft", cex = 0.7)
Run the code above in your browser using DataLab