make.gmap: Make a genetic subset map for rectangular landscape

View source: R/aggregate.R

make.gmapR Documentation

Make a genetic subset map for rectangular landscape

Description

Function to generate a map for aggregating populations from a fine-resolution forward-simulation for coalescent simulations.

Usage

make.gmap(pophist, xnum = 2, ynum = 2)

Arguments

pophist

a data frame describing the population history (source of colonists, time of colonization, etc.; output from getpophist2.cells()).

xnum

number of columns to aggregate

ynum

number of rows to aggregate

Details

Allows the user to specify a scheme for aggregation (e.g., 2x2 blocks of cells are combined if xnum and ynum = 2). If the size of the landscape in pophist is not evenly divisible by xnum and ynum, "remainder" cells on the top and righthand sides of the landscape will be included in genetic clusters. As a result the numbers of cells per cluster will vary

Value

a gmap object used for pophist.aggregate

See Also

pophist.aggregate, getpophist2.cells, run_FSC_step_agg3, doesGmapCombine

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,  #set at cell 540 right now 
                       refsz=parms$ref_Ne,
                       lambda=parms$lambda,
                       mix=parms$mix,  #note how small.
                       shortscale=parms$shortscale*avgCellsz,  # scale parameter of weibull with shape below
                       shortshape=parms$shortshape, #weibull shape
                       longmean=parms$longmean*avgCellsz,  # mean of normal with sd = longmean
                       ysz=res(landscape$sumrast)[2], #height of cell in raster (same units as longmean and shortscale)
                       xsz=res(landscape$sumrast)[1], #width of cell in raster
                       K = parms$Ne) #maximum population size in a grid cell, scaled with hab_suit from landscape object

gmap=make.gmap(ph$pophist,
               xnum=2, #number of cells to aggregate in x-direction
               ynum=2) #number of aggregate in the y-direction

ph2 <- pophist.aggregate(ph,gmap=gmap)


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