Description Details Author(s) References See Also Examples
This is a collection of functions for creating, manipulation, and plotting tree structures. If you want to convert your trees into displayable file formats, you will need the open source graph visualization software Graphviz (www.graphviz.org).
Package: | treeFun |
Type: | Package |
Version: | 1.0 |
Date: | 2015-03-17 |
License: | GPL (>= 2) |
Index:
1 2 3 4 5 6 7 8 | edges Extract edges of tree object
extract_tree Downstream extraction of subtrees
induced_tree Build tree induced by set of node ids
make_tree Convert data frame to tree structure
nodes Extract nodes of tree object
overlap_tree Find common subtree
tree_equal Test if two trees have the same edges
tree2dot Write tree to dot file
|
Clemens Baumbach
Maintainer: Clemens Baumbach <clemens.baumbach@helmholtz-muenchen.de>
Graphviz (open source graph visualization software, www.graphviz.org).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | library(treeFun)
d <- read.table(textConnection("\
id parents label
0 - a
1 0 b
2 0 c
3 1 d
4 1 e
5 1 f
6 2 g
7 2 h
8 7 i
"), header = TRUE, stringsAsFactors = FALSE)
## 0a
## / \
## / \
## 1b 2c
## /|\ / \
## / | \ / \
## 3d 4e 5f 6g 7h
## \
## \
## 8i
rownames(d) <- d$id
d2 <- d
d2$label <- toupper(d$label)
d2 <- d2[sample.int(nrow(d2)),]
## d2 has the same structure as d1 but its labels are in uppercase and
## its rows are permuted.
tr <- make_tree(d)
tr2 <- make_tree(d2)
tree_equal(tr, tr2)
stopifnot(tree_equal(extract_tree(tr, 999), tr))
stopifnot(tree_equal(extract_tree(tr, 2, from = 1), make_tree(d[c("1", "3", "4", "5"), ])))
nodes(tr)
edges(tr)
## Not run: tree2dot(tr, "tree.dot")
itr1 <- induced_tree(c("1","8"), tr)
itr2 <- induced_tree(c("2","5"), tr)
overlap_tree(list(itr1, itr2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.