makePopdf: Create a popDF object

View source: R/makePopdf.R

makePopdfR Documentation

Create a popDF object

Description

Generates a population data frame with information on site IDs and cell or geographic coordinates of sampled populations

Usage

makePopdf(l, system = c("geo", "cell")[1])

Arguments

l

the landscape object used in the forward demographic simulation

system

specifies the coordinate system to use, either cells (x and y positions on the landscape) or geographic coordinates (latitude and longitude)

Details

The data frame produced by this function is used as an input for holoStats, particularly for spatial summaries of genetic variation on the landscape (e.g., isolation by distance analysis, relationships between genetic diversity and latitude / longitude)

Value

Returns a three-column data frame with population IDs (pop) and column (x) / row (y) locations on the simulated landscape for each sampled population

See Also

holoStats, ashSetupLandscape

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) 

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)

loc_parms <- data.frame(marker = "snp",
                        nloci = parms$nloci,           
                        seq_length = parms$seq_length,
                        mu = parms$mu)
  
preLGMparms <- data.frame(preLGM_t = parms$preLGM_t/parms$G,   
                          preLGM_Ne = parms$preLGM_Ne,
                         ref_Ne = parms$ref_Ne)

out <- runFSC_step_agg3(ph = ph2,
                        l = landscape,
                        sample_n = 14,
                        preLGMparms = preLGMparms,
                        label = "test",
                        delete_files = TRUE,
                        num_cores = 1,
                        exec = "fsc26",
                        loc_parms = loc_parms,
                        found_Ne = parms$found_Ne,
                        gmap = gmap,
                        MAF = 0.01,
                        maxloc = 50000)
popDF <- makePopdf(landscape,"cell")


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