File: makeCollapsedTree.Rd

package info (click to toggle)
r-cran-treespace 1.1.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,444 kB
  • sloc: cpp: 24; sh: 13; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,996 bytes parent folder | download | duplicates (4)
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/makeCollapsedTree.R
\name{makeCollapsedTree}
\alias{makeCollapsedTree}
\title{Collapse a tree into a single tip per category}
\usage{
makeCollapsedTree(tree, df, warnings = TRUE)
}
\arguments{
\item{tree}{an object of the class \code{phylo}: the tree to collapse.}

\item{df}{a two-column data frame linking tip labels (column 2) with their corresponding categories (column 1).}

\item{warnings}{a logical determining whether a warning should be given if there are paraphyletic categories (default TRUE)}
}
\value{
A tree (class \code{phylo}) whose tip labels are exactly the set of unique categories from \code{df}.
}
\description{
Reduce a tree with many tips into a tree with a single tip per category. 
Where a category's tips form a monophyletic clade, the clade is replaced by a single tip labelled by that category.
Where a category's tips are paraphyletic, the largest clade for that category is treated as above, and all other tips pruned.
}
\examples{
 
# simulate a tree which is monophyletic per category
tree <- simulateIndTree(rtree(5), permuteTips=FALSE)

df <- cbind(sort(rep(rtree(5)$tip.label,5)),sort(tree$tip.label))
palette <- c("red","blue","black","green","purple")#' 
tipCols <- palette[as.factor(sapply(tree$tip.label, function(l) df[which(df[,2]==l),1]))]
plot(tree, tip.color=tipCols)
collapsedTree <- makeCollapsedTree(tree,df)
plot(collapsedTree, tip.color=palette[as.factor(collapsedTree$tip.label)])

# simulate a tree which is paraphyletic per category
tree <- simulateIndTree(rtree(5), tipPercent=20)
tipCols <- palette[as.factor(sapply(tree$tip.label, function(l) df[which(df[,2]==l),1]))]
plot(tree, tip.color=tipCols)
collapsedTree <- makeCollapsedTree(tree,df)
plot(collapsedTree, tip.color=palette[as.factor(collapsedTree$tip.label)])

}
\seealso{
\code{\link{treeConcordance}} \code{\link{simulateIndTree}}
}
\author{
Michelle Kendall \email{michelle.louise.kendall@gmail.com}
}