Description Usage Arguments Details Value Examples
View source: R/sim_pheno_cline.R
This function generates a dataframe with simulated trait data sampled from a phenotypic cline. The sampling sites, number of individuals, phenotypic variance (sigma), and cline parameters are supplied by the user.
1 2 | sim_pheno_cline(transect_distances, n_ind, sigma, decrease, center, width,
pmin, pmax)
|
transect_distances |
The distances along the transect for the simulated sampling sites. A numeric vector. |
n_ind |
The number of individuals sampled at each site. Either a
single numeric value (for constant sampling), or a numeric vector equal in
length to |
sigma |
The simulated phenotypic variance, given in terms of standard
deviation for a normal distribution. Must be numeric and > 0. Either a
single numeric value (for constant variance), or a numeric vector equal
in length to |
decrease |
Is the cline decreasing in frequency? |
center |
The location of the cline center, in the same distance units as
|
width |
The width of the cline, in the same distance units as
|
pmin, pmax |
The minimum and maximum mean phenotypic trait value in the tails of the cline. Numeric. |
This function calls general_cline_eqn
for each sampled point along the
cline to generate the expected mean phenotype at that point.
For each site the specified number of individuals are simulated. Trait values are drawn from a normal distribution, with mean equal to the expected mean phenotype and standard devitation equal to the provided sigma.
A data frame of simulated phenotypic data sampled from the cline. Each row representes a single individual. Columns are:
site: The site numbers, given sequentially starting at 1.
transectDist: The distance along the cline for each individual
traitValue: The simulated trait value for each individual.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Simulate phenotype data from a decreasing cline
# with center at 100, width of 30, pmin of 10 and pmax of 40.
# Sites are 20 units apart, from 0 to 200.
# 20 individuals are sampled at each site.
# Variance is constant at sigma = 6.
set.seed(123)
sim_pheno_cline(transect_distance = seq(0,200,20),
n_ind = 20, sigma = 6,
decrease = TRUE,
center = 100, width = 30,
pmin = 10, pmax = 40)
# Simulate phenotype data from an increasing cline
# with center at 272, width of 91.
# The minimum and maximum mean phenotype values
# are 32 and 49, respectively.
# Sites are 13 units apart, from 162 to 312.
# At each site, the number of individuals sampled
# is drawn from a random normal distribution with
# mean = 25 and sd = 5
# variance is constant at sigma = 4.67.
set.seed(123)
ind_sampling <- as.integer(rnorm(length(seq(162,312,12)), 25, 5))
sim_pheno_cline(transect_distance = seq(162,312,12),
n_ind = ind_sampling,
sigma = 4.67, decrease = FALSE,
center = 272, width = 91,
pmin = 32, pmax = 49)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.