View source: R/pophistToArray.r
| pophistToArray | R Documentation |
This function converts a "pophist" object to an array. This function is helpful for converting a "pophist" object to input for the bioticVelocity function.
pophistToArray(x, longitude = NULL, latitude = NULL, times = NULL, warn = TRUE)
x |
A pophist object (a list). |
longitude |
Either |
latitude |
Either |
times |
Either |
warn |
Logical, if |
Utility function for pre-processing an Nvecs matrix from a pophist object for biotic velocity calculations.
A list object with:
pophistAsArray: Array representing values in x$pophist with one "layer" (3rd dimension) per time period.
longitude: Array representing longitudes.
latitude: Array representing latitudes.
times: Vector representing times.
getpophist2.cells, NvecNAs, bioticVelocity
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)
times_1k <- seq(-21000,0,by=990)
pharray <- pophistToArray(NvecNAs(ph, landscape), times = times_1G)
metrics <- c('centroid', 'nsQuants', 'summary')
BV_permill_all <- bioticVelocity(
x=pharray$pophistAsArray,
times = times_1G,
atTimes = times_1k,
longitude=pharray$longitude,
latitude=pharray$latitude,
metrics=metrics,
quants=c(0.05, 0.1, 0.9, 0.95),
onlyInSharedCells = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.