plot.anc.RR | R Documentation |
This function plots a data vector onto a phylogenetic tree with ancestral reconstructions following [RRphylo::RRphylo] method. Choices are given regarding the execution of RRphylo, of the colors to be mapped, and to the mapping itself.
plot.anc.RR(RR,tree,y,partial.cov,partial.x1,res.x1=FALSE,
RR.args=NULL,scale.palette.args=NULL,contMap.args=NULL)
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. |
res.x1 |
Logical. If a predictor ('full' or 'partial') is provided, to know whether plotted data should be the |
RR.args |
A list of arguments to be passed to the [RRphylo::RRphylo] function (see function help page for details), with the exception of |
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 ( |
contMap.args |
A list of arguments to be passed to the [phytools::contMap] function (see function help page for details), with the exception of |
. 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, if a predictor is specified, the user can choose whether to plot the original data or the residuals of the variable vs predictor regression.
require(ape)
require(phytools)
require(RRphylo)
set.seed(1)
tree<-rtree(20)
y<-fastBM(tree)
RR<-RRphylo(tree=tree,y=y)
plot.anc.RR(tree=tree,y=y)
set.seed(2)
x1<-fastBM(tree)*runif(1,-5,5)+runif(1,-5,5)+rnorm(20)
plot.anc.RR(tree=tree,y=y,partial.x1=x1)
plot.anc.RR(tree=tree,y=y,partial.x1=x1,res.x1=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.