simulate_spatial_niches | R Documentation |
This function creates a spatial niche around specified origin points in a coordinate data frame. The niche is defined by a specified size and is used to modify values in the data frame based on proximity to the origin points.
simulate_spatial_niches(
coords_df,
origins,
size,
size_fct = 1.1,
vt,
vf = NULL,
rr = c(0, 1),
type = "small",
seed = 123
)
coords_df |
A data frame containing spatial coordinates and other variables. |
origins |
A character vector specifying the barcodes of the origin points around which the niche will be created. |
size |
A numeric value specifying the size of the niche around each origin point. |
vt |
The name of the variable in |
vf |
The name of the variable in |
rr |
A numeric vector of length 2 specifying the range for generating random values. Default is c(0, 1). |
seed |
A numeric value specifying the seed for random number generation. Default is 123. |
The function works by calculating the distances from each origin point to all other points in coords_df
.
Points that fall within the specified niche size around each origin are identified, and their values in the vt
variable are modified based on the vf
variable.
If vf
is NULL, random values within the specified range (rr
) are generated and used.
A data frame with the modified values based on the created spatial niche.
## Not run:
df <- data.frame(x = runif(100, 0, 10), y = runif(100, 0, 10), value = rnorm(100))
df_with_niche <- simulate_spatial_niches(df, origins = c("A", "B"), size = 5, vt = "value")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.