aphylo
object with partial annotationsR/aphylo_from_data_frame.R
aphylo_from_data_frame.Rd
Create an aphylo
object with partial annotations
aphylo_from_data_frame(tree, annotations, types = NULL)
An object of class phylo
.
A data.frame with annotations. The first column should be the gene id (see details).
A data.frame with types. Just like the annotations, the first column should be the gene id.
An object of class aphylo.
Each row in the the annotations
data frame passed to this function
must have a unique row per gene, and one column per function (GO term). The id
of each gene must match the labels in the tree
object. Missing genes are
annotated with NA
(9).
In the case of types
, while tips can also be annotated with a type, which
should be either 0, duplication, or 1, speciation, only internal nodes
are required. Tip types are ignored.
Other Data management functions:
aphylo-class
# Generating a test dataset
set.seed(1371)
x <- raphylo(20)
# Extracting the tree and annotations
tree <- x$tree
anno <- with(x, rbind(tip.annotation, node.annotation))
anno <- data.frame(id = with(tree, c(tip.label, node.label)), anno)
types <- data.frame(id = tree$node.label, x$node.type)
# Creating a aphylo tree without node types
aphylo_from_data_frame(tree, anno)
#>
#> Phylogenetic tree with 20 tips and 19 internal nodes.
#>
#> Tip labels:
#> 1, 2, 3, 4, 5, 6, ...
#> Node labels:
#> 21, 22, 23, 24, 25, 26, ...
#>
#> Rooted; no branch lengths.
#>
#> Tip (leafs) annotations:
#> fun0000
#> 1 1
#> 2 0
#> 3 1
#> 4 1
#> 5 1
#> 6 1
#>
#> ...(14 obs. omitted)...
#>
#>
#> Internal node annotations:
#> fun0000
#> 1 1
#> 2 1
#> 3 1
#> 4 1
#> 5 1
#> 6 1
#>
#> ...(13 obs. omitted)...
#>
# Now including types
aphylo_from_data_frame(tree, anno, types)
#>
#> Phylogenetic tree with 20 tips and 19 internal nodes.
#>
#> Tip labels:
#> 1, 2, 3, 4, 5, 6, ...
#> Node labels:
#> 21, 22, 23, 24, 25, 26, ...
#>
#> Rooted; no branch lengths.
#>
#> Tip (leafs) annotations:
#> fun0000
#> 1 1
#> 2 0
#> 3 1
#> 4 1
#> 5 1
#> 6 1
#>
#> ...(14 obs. omitted)...
#>
#>
#> Internal node annotations:
#> fun0000
#> 1 1
#> 2 1
#> 3 1
#> 4 1
#> 5 1
#> 6 1
#>
#> ...(13 obs. omitted)...
#>
# Dropping some data
aphylo_from_data_frame(tree, anno[sample.int(nrow(anno), 10),])
#>
#> Phylogenetic tree with 20 tips and 19 internal nodes.
#>
#> Tip labels:
#> 1, 2, 3, 4, 5, 6, ...
#> Node labels:
#> 21, 22, 23, 24, 25, 26, ...
#>
#> Rooted; no branch lengths.
#>
#> Tip (leafs) annotations:
#> fun0000
#> 1 9
#> 2 0
#> 3 9
#> 4 9
#> 5 9
#> 6 1
#>
#> ...(14 obs. omitted)...
#>
#>
#> Internal node annotations:
#> fun0000
#> 1 1
#> 2 9
#> 3 9
#> 4 9
#> 5 9
#> 6 9
#>
#> ...(13 obs. omitted)...
#>