circle_general | R Documentation |
Generate a continuous raster map using circular moving windows.
While resist_gd is built specifically for making maps
of genetic diversity from vcfs,circle_general
can be used to make maps
from different data inputs. Unlike resist_gd
, resist_general
will not convert your data into the correct format for calculations of different
diversity metrics. See details for how to format data inputs for different statistics.
circle_general(
x,
coords,
lyr,
maxdist,
distmat = NULL,
stat,
fact = 0,
rarify = FALSE,
rarify_n = 2,
rarify_nit = 5,
min_n = 2,
fun = mean,
L = "nvariants",
rarify_alleles = TRUE,
sig = 0.05,
...
)
x |
data to be summarized by the moving window (note: order matters! |
coords |
coordinates of samples as sf points, a two-column matrix, or a data.frame representing x and y coordinates (see Details for important information about projections) |
lyr |
SpatRaster or RasterLayer to slide the window across (see Details for important information about projections) |
maxdist |
maximum geographic distance used to define neighborhood; any samples further than this distance will not be included (this can be thought of as the neighborhood radius)
Can either be (1) a single numeric value or (2) a SpatRaster where each pixel is the maximum distance to be used for that cell on the landscape (must be the same spatial scale as |
distmat |
distance matrix output from get_geodist (optional; can be used to save time on distance calculations) |
stat |
moving window statistic to calculate (see details). |
fact |
aggregation factor to apply to |
rarify |
if rarify = TRUE, rarefaction is performed (defaults to FALSE) |
rarify_n |
if rarify = TRUE, number of points to use for rarefaction (defaults to min_n) |
rarify_nit |
if rarify = TRUE, number of iterations to use for rarefaction (defaults to 5). Can also be set to |
min_n |
minimum number of samples to use in calculations (any focal cell with a window containing less than this number of samples will be assigned a value of NA; defaults to 2) |
fun |
function to use to summarize rarefaction results (defaults to mean, must take |
L |
for calculating |
rarify_alleles |
for calculating |
sig |
for calculating |
... |
if a function is provided for |
To calculate genetic diversity statistics with the built in wingen functions, data must be formatted as such:
for "pi"
or "biallelic_richness"
, x
must be a dosage matrix with values of 0, 1, or 2
for "Ho"
, x
must be a heterozygosity matrix where values of 0 = homozygosity and values of 1 = heterozygosity
for "allelic_richness"
or "hwe
, x
must be a genind
type object
for "basic_stats"
, x
must be a hierfstat
type object
Otherwise, stat
can be any function that takes a matrix or data frame and outputs a
single numeric value (e.g., a function that produces a custom diversity index);
however, this should be attempted with caution since this functionality has
not have been tested extensively and may produce errors.
SpatRaster that includes a raster layer of genetic diversity and a raster layer of the number of samples within the window for each cell
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.