treeConcordance: Tree concordance

View source: R/treeConcordance.R

treeConcordanceR Documentation

Tree concordance

Description

This function calculates the concordance between a category tree and an individuals tree

Usage

treeConcordance(catTree, indTree, df)

Arguments

catTree

object of class phylo

indTree

object of class phylo

df

data frame specifying to which category each individual belongs. Each row gives an individual (column 2) and its corresponding category (column 1)

See Also

simulateIndTree makeCollapsedTree

Examples

# create an example category tree
catTree <- read.tree(text="(C:1,(B:1,A:1):1);")
plot(catTree)

# make individuals tree with complete concordance:
indTree1 <- read.tree(text="(((c4,c3),(c2,c1)),((b1,b2),((a3,a2),a1)));")
plot(indTree1)

# create data frame linking categories with individuals
df <- cbind(c(rep("A",3),rep("B",2),rep("C",4)),sort(indTree1$tip.label))

treeConcordance(catTree,indTree1,df)

# make a less concordant tree:
indTree2 <- read.tree(text="((((c4,c3),(c2,c1)),b2),(b1,((a3,a2),a1)));")
plot(indTree2)
treeConcordance(catTree,indTree2,df)

# simulate larger example:
catTree <- rtree(10)
indTree3 <- simulateIndTree(catTree, tipPercent=10)
df <- cbind(sort(rep(catTree$tip.label,5)),sort(indTree3$tip.label))
plot(indTree3)
treeConcordance(catTree,indTree3,df)


treespace documentation built on Sept. 8, 2023, 6:04 p.m.