View source: R/eems.posterior.draws.R
| eems.posterior.draws | R Documentation |
Given a set of EEMS output directories, this function takes random draws from the posterior
distribution of the migration and diversity rate parameters. Each draw is visualized as two
smoothed Voronoi diagrams; the migration diagram is saved to a file ending in mvoronoiXX,
the diversity diagram is saved to a file ending in qvoronoiXX where XX is a
numeric id. Specify the number of times to draw from the posterior with the argument
post.draws. If post.draws = 10, then eems.posterior.draws will generate
plots with id XX = 1 to XX = 10.
This function differs from eems.voronoi.samples() by plotting smoothed contour diagrams
rather than raw Voronoi plots.
eems.posterior.draws(
mcmcpath,
plotpath,
longlat,
post.draws = 1,
plot.width = 10,
plot.height = 10,
out.png = TRUE,
res = 600,
xpd = TRUE,
add.grid = FALSE,
col.grid = "gray80",
lwd.grid = 1,
add.demes = FALSE,
col.demes = "black",
pch.demes = 19,
min.cex.demes = 1,
max.cex.demes = 3,
add.outline = FALSE,
col.outline = "gray90",
lwd.outline = 2,
projection.in = NULL,
projection.out = NULL,
add.map = FALSE,
col.map = "gray60",
lwd.map = 2,
eems.colors = NULL,
add.colbar = FALSE,
m.colscale = NULL,
q.colscale = NULL,
add.title = FALSE,
m.plot.xy = NULL,
q.plot.xy = NULL
)
mcmcpath |
A vector of EEMS output directories, for the same dataset. Warning: There is minimal checking that the given directories are for the same dataset. |
plotpath |
The full path and the file name for the graphics to be generated. |
longlat |
A logical value indicating whether the coordinates are given as pairs (longitude, latitude) or (latitude, longitude). |
post.draws |
Number of times to sample from the posterior. The default is 1. |
plot.width |
The width of the graphics region for the two rate contour plots, in inches. The default value is 10. |
plot.height |
The height of the graphics region, in inches. The default value is 10. |
out.png |
A logical value which, if set, forces output graphics to be generated as PNGs
(if |
res |
Resolution, in dots per inch; used only for PNG images. The default is 600. |
xpd |
A logical value indicating whether to clip plotting to the figure region
( |
add.grid |
A logical value indicating whether to add the population grid or not. |
col.grid |
The color of the population grid. Defaults to |
lwd.grid |
The line width of the population grid. Defaults to 1. |
add.demes |
A logical value indicating whether to add the observed demes or not. |
col.demes |
The color of the demes. Defaults to |
pch.demes |
The symbol, specified as an integer, or the character to be used for plotting the demes. Defaults to 19. |
min.cex.demes |
The minimum size of the deme symbol/character. |
max.cex.demes |
The maximum size of the deme symbol/character. Defaults to 1 and 3,
respectively. If |
add.outline |
A logical value indicating whether to add the habitat outline or not. |
col.outline |
The color of the habitat outline. Defaults to |
lwd.outline |
The line width of the habitat outline. Defaults to 2. |
projection.in |
The input cartographic projection, specified as a PROJ.4 string. |
projection.out |
The output cartographic projection, specified as a PROJ.4 string. |
add.map |
A logical value indicating whether to add a high-resolution geographic map.
Requires the |
col.map |
The color of the geographic map. Default is |
lwd.map |
The line width of the geographic map. Defaults to 2. |
eems.colors |
The EEMS color scheme as a vector of colors, ordered from low to high.
Defaults to a DarkOrange to Blue divergent palette with six orange shades, white in the middle,
six blue shades. Acknowledgement: The default color scheme is adapted from the |
add.colbar |
A logical value indicating whether to add the color bar (the key that shows how colors map to rates) to the right of the plot. Defaults to TRUE. |
m.colscale |
A fixed range for log10-transformed migration rates. If the estimated rates fall outside the specified range, then the color scale is ignored. By default, no range is specified for either type of rates. |
q.colscale |
A fixed range for log10-transformed diversity rates. |
add.title |
A logical value indicating whether to add the main title in the contour plots. Defaults to TRUE. |
m.plot.xy |
Statements which add graphical elements (e.g. points) on top of the migration sufrace. |
q.plot.xy |
Statements which add graphical elements (e.g. points) on top of the diversity surface. |
Note about the implementation: eems.voronoi.samples samples randomly from the posterior
draws saved during the execution of EEMS, after burn-in and thinning.
None
Light A and Bartlein PJ (2004). The End of the Rainbow? Color Schemes for Improved Data Graphics. EOS Transactions of the American Geophysical Union, 85(40), 385.
eems.voronoi.samples
# Use the provided example or supply the path to your own EEMS run.
extdata_path <- system.file("extdata", package = "reems")
eems_results <- file.path(extdata_path, "EEMS-example")
# Create a temporary output directory for this example
outdir <- file.path(tempdir(), "path_out")
dir.create(outdir, showWarnings = FALSE)
name_figures <- file.path(outdir, "EEMS-example")
# Plot a series of Voronoi diagrams for the EEMS model parameters:
# the effective migration rates (m) and the effective diversity rates (q).
eems.posterior.draws(
mcmcpath = eems_results,
plotpath = paste0(name_figures, "-posterior-draws"),
longlat = TRUE,
post.draws = 2,
out.png = FALSE
)
# Delete the output directory to tidy up.
unlink(outdir, recursive = TRUE, force = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.