View source: R/plothistslice.R
plotHistSlice | R Documentation |
Plots the history of colonization events from a spatially-explicit forward simulation of population expansion up to a specified time step in the simulation.
plotHistSlice(timeslice, ph, landscape, window = c(0, timeslice))
timeslice |
the layer of the landscape that corresponds to a time step (generation) in the simulation |
ph |
population history object (direct output from |
landscape |
the landscape object that drives the simulation (see |
window |
(optional, default = c(0,timeslice)) a two-element vector that defines the window of time for colonization events shown in the plot |
This function takes a fine-grained spatio-temporal history of a species generated by the forward-time simulator and produces a map that shows population spread through time (up to a specified time step). The input ph object includes the following named components:
pophist
a data frame with population ID, cell row, cell column, timing of colonization, and source population associated with colonists.
Nvecs
a data frame with number of generations columns and number of populations rows that provides population size through time from the forward demographic simulation.
tmat
a matrix of pairwise migration rates between populations, used in subsequent coalescent simulations.
struct
a vector summarizing the structure of the simulated landscape from the forward simulation, x and y dimensions of the grid, number of generations, disperal parameters, etc.
hab_suit
a matrix with number of generations rows and number of populations columns that provides habitat suitability through time.
coalhist
a data frame specifying historical events for the coalescent simulation, includes time of event (time), source (src) and sink (snk) IDs, and fractional colonization (prop).
popslst
a list object with one element per population from the forward-time demographic simulation. Each element includes information on location on the landscape, colonization time, source populations, and population size through time.
Does not return an object, but creates a plot illustrating the history of colonization of cells on the landscape over a specified time in the simulation. Arrows indicate the direction of colonization and points are sized relative to population size in the forward simulation. Habitat suitability (at generation timeslice
) is represented by a color gradient (green as highest suitability).
getpophist2.cells
, plothist
, ashSetupLandscape
library(holoSimCell)
parms <- drawParms(control = system.file("extdata/ashpaper","Ash_priors.csv",package="holoSimCell"))
load(file=paste0(system.file(package="holoSimCell"),"/extdata/landscapes/",pollenPulls[[1]]$file))
refpops <- pollenPulls[[1]]$refs
avgCellsz <- mean(c(res(landscape$sumrast)))
ph = getpophist2.cells(h = landscape$details$ncells, xdim = landscape$details$x.dim, ydim = landscape$details$y.dim,
landscape=landscape,
refs=refpops,
refsz=parms$ref_Ne,
lambda=parms$lambda,
mix=parms$mix,
shortscale=parms$shortscale*avgCellsz,
shortshape=parms$shortshape,
longmean=parms$longmean*avgCellsz,
ysz=res(landscape$sumrast)[2],
xsz=res(landscape$sumrast)[1],
K = parms$Ne)
plotHistSlice(timeslice = 20, ph = ph, landscape = landscape)
plotHistSlice(timeslice = 200, ph = ph, landscape = landscape, window = c(150,200))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.