R/check.TaxAgainstPhy.R

check.TaxAgainstPhy <- function(phy, tax, rank = NULL){
  
  if ( !inherits(phy, "phylo") )
    stop("argument 'phy' is not of class 'phylo'")
  
  ## intersect tax and phy
  ## ---------------------
  tax <- tax[tax$spec %in% phy$tip.label, ]
  phy <- drop.tip(phy, phy$tip.label[!phy$tip.label %in% tax$spec])
  
  x <- split(tax$spec, tax[rank])
  
  obj <- data.frame(taxon = names(x))
  obj <- cbind(obj, 
               topo = sapply(x, is.monophyletic, phy = phy))
  obj$topo[obj$topo] <- "mono"
  obj <- cbind(obj, size = sapply(x, length))
  obj
}

Try the megaptera package in your browser

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

megaptera documentation built on Jan. 15, 2017, 11:19 p.m.