R/tip.color.R

Defines functions tip.color

Documented in tip.color

## This code is part of the viper package
## © C. Heibl 2014 (last update 2016-11-29)

#' @export

tip.color <- function(phy, tips, regex = FALSE, col, bgcol){
	
	# checks and definitions
	# ----------------------
	if (!inherits(phy, "phylo"))
		stop("'phy' is not of class 'phylo'")
	if (missing(bgcol)) bgcol <- "black"
	tiplab <- phy$tip.label
	nbtips <- length(tiplab)
	tipcol <- rep(bgcol, nbtips)
		
	if (!is.list(tips)) tips <- list(tips)
	
	for (i in seq(along = tips)){
		pattern <- paste(tips[[i]], collapse = "|")
		tipcol[grep(pattern, tiplab, fixed = FALSE)] <- col[i]
	}
	tipcol
}
heibl/viper documentation built on May 21, 2019, 10:47 a.m.