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")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(BAMMtools)
Loading required package: ape
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BAMMtools/assignColorBreaks.Rd_%03d_medium.png", width=480, height=480)
> ### Name: assignColorBreaks
> ### Title: Map macroevolutionary rates to colors
> ### Aliases: assignColorBreaks
> ### Keywords: graphics
>
> ### ** Examples
>
> data(whales, events.whales)
> ed <- getEventData(whales, events.whales, burnin = 0.2, nsamples = 500)
Processing event data from data.frame
Discarded as burnin: GENERATIONS < 1995000
Analyzing 500 samples from posterior
Setting recursive sequence on tree...
Done with recursive sequence
>
> 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")
>
>
>
>
>
> dev.off()
null device
1
>