pophist.aggregate | R Documentation |
Combines grid cells from the forward-time demographic simulation into a smaller number of cells for coalescent simulation.
pophist.aggregate(ph, gmap = NULL)
ph |
the output from forward time sim, includes a pophist object (output by |
gmap |
data frame that maps forward time populations to genetic populations (output by |
This function takes a fine-grained spatio-temporal history of a species generated by holoSimCells forward-time simulator and aggregates demographic populations into genetic populations that can be simulated more tractably. The colonization history of component cells in the coarse grid is used to model proportional colonization from multiple source cells.
Returned 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 (aggregated) populations rows that provides population size through time from the forward demographic simulation.
tmat
a matrix of pairwise migration rates between (aggregated) 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 (aggregated) 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 grid cell from the forward-time demographic simulation. Each element includes information on location on the landscape, colonization time, source populations, and population size through time.
old_landscape
original landscape from the forward-time demographic simulation.
old_tmat
original migration matrix from the forward-time demographic simulation.
gmap
gmap object that maps cells from the demographic simulation to a coarser grid for coalescent simulations.
make.gmap
, doesGmapCombine
, getpophist2.cells
, run_FSC_step_agg3
, http://cmpg.unibe.ch/software/fastsimcoal26/man/fastsimcoal26.pdf
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)
gmap=make.gmap(ph$pophist,
xnum=2,
ynum=2)
ph2 <- pophist.aggregate(ph,gmap=gmap)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.