plothist: plot the population history

View source: R/plothist.R

plothistR Documentation

plot the population history

Description

Plots the history of colonization events from a spatially-explicit forward simulation of population expansion.

Usage

plothist(ph, maxtime = NULL)

Arguments

ph

population history object (direct output from gepophist2.cells)

maxtime

the maximum number of generations to plot, sets the end of the period where colonization history is plotted (i.e., maxtime=100 plots the first 100 generations of the forward simulation).

Details

This function takes a fine-grained spatio-temporal history of a species generated by holoSimCell's forward-time simulator and produces a map that shows population spread through time. The input 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 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.

Value

Does not return an object, but creates a multi-panel plot illustrating the history of colonization of cells on the landscape (colored arrows, red arrows are associated with older events, yellow and white with more recent colonization), histogram illustrating the distribution of colonization times, and a simplified plot of centroid (mass-weighted range centroid - 'centroid' in enmSdm::bioticVelocity metrics - and centroid of the northern portion of the range - 'nCentroid' in enmSdm::bioticVelocity metrics) biotic velocity through time (generation-by-generation).

See Also

getpophist2.cells, plotHistSlice, bioticVelocity

Examples

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) 

plothist(ph)


stranda/holoSimCell documentation built on Aug. 4, 2023, 1:12 p.m.