plot.rates.RR: Map RRphylo evolutionary rates of univariate data on...

View source: R/plot_rates_RR.R

plot.rates.RRR Documentation

Map RRphylo evolutionary rates of univariate data on phylogeny

Description

This function plots the evolutionary rates of a data vector reconstructed with the [RRphylo::RRphylo] method onto a phylogenetic tree. Choices are given regarding the execution of RRphylo, of the colors to be mapped, and to the mapping itself.

Usage

plot.rates.RR(RR,tree,y,partial.cov,partial.x1,absrates=FALSE,
              RR.args=NULL,scale.palette.args=NULL,contMap.args=NULL)

Arguments

RR

Optional. The RRphylo object to work with. If not provided, it is computed (which can take time depending on the data).

tree

A phylogenetic tree.

y

A data vector.

partial.cov

Optional. A covariate (see [RRphylo::RRphylo] help page for more details) with data only for tips; full covariate (i.ee., with data for tips and for nodes) is then computed within this function.

partial.x1

Optional. A predictor (see [RRphylo::RRphylo] help page for more details) with data only for tips; full predictor (i.ee., with data for tips and for nodes) is then computed within this function.

absrates

Logical. Specify whether the user wants to plot natural evolutionary rates (absrates=FALSE) or absolute evolutionary rates (absrates=TRUE). Default turned to FALSE.

RR.args

A list of arguments to be passed to the [RRphylo::RRphylo] function (see function help page for details), with the exception of tree and y.

scale.palette.args

A list of arguments to be passed to the [ULT::scale.palette] function (see function help page for details). By default, color is set to a blue-white-red gradient with the white a central color and 0 a central value (scale.palette.args=list(cols=c("blue","white","red"),middle.col="white",middle=0,steps=NA)) for natural evolutionary rates, and to a heatmap using [RColorBrewer::brewer.pal] (scale.palette.args=list(cols=brewer.pal(9,"YlOrRd"),middle.col=brewer.pal(9,"YlOrRd")[5],middle=NA,steps=NA)) for absolute evolutionary rates.

contMap.args

A list of arguments to be passed to the [phytools::contMap] function (see function help page for details), with the exception of tree, x, method, and anc.states.

Details

. The goal of this function is to perform separately the phylogenetic comparative method, the color mapping, and the mapping itself, letting the user give additional arguments for each step. The function first runs the [RRphylo::RRphylo] function if a RR object is not provided, taking into account potential supplementary arguments. Then, the function computes a "basic" mapping using the [phytools::contMap] function but does not show it, taking into account potential additional arguments to be passed to this specific function. Then, the function recreates a color gradient using the [ULT::scale.palette] function, taking into account potential arguments to be passed to this function. Finally, the function replaces the original color gradient by the new, user-specified, one, and plots the new mapping with it.
A supplementary interesting point of this function is that the user can provide a covariate and/or a predictor of the variable with only tip values; the function then runs the whole process. Additionally, the user can choose whether to plot the original evolutionary rates or their absolute values.

Examples

require(ape)
require(phytools)
require(RRphylo)
set.seed(1)
tree<-rtree(20)
y<-fastBM(tree)
RR<-RRphylo(tree=tree,y=y)
plot.rates.RR(tree=tree,y=y)
set.seed(2)
x1<-fastBM(tree)*runif(1,-5,5)+runif(1,-5,5)+rnorm(20)
plot.rates.RR(tree=tree,y=y,partial.x1=x1)
plot.rates.RR(tree=tree,y=y,partial.x1=x1,absrates=TRUE)
set.seed(3)
cov<-fastBM(tree)*runif(1,-5,5)+runif(1,-5,5)+rnorm(20)
plot.rates.RR(tree=tree,y=y,partial.cov=cov)
plot.rates.RR(tree=tree,y=y,partial.cov=cov,absrates=TRUE)
plot.rates.RR(tree=tree,y=y,partial.x1=x1,partial.cov=cov)
plot.rates.RR(tree=tree,y=y,partial.x1=x1,partial.cov=cov,absrates=TRUE)


jacobmaugoust/ULT documentation built on May 16, 2023, 1:29 p.m.