rdm_resistance: Produces environmental resistance to dispersal over a...

View source: R/rdm_resistance_v11_TF_TQ.R

rdm_resistanceR Documentation

Produces environmental resistance to dispersal over a landscape, for individuals in a population

Description

rdm_resistance: Reads in IBD residuals for pairs of individuals in a population, represented as line segments connecting the pairs of individuals over a defined landscape, and then applies a novel method (Tang et al., in review) to the residuals to calculate environmental resistance to dispersal over the landscape. Essentially, the method splits the landscape into a grid of cells and for each cell, calculates the resistance as the average of the IBD residuals of all line segments that intersect the cell.

Usage

rdm_resistance(IBD.res, Res_SLDF, nrows = 30, ncols = 30,
  conf_intervals = 0.95, random_rep = 1000,
  outputfile = "resistance_map.csv")

Arguments

IBD.res

An object of class dist, containing a matrix with the IBD residuals for pairs of individuals in a population.

Res_SLDF

An object of class SpatialLinesDataFrame, containing the IBD residuals for each pair of individuals in a population and the coordinates of line segments connecting the pairs of individuals over the defined landscape. This object is produced by the function rdm_residual.

nrows

Number of grid cells in each row of the raster map of resistance. The default value is 30.

ncols

Number of grid cells in each column of the raster map of resistance. The default value is 30.

conf_intervals

The coverage of the confidence interval generated for each resistance value in a grid cell, expressed as a proportion. This interval measures the uncertainty in the (observed) resistance in each cell. If a cell has no intersecting line segments or only one, then a confidence interval cannot be calculated and the cell is no longer considered for further calculation. If the confidence interval does not overlap 0, then the resistance is statistically different from 0. The default value is 0.95 (corresponding to 95% intervals).

random_rep

Number of random resamples of the IBD residuals used to construct the null distribution of resistances in each grid cell. For a grid cell with n intersecting line segments and n corresponding IBD residuals, a random resample consists of randomly sampling n IBD residuals from the set of all IBD residuals over the entire landscape, without replacement. If the observed resistance is above a threshold percentile of the null distribution, then the cell is considered to have a high resistance that is statistically significant. If instead the observed resistance is below another threshold percentile of the null distribution, then the cell is considered to have a low resistance that is statistically significant. The default value is 1,000.

outputfile

Name of the .csv file that is produced, containing resistance information in the output data frame. The default is 'resistance_map.csv'.

Value

A data frame with resistance information for each grid cell in the landscape with more than one intersecting line segment. Each row corresponds to one cell, and the eight different columns refer to the resistance, the number of intersecting line segments, the x and y coordinates specifying the location of the mid-point of the cell, the lower and upper limits of the confidence interval for the resistance, the sign of the product of the lower and upper limits of the confidence interval, and the percentile of the null distribution of resistances corresponding to the observed resistance. When calculating this data, the function rdm_resistance prints out messages showing the current stage of calculation. There are four stages: Calculating (1) the resistances, (2) the numbers of intersecting line segments, (3) the lower limits of the confidence intervals for the resistances, and (4) the upper limits of the confidence intervals for the resistances.

References

Tang, Q., Fung, T., Rheindt, F.E. (In review). ResDisMapper: An R package for fine-scale mapping of resistance to dispersal.

Examples

IBD_res <- rdm_IBD("files/genotypes.gen", "files/coordinates.txt")
Res_SLDF <- rdm_residuals(IBD_res, "files/coordinates.txt")
rdm_resistance(IBD_res, Res_SLDF)

takfung/ResDisMapper documentation built on Jan. 27, 2024, 8:36 a.m.