plt_recpd | R Documentation |
By default trees are plotted in 'willow tree' format, where the evolutionary distance between nodes/tips is mapped as branch width, instead of length.
plt_recpd( res, feat, map = c("anc_new", "anc_old"), tree.format = c("willow", "phylo"), direction = c("v", "h") )
res |
A results data.frame generated by recpd_calc(). |
feat |
A user-provided array of at least length 2, containing named features, or indices, corresponding to the feature column/rows of the recpd_calc() results data.frame. |
map |
Use finalized RecPD ancestral lineages ('anc_new') or preliminary state mappings ('anc_old'). |
tree.format |
Plot tree as phylogram ('phylo') or in willow-tree ('willow') format. |
direction |
Plotting direction of the tree: either vertical ('v') or horizontal ('h'). |
A ggtree object.
Cedoljub Bundalovic-Torma
library(ape) library(dplyr) library(ggplot2) ##Test case for a randomly generated tree (10 tips) and 10 randomly generated ###feature presence/absence (1, 0) data.frame. #Generate a random phylogenetic tree: n_tip <- 10 tree <- rtree(n_tip) #Generate 10 randomly distributed features (rows = features, columns = #phylogenetic tree tips): tab <- replicate(10, sapply(10, function(x) sample(c(0,1), x, replace=TRUE)), simplify='matrix') %>% t() %>% data.frame(check.names=FALSE) %>% rename_with(function(x) tree$tip.label[as.numeric(x)]) #Perform ancestral lineage reconstruction with recpd_calc(): #res <- recpd_calc(tree, tab, calc=TRUE) #Plot the tree: #plt_recpd(res, 1) + # #Can also add ggplot2 elements, like a title: # labs(title = res %>% # filter(feature == 1) %>% # paste(colnames(.), '=', ., collapse = '\n'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.