assignColorBreaks {BAMMtools}R Documentation

Map macroevolutionary rates to colors

Description

Maps macroevolutionary rates to a set of NCOLORS.

Usage

assignColorBreaks(
  rates,
  NCOLORS = 64,
  spex = "s",
  logcolor = FALSE,
  method = c("linear", "quantile", "jenks"),
  JenksSubset = NULL
)

Arguments

rates

A numeric vector of phenotypic rates or a list of numeric vectors of speciation and extinction rates.

NCOLORS

An integer number of colors to use for the mapping. Larger numbers do not necessarily result in smoother looking color ramps. The default is 64 and is probably sufficient for most purposes.

spex

A character string. "s" means that speciation rates are used to make the map, "e" means that extinction rates are used. "netdiv" means that diversification rates are used. Ignored for BAMM trait data.

logcolor

Logical. Should the natural logarithm of rates be used for the color map.

method

Determines how the color breaks are created. See Details.

JenksSubset

Number of regularly spaced samples to subset from rates. Only relevant when method = "jenks". See Details.

Details

If method = "quantile" macroevolutionary rates are binned into NCOLORS+1 percentiles and rates in each bin are mapped to a color determined by the pal argument in plot.bammdata. Alternatively, if method = "linear" macroevolutionary rates are binned into NCOLORS+1 equal length intervals between the minimum and maximum.

If method = "jenks", macroevolutionary rates are binned into NCOLORS+1 categories, according to the Jenks natural breaks classification method. This method is borrowed from the field of cartography, and seeks to minimize the variance within categories, while maximizing the variance between categories.

The Jenks natural breaks method was ported to C from code found in the classInt R package.

Value

A numeric vector of rate percentiles/intervals.

Author(s)

Mike Grundler, Pascal Title

See Also

plot.bammdata

Examples

data(whales, events.whales)
ed <- getEventData(whales, events.whales, burnin = 0.2, nsamples = 500)

ed <- dtRates(ed, 0.01)
colors <- assignColorBreaks(ed$dtrates$rates, spex="s") #speciation rates
#colors <- assignColorBreaks(ed$dtrates$rates[[1]]) 
#this also works for speciation rates

plot(ed, colorbreaks = colors, spex="s")
colors <- assignColorBreaks(ed$dtrates$rates, spex="netdiv") 
#diversification rates

#colors <- assignColorBreaks(ed$dtrates$rates[[1]] - ed$dtrates$rates[[2]]) 
#this also works for diversification rates

plot(ed, colorbreaks = colors, spex="netdiv")

[Package BAMMtools version 2.1.11 Index]