crossVmap | R Documentation |
maps groups from old to new communities for phylofactor cross-validation
crossVmap(Grps, tree, original_community, new_community,
ignore.interruptions = T)
Grps |
list of length two containing the names of taxa (found in tip-labels of |
tree |
phylo class object. Must contain all |
original_community |
original community being factored (strings corresponding to tip-labels of |
new_community |
new community being cross-validated (strings corresponding to tip-labels of |
ignore.interruptions |
Logical on whether or not to ignore edges in new-community that interrupt the edges separating |
set.seed(1)
tree <- ape::rtree(7)
c1 <- c('t2','t5','t6','t3','t4','t7')
c2 <- setdiff(tree$tip.label,c('t3','t4','t5'))
grp1 <- c('t3','t6')
grp2 <- c('t2','t7')
Grps <- list(grp1,grp2)
factored.edges <- getFactoredEdges(grp1=match(grp1,tree$tip.label),
grp2=match(grp2,tree$tip.label),tree=tree)
ecols <- rep('grey',ape::Nedge(tree))
ecols[factored.edges] <- 'red'
ecols[12] <- 'yellow'
ecols[c(2,3,10,11)] <- 'blue'
plot(tree,use.edge.length = FALSE,
edge.width = 3,edge.color = ecols)
tiplabels(tree$tip.label,cex=3)
# one clade interrupts our chain of branches: t1
# another clade: [t4,t5], was factored out previously and is not in our Grps
# We have an optional output "ignore.interruptions=T' which omits interruptions
# in output of group comparisons.
# if ignore.interruptions=F, we want to output the list of possible groups
# for iteration and refinement of which edge along the chain holds an effect.
# the default is to ignore interruptions, and it should output
# [[t2,t7]],[[t6]]
# by succesfully ignoring t1.
crossVmap(Grps,tree,c1,c2)
#correct
#Quick check - let's include two interruptions, one of which contains the root
grp1 <- c('t4','t5')
grp2 <- c('t1')
Grps <- list(grp1,grp2)
c1 <- c(grp1,grp2,'t6')
c2 <- setdiff(tree$tip.label,'t4')
#correct output should be [[t3]],[[t5]]
crossVmap(Grps,tree,c1,c2)
# Now, suppose we wanted to use those interruptions to refine phylofactorization
# to a subset of the original edges
crossVmap(Grps,tree,c1,c2,ignore.interruptions = FALSE)
#notice the output: the first and last entries are our output from crossVmap
#when ignore.interruptions=T. The intervening elements are the interrupting clades
#in the order in which they interrupt the factored edges.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.