View source: R/tree_findChild.R
findChild | R Documentation |
Find the direct children of an internal node in a tree.
findChild(tree, node, use.alias = FALSE)
tree |
A |
node |
Either the node number or node label of an internal node of
|
use.alias |
A logical scalar. If |
A vector of nodes. The numeric value is the node number, and the
vector name is the corresponding node label. If a node has no label, it
would have NA as name when use.alias = FALSE
, and have the alias
of the node label as name when use.alias = TRUE
.
Ruizhu Huang, Charlotte Soneson
suppressPackageStartupMessages({
library(ggtree)
library(TreeSummarizedExperiment)
})
data(tinyTree)
ggtree(tinyTree, branch.length = "none") +
geom_text2(aes(label = node), color = "darkblue",
hjust = -0.5, vjust = 0.7) +
geom_text2(aes(label = label), color = "darkorange",
hjust = -0.1, vjust = -0.7)
## Specify node numbers
findChild(tree = tinyTree, node = c(17, 12))
## Name return values using aliases
findChild(tree = tinyTree, node = c(17, 12), use.alias = TRUE)
## Specify node labels
findChild(tree = tinyTree, node = c("Node_17", "Node_12"))
## Tips have no children
findChild(tree = tinyTree, node = "t4")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.