Description Usage Arguments Value Examples
Phylogenetic trees depict the evolutionary relationships between different species. Each branch in a phylogenetic tree represents a period of evolutionary history. Species that are connected to the same branch both share that same period of evolutionary histroy. This function creates a matrix that shows which species are connected with branch. In other words, it creates a matrix that shows which periods of evolutionary history each species experienced.
1 2 3 4 5 6 7 | branch_matrix(x)
## Default S3 method:
branch_matrix(x)
## S3 method for class 'phylo'
branch_matrix(x)
|
x |
|
dgCMatrix-class
sparse matrix object. Each row
corresponds to a different species. Each column corresponds to a different
branch. Species that inherit from a given branch are denoted with a one.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # load data
data(sim_phylogeny)
# generate species by branch matrix
m <- branch_matrix(sim_phylogeny)
# plot data
if (requireNamespace("ape", quietly = TRUE)) {
par(mfrow = c(1,2))
plot(sim_phylogeny, main = "phylogeny")
plot(raster(as.matrix(m)), main = "branch matrix")
} else {
message("the \"ape\" package needs to be installed to plot phylogenies")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.