| plot_contMap | R Documentation |
Plot on a time-calibrated phylogeny the evolution of a continuous trait as
summarized in a contMap object typically generated with prepare_trait_data().
This function is a wrapper of original functions from the R package {phytools}:
Step 1: Use phytools::setMap() to update the color scale if requested.
Step 2: Use phytools::plot.contMap() to plot the mapped phylogeny.
plot_contMap(
contMap,
color_scale = NULL,
...,
display_plot = TRUE,
PDF_file_path = NULL
)
contMap |
List of class |
color_scale |
Vector of character string. List of colors to use to build the color scale with |
... |
Additional arguments to pass down to |
display_plot |
Logical. Whether to display the plot generated in the R console. Default is |
PDF_file_path |
Character string. If provided, the plot will be saved in a PDF file following the path provided here. The path must end with ".pdf". |
This function is a wrapper of original functions phytools::setMap() and phytools::plot.contMap(). Additions are listed below:
The color scale can be controlled directly with the argument color_scale.
The plot can be exported in PDF using PDF_file_path to define the output file.
If display_plot = TRUE, the function plots the time-calibrated phylogeny displaying the evolution of a continuous trait.
If PDF_file_path is provided, the function exports the plot into a PDF file.
An object of class "contMap" with an (optionally) updated color scale ($cols) is returned invisibly.
Maël Doré
Original functions by Liam Revell in R package {phytools}. Contact: liam.revell@umb.edu
phytools::plot.contMap() plot_densityMaps_overlay()
# Load phylogeny
data(Ponerinae_trait_tip_data, package = "deepSTRAPP")
# Load trait df
data(Ponerinae_tree, package = "deepSTRAPP")
## Prepare trait data
# (May take several minutes to run)
# Extract continuous trait data as a named vector
Ponerinae_cont_tip_data <- setNames(object = Ponerinae_trait_tip_data$fake_cont_tip_data,
nm = Ponerinae_trait_tip_data$Taxa)
# Get Ancestral Character Estimates based on a Brownian Motion model
# To obtain values at internal nodes
Ponerinae_ACE <- phytools::fastAnc(tree = Ponerinae_tree, x = Ponerinae_cont_tip_data)
# Infer Ancestral Character Estimates based on a Brownian Motion model
# and run a Stochastic Mapping to interpolate values along branches and obtain a "contMap" object
Ponerinae_contMap <- phytools::contMap(Ponerinae_tree, x = Ponerinae_cont_tip_data,
res = 100, # Number of time steps
plot = FALSE)
# Plot contMap with the phytools method
plot(x = Ponerinae_contMap, fsize = c(0.5, 1))
# Plot contMap with an updated color scale
plot_contMap(contMap = Ponerinae_contMap, fsize = c(0.5, 1),
color_scale = c("darkgreen", "limegreen", "orange", "red"))
# PDF_file_path = "Ponerinae_contMap.pdf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.