getFactoredEdges: Returns edges from a phylofactor

View source: R/getFactoredEdges.R

getFactoredEdgesR Documentation

Returns edges from a phylofactor

Description

Returns edges from a phylofactor

Usage

getFactoredEdges(v = NULL, tree, M = NULL, grp1 = NULL,
  grp2 = NULL)

Arguments

v

Optional input of an ILR-style partition vector, which automatically extracts grp1 and grp2

tree

Phylo object

M

Most recent common ancestor matrix of tree, the output from mrca

grp1

Vector of the indexes for tips contained in group1 (also the nodes corresponding to the tips in group1)

grp2

same as grp1, but must be a disjoint group from grp1.

Examples

#Case 1: mrca1>root:
set.seed(1)
tree <- rtree(12)
grp1 <- c(9:12)
grp2 <- c(1:8) #correct answer: 16
getFactoredEdges(tree=tree,grp1=grp1,grp2=grp2)

#Case 2: mrca2>root:
grp1 <- c(1:8)
grp2 <- c(9:12) #correct answer:16
getFactoredEdges(tree=tree,grp1=grp1,grp2=grp2)

grp1 <- c(1:8,12)
grp2 <- c(9:11) #correct answer: 17
getFactoredEdges(tree=tree,grp1=grp1,grp2=grp2)
#Case 3: mrca1>root & mrca2 >root - nodepath passing trough root
grp1 <- c(9:11)
grp2 <- c(2:3) #correct answer: c(17,16,6,1,3)
getFactoredEdges(tree=tree,grp1=grp1,grp2=grp2)
#Case 4: mrca1>root & mrca2 >root - nodepath NOT passing trough root
grp1 <- c(9:11)
grp2 <- c(5,6) #correct answer: c(17,16,7,8,10,11)
getFactoredEdges(tree=tree,grp1=grp1,grp2=grp2)

reptalex/phylofactor documentation built on Feb. 28, 2024, 3:19 p.m.