gdist.prep: Prepare data for optimization using 'gdistance'

View source: R/gdistance.R

gdist.prepR Documentation

Prepare data for optimization using gdistance

Description

Creates a necessary input for optimizing resistance surfaces based on pairwise cost distances, implemented using the gdistance library

Usage

gdist.prep(n.Pops, 
                  response = NULL,
                  samples,
                  covariates = NULL,
                  formula = NULL,
                  transitionFunction = function(x)  1 / mean(x),
                  directions = 8,
                  longlat = FALSE,
                  method = 'commuteDistance',
                  min.max_dist = NULL,
                  keep = NULL)

Arguments

n.Pops

The number of populations that are being assessed

response

Vector of pairwise genetic distances (lower half of pairwise matrix).

samples

Either provide the path to a .txt file containing the xy coordinates, or provide a matrix with x values in column 1 and y values in column 2. Alternatively, you can provide a SpatialPoints object

covariates

Data frame of additional covariates that you want included in the MLPE model during opitmization.

formula

If covariates are included in the model, specify the R formula for the fixed effects portion of the MLPE model.

transitionFunction

The function to calculate the gdistance TransitionLayer object. See transition. Default = function(x) 1/mean(x)

directions

Directions in which cells are connected (4, 8, 16, or other). Default = 8

longlat

Logical. If true, a geoCorrection will be applied to the transition matrix. Default = FALSE

method

Specify whether pairwise distance should be calulated using the costDistance or commuteDistance (Default) functions. costDistance calculates least cost path distance, commuteDistance is equivalent (i.e. nearly perfectly correlated with) resistance distance calculated by CIRCUITSCAPE.

min.max_dist

NOT YET SUPPORTED. Optional. Specify the minimum and maximum distance at which pairwise comparisons will be made(e.g., c(1, 50)). Euclidean distances below and above the minumum and maximum values will be omitted from the analysis. This has potential to reduce analysis time, but also reduces the number of pairwise comparisons.

keep

NOT YET SUPPORTED. An optional vector equal to length response (i.e. all pairwise observations), with 1 indicating to keep the observation, and 0 to drop the observation. This can be used in conjunction with, or in place of min.max_dist to select which observations to include in analyses.

Details

When specifying a formula, provide it as: response ~ covariate. the formula response will use the vector of values specified for the response parameter. Make sure that covariate names match variable names provided in covariates

Value

An R object that is a required input into optimization functions

Author(s)

Bill Peterman <Peterman.73@osu.edu>

Examples

 
## Not run:
## *** TO BE COMPLETED *** ##

## End (Not run)

wpeterman/ResistanceGA documentation built on Nov. 20, 2023, 11:50 p.m.