R/allCladeMembers.R

Defines functions allCladeMembers

Documented in allCladeMembers

#' allCladeMembers (internal function)
#'
#' This is an internal function to generate an allCladeMembersMatrix
#' @param phy phylogeny in ape phylo format
#' @return cladeMembersMatrix
#' @author Gavin Thomas
#' @export

allCladeMembers <- function(phy) {
	
	nodeIDs <- c(1:Ntip(phy), (Ntip(phy)+2):(Ntip(phy) + Nnode(phy)))
	k <- length(nodeIDs)
   cladeMembersMatrix <-  sapply(nodeIDs, function(k) {
    	nodeShiftID <- c(k, node.descendents(x = k , phy = phy))
    	as.numeric(phy$edge[, 2] %in% nodeShiftID)
    	}
    )
    return(cladeMembersMatrix)
}

Try the motmot.2.0 package in your browser

Any scripts or data that you put into this service are public.

motmot.2.0 documentation built on May 1, 2019, 9:22 p.m.