Title: | Simulate and Estimate Close-Kin Dispersal Kernels |
---|---|
Description: | Functions for simulating and estimating kinship-related dispersal. Based on the methods described in M. Jasper, T.L. Schmidt., N.W. Ahmad, S.P. Sinkins & A.A. Hoffmann (2019) <doi:10.1111/1755-0998.13043> "A genomic approach to inferring kinship reveals limited intergenerational dispersal in the yellow fever mosquito". Assumes an additive variance model of dispersal in two dimensions, compatible with Wright's neighbourhood area. Simple and composite dispersal simulations are supplied, as well as the functions needed to estimate parent-offspring dispersal for simulated or empirical data, and to undertake sampling design for future field studies of dispersal. For ease of use an integrated Shiny app is also included. |
Authors: | Moshe-Elijah Jasper [aut, cre] |
Maintainer: | Moshe-Elijah Jasper <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.10.3 |
Built: | 2024-11-20 02:49:48 UTC |
Source: | https://github.com/moshejasper/kindisperse |
KinPairSimulation
objectsThese generics & methods work with KinPairSimulation
objects to access & modify information about the dispersal
sigma parameters that define the stored simulation. The posigma()
method accesses the single dispersal parameter
stored in a simulation with simtype == "simple"
. The remaining parameters access the dispersal parameters stored
in a simulation with simtype == "composite"
. The dispersal kernel sigma parameters of simtype == "custom"
simulations are not yet implemented here. Assignment operations currently only exist as generics (they are not yet applied
to the KinPairSimulation
class).
posigma(x) posigma(x) <- value initsigma(x) initsigma(x) <- value breedsigma(x) breedsigma(x) <- value gravsigma(x) gravsigma(x) <- value ovisigma(x) ovisigma(x) <- value ## S4 method for signature 'KinPairSimulation' posigma(x) ## S4 method for signature 'KinPairSimulation' initsigma(x) ## S4 method for signature 'KinPairSimulation' breedsigma(x) ## S4 method for signature 'KinPairSimulation' gravsigma(x) ## S4 method for signature 'KinPairSimulation' ovisigma(x)
posigma(x) posigma(x) <- value initsigma(x) initsigma(x) <- value breedsigma(x) breedsigma(x) <- value gravsigma(x) gravsigma(x) <- value ovisigma(x) ovisigma(x) <- value ## S4 method for signature 'KinPairSimulation' posigma(x) ## S4 method for signature 'KinPairSimulation' initsigma(x) ## S4 method for signature 'KinPairSimulation' breedsigma(x) ## S4 method for signature 'KinPairSimulation' gravsigma(x) ## S4 method for signature 'KinPairSimulation' ovisigma(x)
x |
object of class |
value |
new value to assign |
KinPairSimulation |
object of class KinPairSimulation |
numeric
value of specified sigma parameter or modified KinPairSimulation
object
posigma(KinPairSimulation)
:
initsigma(KinPairSimulation)
:
breedsigma(KinPairSimulation)
:
gravsigma(KinPairSimulation)
:
ovisigma(KinPairSimulation)
:
Other kpsmethods:
filter_methods
,
kernelshape()
,
kerneltype()
,
simtype()
This function performs a basic estimation of axial dispersal for a numeric vector of distances between close kin dyads. The axial dispersal distance returned is interpretable as the standard deviation of one dimension of a symmetric bivariate random distribution centred on zero.
axials(valvect, composite = 1)
axials(valvect, composite = 1)
valvect |
A numeric vector of distances between close kin OR an object of class |
composite |
numeric. The number of separate 'draws' (dispersal events) from the kernel required to produce the final positions of the measured individuals. For example, the displacement of a child from parent at the same lifestage would involve 1 draw and thus be composite = 1. Two full siblings would be two draws (composite = 2) from the FS kernel. Non-symmetric relationships (e.g. AV, 1C) should not be decomposed using this method, nor should any assumptions be made about different kernels (e.g. the 1C relationship would appropriately be given the value 2, but not 4) |
Returns the value of the estimated axial dispersal distance of the kernel producing the dispersal distances measured. (numeric)
Other axial_helpers:
axials_add()
,
axials_decompose()
,
axials_subtract()
,
axpermute()
,
axpermute_subtract()
po_dists <- c(5, 6, 7.5) axials(po_dists) # one 'draw' (dispersal event) goes into the parent offspring category # so composite is left to its default of 1 fs_dists <- c(2, 3, 3) axials(fs_dists, composite = 2) # two 'draws' (symmetric dispersal events) # go into the full sibling category so composite is set to 2
po_dists <- c(5, 6, 7.5) axials(po_dists) # one 'draw' (dispersal event) goes into the parent offspring category # so composite is left to its default of 1 fs_dists <- c(2, 3, 3) axials(fs_dists, composite = 2) # two 'draws' (symmetric dispersal events) # go into the full sibling category so composite is set to 2
Add axial distributions. Useful to construct an overall distribution that results from multiple 'draws' from smaller distributions. E.g. The pathway between first cousins which can be found by adding each of the component distributions of their respective lifespans along with the relevant offspring producing (e.g. oviposition) of the parent.
axials_add(axvals)
axials_add(axvals)
axvals |
numeric. vector of axial distribution values from different kernels that are to be added. |
numeric
Returns the axial value that results from adding the input axial values under an additive variance framework.
Other axial_helpers:
axials()
,
axials_decompose()
,
axials_subtract()
,
axpermute()
,
axpermute_subtract()
fullsibs_ax <- 5 parent_offspring_ax <- 25 cousin_ax <- axials_add(c(fullsibs_ax, parent_offspring_ax))
fullsibs_ax <- 5 parent_offspring_ax <- 25 cousin_ax <- axials_add(c(fullsibs_ax, parent_offspring_ax))
combines axial distributions to produce a mixed distribution. This is useful in settings where you have two separate distributions (e.g. FS & HS) with their own axial values, but you want to average them appropriately so that they can be compared to e.g. a mixed distribution of full & half cousins which cannot be distinguished via kinship determination methods and thus are best treated as an even mixture of the two categories. Different to adding dispersal events.
axials_combine(axvals)
axials_combine(axvals)
axvals |
numeric. vector of axial distribution values from different kernels that are to be combined |
numeric
Returns the axial value that results from combining the input axial values under an additive variance framework.
fullax <- axials(c(2, 4, 5), composite = 2) halfax <- axials(c(6, 5, 7), composite = 2) sibax <- axials_combine(c(fullax, halfax))
fullax <- axials(c(2, 4, 5), composite = 2) halfax <- axials(c(6, 5, 7), composite = 2) sibax <- axials_combine(c(fullax, halfax))
Decomposes an axial distribution into simple components. Note that this should only be used in the simplest situations. It assumes all composite dispersal events are of identical magnitude and have happened equivalently to both branches of a 'symmetric' pedigree leading to the final kin dyad. (it can be used to derive e.g.full-sibling dispersal parameters from the distribution of full-siblings, or equivalent for first cousins, but not to divide the 'avuncular' kernel into its component parts (uncle/aunt & niece/nephew have different dispersal paths from their common ancestor)).
axials_decompose(ax, n_composites = 2)
axials_decompose(ax, n_composites = 2)
ax |
numeric. The axial value to be decomposed. |
n_composites |
numeric. The number of separate 'draws' (dispersal events) from the kernel required to produce the final positions of the measured individuals. For example, the displacement of a child from parent at the same life stage would involve 1 draw and thus be composite = 1. Two full siblings would be two draws (composite = 2) from the FS kernel. Non-symmetric relationships (e.g. AV, 1C) should not be decomposed using this method, nor should any assumptions be made about different kernels (e.g. the 1C relationship would appropriately be given the value 2, but not 4) |
Returns the (numeric) axial distribution value of the underlying dispersal kernel from which the composite kernel was (or could be) created.
Other axial_helpers:
axials()
,
axials_add()
,
axials_subtract()
,
axpermute()
,
axpermute_subtract()
fs_vect <- c(10, 11, 12) fs_axial_raw <- axials(fs_vect, composite = 1) # composite hasn't corrected for two dispersal events # inherent to this kin category! fs_axial_final <- axials_decompose(fs_axial_raw, n_composites = 2)
fs_vect <- c(10, 11, 12) fs_axial_raw <- axials(fs_vect, composite = 1) # composite hasn't corrected for two dispersal events # inherent to this kin category! fs_axial_final <- axials_decompose(fs_axial_raw, n_composites = 2)
This function takes (at least) two vectors of kinship dispersal distances from defined kinship categories, and returns a resulting calculation of the parent-offspring
(intergenerational) kinship dispersal kernel. Dispersal distances can be inputted as numeric vectors, or alternatively as objects of classes KinPairData
or KinPairSimulation
.
axials_standard( avect, bvect, acat = NULL, bcat = NULL, amix = FALSE, bmix = FALSE, amixcat = NULL, bmixcat = NULL, acomp = FALSE, bcomp = FALSE, acompvect = NULL, bcompvect = NULL, acompcat = NULL, bcompcat = NULL, acycle = NULL, bcycle = NULL, amixcycle = NULL, bmixcycle = NULL, acompcycle = NULL, bcompcycle = NULL, override = FALSE )
axials_standard( avect, bvect, acat = NULL, bcat = NULL, amix = FALSE, bmix = FALSE, amixcat = NULL, bmixcat = NULL, acomp = FALSE, bcomp = FALSE, acompvect = NULL, bcompvect = NULL, acompcat = NULL, bcompcat = NULL, acycle = NULL, bcycle = NULL, amixcycle = NULL, bmixcycle = NULL, acompcycle = NULL, bcompcycle = NULL, override = FALSE )
avect |
vector a of kin dispersal distances for the less closely related kinship category OR object of class |
bvect |
vector b of kin dispersal distances for the more closely related kinship category OR object of class |
acat |
kinship category of kin dispersal vector avect. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
bcat |
kinship category of kin dispersal vector bvect. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
amix |
logical describing whether vector a is a mixture of two kinship categories. Used with amixcat. Default FALSE. |
bmix |
logical describing whether vector b is a mixture of two kinship categories. Used with bmixcat. Default FALSE. |
amixcat |
mixture kinship category of vector a. Must be set if amix == TRUE. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
bmixcat |
mixture kinship category of vector b. Must be set if bmix == TRUE. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
acomp |
logical denoting whether vector a should be composited with an additional kinship category vector. Used with acompvect and acompcat. Default FALSE. |
bcomp |
logical denoting whether vector b should be composited with an additional kinship category vector. Used with bcompvect and bcompcat. Default FALSE. |
acompvect |
vector acomp of kin dispersal distances for compositing with vector a OR object of class KinPairData. Must be set if acomp == TRUE. |
bcompvect |
vector bcomp of kin dispersal distances for compositing with vector b OR object of class KinPairData. Must be set if bcomp == TRUE. |
acompcat |
kinship category of kin dispersal vector acompvect. Must be set if acomp == TRUE. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
bcompcat |
kinship category of kin dispersal vector bcompvect. Must be set if bcomp == TRUE. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
acycle |
breeding cycle number of kin dispersal vector avect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
bcycle |
breeding cycle number of kin dispersal vector bvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan |
amixcycle |
breeding cycle number of kin dispersal vector amixvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan |
bmixcycle |
breeding cycle number of kin dispersal vector bmixvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
acompcycle |
breeding cycle number of kin dispersal vector acompvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
bcompcycle |
breeding cycle number of kin dispersal vector bcompvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
override |
whether or not to override the default -1 cycle compatibility check (default FALSE) override in situations where you are confident e.g. a c(-1, -1) cycle FS or HS category is truly zeroed (& thus separated from later stages by a complete lifespan) |
This (with its paired function axpermute_standard
) are the core functions implemented in the kindisperse
package. They enable the decomposition of the
pedigree & dispersal information contained in the sampled distributions of close kin dyads (full siblings, first cousins, etc.) & its leveraging within an additive dispersal
framework to estimate the key intergenerational (parent-offspring) dispersal parameter of a population. Four key ideas underpin the approach in this function: (a) tracing
dispersal pedigrees to determine the number of complete intergenerational (breeding-cycle-spanning) dispersal events separating the sampled close-kin dyads; (b) using kin categories
that share the same overarching kinship 'phase' to control for residual 'phased' (non-intergenerational) disperal events that occur at the pedigree branch point (e.g. ovipositional
dispersal for full sibling mosquitoes), and (c) using synced or equivalent sampling points to eliminate non-intergenerational dispersal at the branch-tips of the pedigrees, then
finally (d) decomposing the 'pure' pedigree-associated (intergenerational) dispersal into an estimae of the single-generation intergenerational dispersal parameter.
At its most basic, this function requires information about two dispersal vectors, a & b - both of a phased kinship category, & vector a
having a more dispersed pedigree
than vector b
. In addition to this initial pair of dispersed kin categories, either one or another matched pair of kin categories can be added:
A mixture category. This redefines the vector it is paired with (either a or b) so that rather than being considered as a 'pure' pedigree variant, it is considered as mixed with a different kin category, often of a differing pedigree phase. If used, the other initial vector must also be paired with a related mixture category or composite vector.
A composite dispersal vector. This is defined exactly as the initial dispersal vectors. After calculation, the axial value found is composited with that of the matched initial vector, and its kinship category redefined as a mixture category as above. If used, the other initial vector must also be paired with a related mixture category or composite vector. These can be paired so that a mixture category (e.g. first & half-first cousins where these could not be separated with available genetic data) can be counterbalanced with the composition of full sibling & half-sibling dyads, which (assuming equal mixture) approximately controls for the phasing of the mixed kin categories, enabling an estimate of intergenerational dispersal without exact knowledge of the composition of the cousins distribution.
Each vector or KinPairData
/ KinPairSimulation
object is paired with several other parameters: (1) a logical (e.g. amix
delineating whether the category is being
used in the calculation, (2) a category parameter (.e.g acat
) defining what kin relationship is being measured, (3) an optional breeding cycle number (e.g. acycle
)
showing the number of breeding cycles each member of the kin pair has passed through before being sampled (the cycle vector c(1, 0)
corresponds to an adult & a juvenile
being sampled at the same point in the breeding cycle; c(1, 1)
represents two adults (i.e. after their first breeding), etc.) . If a KinPairData
or
KinPairSimulation
object is inputted, all paired parameters that are not explicitly set will default to those contained in the objects (using KinPair objects
is the ideal way to deploy this function).
For further information on this function, package & the dispersal estimation method it represents, see the paper by Jasper et al. - "A genomic approach to inferring kinship reveals limited intergenerational dispersal in the yellow fever mosquito", doi:10.1111/1755-0998.13043.
Returns a numeric estimate of PO (intergenerational) dispersal kernel axial distribution.
Other axstandard:
axpermute_standard()
cous <- rexp(100, 1 / 100) fullsibs <- rexp(50, 1 / 50) axials_standard(cous, fullsibs, acat = "1C", bcat = "FS")
cous <- rexp(100, 1 / 100) fullsibs <- rexp(50, 1 / 50) axials_standard(cous, fullsibs, acat = "1C", bcat = "FS")
Subtract axial distributions, finding the difference (under an additive variance framework). This is most useful when one distribution subsumes another and includes a unique dispersal event that needs to be extracted. For example, the FS category is subsumed by the 1C category, which can be written 'FS + PO'. In this circumstance, subtracting FS from 1C will yield an estimate of the PO kernel (the basic intergenerational dispersal kernel)
axials_subtract(abig, asmall)
axials_subtract(abig, asmall)
abig |
numeric. The axial dispersal distance of the larger (subsuming) distribution (e.g. 1C). |
asmall |
numeric. The axial dispersal distance of the smaller (subsumed) distribution (e.g. FS). |
numeric
Returns an estimate of the axial dispersal distance of those dispersal elements that are unique to the larger dispersal distribution (e.g. PO).
Other axial_helpers:
axials()
,
axials_add()
,
axials_decompose()
,
axpermute()
,
axpermute_subtract()
axials_subtract(100, 70)
axials_subtract(100, 70)
This function performs an estimation of axial dispersal for a numeric vector of distances between close kin dyads with confidence
intervals. The axial dispersal distance returned is interpretable as the standard deviation of one dimension of a
symmetric bivariate random distribution centred on zero. Confidence intervals are assigned via bootstrapping, or optionally the
vector of all bootstrapped results can be outputted by setting output
to 'vect'
, enabling its passing to other
functions or external statistical analysis.
axpermute(vals, nreps = 1000, nsamp = "std", composite = 1, output = "confs")
axpermute(vals, nreps = 1000, nsamp = "std", composite = 1, output = "confs")
vals |
numeric. Vector of distances between close kin OR object of class KinPairData. |
nreps |
numeric. Number of permutations to run for confidence intervals (default 1000) |
nsamp |
numeric. Number of kin pairs to subsample for each permutation. Either "std" or an integer. If "std" will be computed as equal to the sample size. (default "std") |
composite |
numeric. The number of separate 'draws' (dispersal events) from the kernel required to produce the final positions of the measured individuals. For example, the displacement of a child from parent at the same lifestage would involve 1 draw and thus be composite = 1. Two full siblings would be two draws (composite = 2) from the FS kernel. Non-symmetric relationships (e.g. AV, 1C) should not be decomposed using this method, nor should any assumptions be made about different kernels (e.g. the 1C relationship would appropriately be given the value 2, but not 4) |
output |
character. Denotes what kind of output to return. If 'confs', a vector of 95% confidence intervals. if 'vect', a vector of all permuted axial value results |
If ouput = 'confs', returns a numeric vector
of 95% confidence intervals and mean axial value.
if output = 'vect', returns a numeric vector
of all permuted axial value results
Other axial_helpers:
axials()
,
axials_add()
,
axials_decompose()
,
axials_subtract()
,
axpermute_subtract()
po_dists <- rexp(100, 1 / 50) axpermute(po_dists, composite = 1)
po_dists <- rexp(100, 1 / 50) axpermute(po_dists, composite = 1)
This function takes (at least) two vectors of kinship dispersal distances from defined kinship categories, and returns a resulting calculation of the parent-offspring
(intergenerational) kinship dispersal kernel with bootstrapped confidence intervals. Dispersal distances can be inputted as numeric vectors, or alternatively as objects of
classes KinPairData
or KinPairSimulation
.
axpermute_standard( avect = NULL, bvect = NULL, acat = NULL, bcat = NULL, nreps = 1000, nsamp = "std", amix = FALSE, bmix = FALSE, amixcat = NULL, bmixcat = NULL, acomp = FALSE, bcomp = FALSE, acompvect = NULL, bcompvect = NULL, acompcat = NULL, bcompcat = NULL, acycle = NULL, bcycle = NULL, amixcycle = NULL, bmixcycle = NULL, acompcycle = NULL, bcompcycle = NULL, output = "confs", override = FALSE )
axpermute_standard( avect = NULL, bvect = NULL, acat = NULL, bcat = NULL, nreps = 1000, nsamp = "std", amix = FALSE, bmix = FALSE, amixcat = NULL, bmixcat = NULL, acomp = FALSE, bcomp = FALSE, acompvect = NULL, bcompvect = NULL, acompcat = NULL, bcompcat = NULL, acycle = NULL, bcycle = NULL, amixcycle = NULL, bmixcycle = NULL, acompcycle = NULL, bcompcycle = NULL, output = "confs", override = FALSE )
avect |
vector a of kin dispersal distances for the less closely related kinship category OR object of class KinPairData. |
bvect |
vector b of kin dispersal distances for the more closely related kinship category OR object of class KinPairData. |
acat |
kinship category of kin dispersal vector avect. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
bcat |
kinship category of kin dispersal vector bvect. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
nreps |
number of permutations to run for confidence intervals (default 1000) |
nsamp |
number of kin pairs to subsample for each permutation. Either "std" or an integer. If "std" will be computed as equal to the sample size. (default "std") |
amix |
logical describing whether vector a is a mixture of two kinship categories. Used with amixcat. Default FALSE. |
bmix |
logical describing whether vector b is a mixture of two kinship categories. Used with bmixcat. Default FALSE. |
amixcat |
mixture kinship category of vector a. Must be set if amix == TRUE. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
bmixcat |
mixture kinship category of vector b. Must be set if bmix == TRUE. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
acomp |
logical denoting whether vector a should be composited with an additional kinship category vector. Used with acompvect and acompcat. Default FALSE. |
bcomp |
logical denoting whether vector b should be composited with an additional kinship category vector. Used with bcompvect and bcompcat. Default FALSE. |
acompvect |
vector acomp of kin dispersal distances for compositing with vector a OR object of class KinPairData. Must be set if acomp == TRUE. |
bcompvect |
vector bcomp of kin dispersal distances for compositing with vector b OR object of class KinPairData. Must be set if bcomp == TRUE. |
acompcat |
kinship category of kin dispersal vector acompvect. Must be set if acomp == TRUE. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
bcompcat |
kinship category of kin dispersal vector bcompvect. Must be set if bcomp == TRUE. Must be one of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV", "HGAV", "H1C", "H1C1", "H2C" |
acycle |
breeding cycle number of kin dispersal vector avect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
bcycle |
breeding cycle number of kin dispersal vector bvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
amixcycle |
breeding cycle number of kin dispersal vector amixvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
bmixcycle |
breeding cycle number of kin dispersal vector bmixvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
acompcycle |
breeding cycle number of kin dispersal vector acompvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
bcompcycle |
breeding cycle number of kin dispersal vector bcompvect. Must be a nonnegative integer. (0, 1, 2, ...). Represents the number of complete breeding cycles the sampled individual has undergone before the checkpoint, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). Only use in spp. where there is likely to be a reasonable equivalence between breeding stages across a lifespan. |
output |
string denoting what kind of output to return. If 'confs', a vector of 95% confidence intervals. if 'vect', a vector of all permutated axial value results |
override |
whether or not to override the default -1 cycle compatibility check (default FALSE) override in situations where you are confident e.g. a c(-1, -1) cycle FS or HS category is truly zeroed (& thus separated from later stages by a complete lifespan) |
This (with its paired function axials_standard
) are the core functions implemented in the kindisperse
package. They enable the decomposition of the
pedigree & dispersal information contained in the sampled distributions of close kin dyads (full siblings, first cousins, etc.) & its leveraging within an additive dispersal
framework to estimate the key intergenerational (parent-offspring) dispersal parameter of a population. Four key ideas underpin the approach in this function: (a) tracing
dispersal pedigrees to determine the number of complete intergenerational (breeding-cycle-spanning) dispersal events separating the sampled close-kin dyads; (b) using kin categories
that share the same overarching kinship 'phase' to control for residual 'phased' (non-intergenerational) disperal events that occur at the pedigree branch point (e.g. ovipositional
dispersal for full sibling mosquitoes), and (c) using synced or equivalent sampling points to eliminate non-intergenerational dispersal at the branch-tips of the pedigrees, then
finally (d) decomposing the 'pure' pedigree-associated (intergenerational) dispersal into an estimae of the single-generation intergenerational dispersal parameter.
At its most basic, this function requires information about two dispersal vectors, a & b - both of a phased kinship category, & vector a
having a more dispersed pedigree
than vector b
. In addition to this initial pair of dispersed kin categories, either one or another matched pair of kin categories can be added:
A mixture category. This redefines the vector it is paired with (either a or b) so that rather than being considered as a 'pure' pedigree variant, it is considered as mixed with a different kin category, often of a differing pedigree phase. If used, the other initial vector must also be paired with a related mixture category or composite vector.
A composite dispersal vector. This is defined exactly as the initial dispersal vectors. After calculation, the axial value found is composited with that of the matched initial vector, and its kinship category redefined as a mixture category as above. If used, the other initial vector must also be paired with a related mixture category or composite vector. These can be paired so that a mixture category (e.g. first & half-first cousins where these could not be separated with available genetic data) can be counterbalanced with the composition of full sibling & half-sibling dyads, which (assuming equal mixture) approximately controls for the phasing of the mixed kin categories, enabling an estimate of intergenerational dispersal without exact knowledge of the composition of the cousins distribution.
Each vector or KinPairData
/ KinPairSimulation
object is paired with several other parameters: (1) a logical (e.g. amix
delineating whether the category is being
used in the calculation, (2) a category parameter (.e.g acat
) defining what kin relationship is being measured, (3) an optional breeding cycle number (e.g. acycle
)
showing the number of breeding cycles each member of the kin pair has passed through before being sampled (the cycle vector c(1, 0)
corresponds to an adult & a juvenile
being sampled at the same point in the breeding cycle; c(1, 1)
represents two adults (i.e. after their first breeding), etc.) . If a KinPairData
or
KinPairSimulation
object is inputted, all paired parameters that are not explicitly set will default to those contained in the objects (using KinPair objects
is the ideal way to deploy this function).
Confidence intervals are assigned via bootstrapping, or optionally the
vector of all bootstrapped results can be outputted by setting output
to 'vect'
, enabling its passing to other
functions or external statistical analysis.
For further information on this function, package & the dispersal estimation method it represents, see the paper by Jasper et al. - "A genomic approach to inferring kinship reveals limited intergenerational dispersal in the yellow fever mosquito", doi:10.1111/1755-0998.13043.
If output = 'confs' returns vector of 95% confidence intervals (with mean). If output = 'vect' returns vector of individual axial estimates from each permutation
Other axstandard:
axials_standard()
cous <- rexp(100, 1 / 100) fullsibs <- rexp(50, 1 / 50) axpermute_standard(cous, fullsibs, acat = "1C", bcat = "FS")
cous <- rexp(100, 1 / 100) fullsibs <- rexp(50, 1 / 50) axpermute_standard(cous, fullsibs, acat = "1C", bcat = "FS")
Finds the difference between two different empirical axial distributions with confidence intervals.
This is most useful when one distribution subsumes another and includes a unique dispersal event that needs to be extracted.
For example, the FS category is subsumed by the 1C category, which can be written 'FS + PO'.
In this circumstance, subtracting FS from 1C will yield an estimate of the PO kernel (the basic intergenerational dispersal kernel).
Confidence intervals are assigned via bootstrapping, or optionally the
vector of all bootstrapped results can be outputted by setting output
to 'vect'
, enabling its passing to other
functions or external statistical analysis.
axpermute_subtract( bigvals, smallvals, nreps = 1000, nsamp = "std", composite = 2, output = "confs" )
axpermute_subtract( bigvals, smallvals, nreps = 1000, nsamp = "std", composite = 2, output = "confs" )
bigvals |
numeric. Vector of distance distributions of the larger (subsuming) distribution (e.g. 1C) OR object of class KinPairData. |
smallvals |
numeric. Vector of distance distributions of the smaller (subsumed) distribution (e.g. FS) OR object of class KinPairData. |
nreps |
numeric. Number of permutations to perform when generating confidence intervals. |
nsamp |
numeric. number of kin pairs to subsample for each permutation. Either "std" or an integer. If "std" will be computed as equal to the sample size. (default "std") |
composite |
numeric. The number of separate 'draws' (dispersal events) from the kernel required to produce the final positions of the measured individuals. For example, the displacement of a child from parent at the same lifestage would involve 1 draw and thus be composite = 1. Two full siblings would be two draws (composite = 2) from the FS kernel. Non-symmetric relationships (e.g. AV, 1C) should not be decomposed using this method, nor should any assumptions be made about different kernels (e.g. the 1C relationship would appropriately be given the value 2, but not 4) |
output |
character. What kind of output to return. Either 'confs' (default -> confidence intervals) or 'vect -> vector of axial distances |
If output = 'confs' returns numeric vector
of 95% confidence intervals and mean axial value.
If output = 'vect' returns numeric vector
of individual axial estimates from each permutation
Other axial_helpers:
axials()
,
axials_add()
,
axials_decompose()
,
axials_subtract()
,
axpermute()
firstcous <- rexp(100, 1 / 80) fullsibs <- rexp(100, 1 / 50) axpermute_subtract(firstcous, fullsibs)
firstcous <- rexp(100, 1 / 80) fullsibs <- rexp(100, 1 / 50) axpermute_subtract(firstcous, fullsibs)
DispersalModel
object.Access breeding cycle at sampling of DispersalModel
object.
breeding_cycle(x) ## S4 method for signature 'DispersalModel' breeding_cycle(x) ## S4 method for signature 'KinPairData' breeding_cycle(x)
breeding_cycle(x) ## S4 method for signature 'DispersalModel' breeding_cycle(x) ## S4 method for signature 'KinPairData' breeding_cycle(x)
x |
object of class |
DispersalModel |
object of class |
KinPairData |
object of class |
integer(s) >= -1
Breeding cycle numbers of modeled dispersed kin. Represents the number of complete
breeding cycles each indivdiual has undergone before the sampling point, where the time between birth and first
reproduction is coded as 0
, that between first and second reproduction 1
, etc.
breeding_cycle(DispersalModel)
:
breeding_cycle(KinPairData)
:
DispersalModel
objectAccess life stage at which breeding occurs of DispersalModel
object
breeding_stage(x) ## S4 method for signature 'DispersalModel' breeding_stage(x)
breeding_stage(x) ## S4 method for signature 'DispersalModel' breeding_stage(x)
x |
object of class |
DispersalModel |
object of class |
character
life stage at which breeding occurs for modeled dispersed kin.
breeding_stage(DispersalModel)
:
Checks if vector of kinship categories contains all valid entries
check_valid_kinship(vect)
check_valid_kinship(vect)
vect |
vector of kinship categories |
TRUE if valid. Error otherwise.
Checks if vector of lifestages contains all valid entries
check_valid_lifestage(vect)
check_valid_lifestage(vect)
vect |
vector of lifestages |
TRUE if valid. Error otherwise
.csv
and converts to KinPairData
objectThis function is part of suite of functions handling file import/export for kinship dispersal objects.
.csv
& .tsv
reading functions at minimum require the .delim file to contain a column titled 'distance' containing distances
between kin pairs. It can optionally contain a column of kinship values 'kinship' as well as a column of lifestage values 'lifestage'.
If the file contains more than one value in the kinship or lifestage columns (e.g. bot 'FS' and 'HS') - the corresponding function
parameter must be set to pick a corresponding subset of dispersed pairs. where parameters are set in the absence of file columns,
these values are assigned to the returned KinPairData
object.
csv_to_kinpair(file, kinship = NULL, lifestage = NULL, ...)
csv_to_kinpair(file, kinship = NULL, lifestage = NULL, ...)
file |
The file path to read from |
kinship |
character. kin category to assign or extract from data. one of PO, FS, HS, AV, GG, HAV, GGG, 1C, 1C1, 2C, GAV, HGAV, H1C , H1C1 or H2C |
lifestage |
character. lifestage to assign or extract from data. one of 'unknown', 'immature' or 'ovipositional'. |
... |
additional arguments to pass to |
returns an object of class KinPairData
Other import_functions:
df_to_kinpair()
,
read_kindata()
,
tsv_to_kinpair()
,
vector_to_kinpair()
KinPairData
classThis function at minimum requires the dataframe to contain a column titled 'distance' containing distances
between kin pairs. It can optionally contain a column of kinship values 'kinship' as well as a column of lifestage values 'lifestage'.
If the file contains more than one value in the kinship or lifestage columns (e.g. bot 'FS' and 'HS') - the corresponding function
parameter must be set to pick a corresponding subset of dispersed pairs. where parameters are set in the absence of file columns,
these values are assigned to the returned KinPairData
object.
df_to_kinpair(data, kinship = NULL, lifestage = NULL, lifecheck = TRUE)
df_to_kinpair(data, kinship = NULL, lifestage = NULL, lifecheck = TRUE)
data |
data.frame or tibble of kin distances - can contain $distance (kin distances), $kinship (kin cats) & $lifestage columns |
kinship |
character. kin category to assign or extract from data. one of PO, FS, HS, AV, GG, HAV, GGG, 1C, 1C1, 2C, GAV, HGAV, H1C , H1C1 or H2C |
lifestage |
character. lifestage to assign or extract from data. one of 'unknown', 'immature' or 'ovipositional'. |
lifecheck |
logical. If TRUE (default) tests if lifestage is valid, if FALSE, ignores this test. Set to FALSE when using custom lifestages. |
returns valid KinPairData
object
Other import_functions:
csv_to_kinpair()
,
read_kindata()
,
tsv_to_kinpair()
,
vector_to_kinpair()
mydata <- tibble::tibble( distance = 1:10, lifestage = "immature", kinship = c("FS", "FS", "FS", "FS", "FS", "FS", "HS", "HS", "HS", "HS") ) df_to_kinpair(mydata, kinship = "FS")
mydata <- tibble::tibble( distance = 1:10, lifestage = "immature", kinship = c("FS", "FS", "FS", "FS", "FS", "FS", "HS", "HS", "HS", "HS") ) df_to_kinpair(mydata, kinship = "FS")
The function creates an object of class DispersalModel
carrying organism-specific information about dispersal stages (with axial
sigmas), FS & HS branch points, and the dispersal stage at which sampling occurs.It is used with the
simulate_kindist_custom
function to enable the simulation of uniquely defined breeding & dispersal cycles.
dispersal_model( ..., .FS = 0, .HS = .FS, .sampling_stage = 0, .cycle = 0, .breeding_stage = .HS, .visible_stage = .FS )
dispersal_model( ..., .FS = 0, .HS = .FS, .sampling_stage = 0, .cycle = 0, .breeding_stage = .HS, .visible_stage = .FS )
... |
name, value (numeric) pairs pairing custom lifestages with their corresponding axial dispersal values. MUST be in chronological order across the entire breeding cycle. |
.FS |
(character) - breeding cycle stage at which first substantial FS-phased dispersal occurs. Must correspond to a previously described cycle stage name. Typically reflects the first dispersal of female gametes from the mother at (variously) egg-laying, birth, weaning stages (species-dependent). Use care in adapting to situations where multiple breeding and/or dispersal routes commonly lead to the FS phase |
.HS |
(character) - breeding cycle stage at which first substantial HS-phased dispersal occurs. Must correspond to a previously described cycle stage name. Typically reflects the movement of male gametes at e.g. the breeding stage (use care in adapting to situations where multiple dispersal routes commonly lead to the HS phase) |
.sampling_stage |
(character) - stage in the breeding cycle at which samples are to be collected for kin identification. Must correspond to a previously described cycle stage name. (so collection of eggs corresponds to an egg-laying stage, as juveniles to a juvenile stage, etc.) |
.cycle |
(integer >= -1 or vector of two such integers) breeding cycle numbers of dispersed kin to be modeled. Represents
the number of complete breeding cycles each simulated individual has undergone before the sampling point, where the time between
first dispersal and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). If .cycle
is specially set to '-1' this constitutes the sampling of an individual before it has differentiated (via dispersal) from the parent. Only use in spp.
where there is likely to be a reasonable equivalence between breeding stages across a lifespan. As the rest of the model is compatible
with a variety of cycle points, this parameter will often be overridden by the 'cycle' parameter in the |
.breeding_stage |
(character) - stage in the cycle at which breeding occurs. Must correspond to a previously described cycle stage name. By default, equated with the .HS stage. This stage corresponds to the generation of next-generation individuals; the .FS & .HS stages correspond to their separation. Needed for situations where individuals are sampled before they separate from the parent. Modify if the modeled .HS gamete dispersal event does not correspond to the initial breeding event. |
.visible_stage |
(character) - stage in the cycle at the beginning of which individuals are visible to the study for
sampling rather than their parents (i.e. the beginning point of |
The original simulation functions in this package (simulate_kindist_simple()
& simulate_kindist_composite
) were
designed for an organism with a specific (& relatively simple) breeding & dispersal cycle. 'simple' corresponded to a single
dispersal event across a lifespan, equivalency of all dispersal phases (FS, HS, PO) and no lifetime overlaps. 'composite'
corresponded to many insect dispersal situations, where breeding & oviposition are the key 'phase-defining' events (i.e.,
they lead to the initial gamete dispersal of half siblings & full siblings from each other), where field sampling typically
occurs via ovitraps
More general dispersal scenarios (e.g in mammals) require the ability to uniquely specify a variety of distinct breeding
ecologies & sampling schemes: the DispersalModel
class paired with the simulate_kindist_custom
function achieves this by defining a breeding cycle with an arbitrary number of dispersal phases (the dispersal_vector
slot, accessed by the dispersal_vector
method).
The breeding structure of a species may also impact at which stage
FS and HS phase branches occur. In Ae. aegypti, males mate with multiple females in a (single) breeding season, and a female
typically carried the egg of only one male. In this context the FS (full-sibling) phase would be set to correspond to the female's
oviposition dispersal, while the HS (half-sibling) phase would be set to correspond to the male's breeding dispersal (as its gametes
will then be dispersed by multiple females across their gravid & ovipositional phases). However, in e.g. some species of the marsupial
Antechinus, the FS branch point would be more appropriately associated with juveniles at the time that they leave the mother's
pouch. The .FS
and .HS
parameters enable the assignment of these phase branches to any
defined life phase. Similarly, the .sampling_stage
parameter allow the sampling point to be set to correspond to any
phase of the defined breeding cycle (this is later accessed with the sampling_stage
method).
The final parameter stored in this object is the breeding cycle number .cycle
, accessed later by the breeding_cycle
method.
This parameter enables the treatment of species that undergo multiple breeding cycles in one lifetime. This is defined as a length two
vector describing the number of breeding cycles undergone by the final descendant of branch 1 and branch 2 of the dispersal pedigree before
their sampling. (where branch one is the 'senior' and branch two the 'junior' member of the pedigree) (so uncle is branch one, nephew branch
two, grandmother branch one, granddaughter branch two, etc.). For each member of the resulting kin pair, the cycle number represents the
number of complete breeding cycles each individual has undergone before the sampling point, where the time between birth and first
reproduction is coded as '0', that between first and second reproduction '1', etc. This enables an application of the simulation
functions defined here to deal with populations with some amount of overlap between generations.
Note that this 'breeding cycle' approach is only applicable in situations where there is an approximate equivalence between the dispersal which
occurs in the first 'juvenile' breeding cycle and that which occurs between later breeding cycles. This parameter is implemented here, but it
will often be more productive to implement it instead as a parameter of the simulate_kindist_custom
function (the cycle parameter
there if set overrides whatever was defined within this object)
Returns an object of class DispersalModel
containing custom lifestages and dispersal, phase & sampling parameters that
can be passed to simulation functions.
antechinus_model <- dispersal_model(pouch = 25, nest = 25, free_living = 250, breeding = 40, gestation = 25, .FS = "nest", .HS = "breeding", .sampling_stage = "nest") antechinus_model
antechinus_model <- dispersal_model(pouch = 25, nest = 25, free_living = 250, breeding = 40, gestation = 25, .FS = "nest", .HS = "breeding", .sampling_stage = "nest") antechinus_model
DispersalModel
object.Access dispersal vector of DispersalModel
object.
dispersal_vector(x) ## S4 method for signature 'DispersalModel' dispersal_vector(x)
dispersal_vector(x) ## S4 method for signature 'DispersalModel' dispersal_vector(x)
x |
object of class |
DispersalModel |
object of class |
numeric vector
named vector of custom lifestages & associated dispersal sigmas.
dispersal_vector(DispersalModel)
:
The class DispersalModel
is an S4 Class supplying organism-specific information about dispersal stages (with axial
sigmas), FS & HS branch points, and the dispersal stage at which sampling occurs.It is used with the
simulate_kindist_custom
function to enable the simulation of uniquely defined breeding & dispersal cycles.
## S4 method for signature 'DispersalModel' show(object) ## S4 method for signature 'DispersalModel' initialize( .Object, stages = NULL, dispersal_vector = NULL, fs = NULL, hs = NULL, sampling_stage = NULL, cycle = NULL, breeding_stage = NULL, visible_stage = NULL )
## S4 method for signature 'DispersalModel' show(object) ## S4 method for signature 'DispersalModel' initialize( .Object, stages = NULL, dispersal_vector = NULL, fs = NULL, hs = NULL, sampling_stage = NULL, cycle = NULL, breeding_stage = NULL, visible_stage = NULL )
object |
an object of class |
.Object |
object to be constructed into DispersalModel class |
stages |
character. Ordered vector of all dispersal stages across the breeding cycle of the modeled species |
dispersal_vector |
numeric. Named vector of custom breeding cycle stages and their corresponding axial dispersal values |
fs |
character. breeding cycle stage at which first substantial FS-phased dispersal occurs |
hs |
character. breeding cycle stage at which first substantial HS-phased dispersal occurs |
sampling_stage |
character. stage in the breeding cycle at which samples are to be collected for kin identification. |
cycle |
non-negative integer. Breeding cycle numbers of dispersed kin to be modeled. Represents the number of complete breeding cycles each simulated individual has undergone before the sampling point, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0) |
breeding_stage |
(character) - stage in the cycle at which breeding occurs. Must correspond to a previously described cycle stage name. By default, equated with the .HS stage. This stage corresponds to the generation of next-generation individuals; the .FS & .HS stages correspond to their separation. Needed for situations where individuals are sampled before they separate from the parent. Modify if the modeled .HS gamete dispersal event does not correspond to the initial breeding event. |
visible_stage |
(character) - stage in the cycle at the beginning of which individuals are visible to the study for
sampling rather than their parents (i.e. the beginning point of |
DispersalModel |
an object of class DispersalModel |
The original simulation functions in this package (simulate_kindist_simple()
& simulate_kindist_composite
) were
designed for an organism with a specific (& relatively simple) breeding & dispersal cycle. 'simple' corresponded to a single
dispersal event across a lifespan, equivalency of all dispersal phases (FS, HS, PO) and no lifetime overlaps. 'composite'
corresponded to many insect dispersal situations, where breeding & oviposition are the key 'phase-defining' events (i.e.,
they lead to the initial gamete dispersal of half siblings & full siblings from each other), where field sampling typically
occurs via ovitraps
More general dispersal scenarios (e.g in mammals) require the ability to uniquely specify a variety of distinct breeding
ecologies & sampling schemes: the DispersalModel
class paired with the simulate_kindist_custom
function achieves this by defining a breeding cycle with an arbitrary number of dispersal phases (the dispersal_vector
slot, accessed by the dispersal_vector
method).
The breeding structure of a species may also impact at which stage
FS and HS phase branches occur. In Ae. aegypti, males mate with multiple females in a (single) breeding season, and a female
typically carried the egg of only one male. In this context the FS (full-sibling) phase would be set to correspond to the female's
oviposition dispersal, while the HS (half-sibling) phase would be set to correspond to the male's breeding dispersal (as its gametes
will then be dispersed by multiple females across their gravid & ovipositional phases). However, in e.g. some species of the marsupial
Antechinus, the FS branch point would be more appropriately associated with juveniles at the time that they leave the mother's
pouch. The fs
and hs
slots & accessor functions enable the assignment of these phase branches to any
defined life phase. Similarly, the sampling_stage
slot & method allow the sampling point to be set to correspond to any
phase of the defined breeding cycle.
The next parameter stored in this object is the breeding cycle number cycle
, accessed by the breeding_cycle
method.
This parameter enables the treatment of species that undergo multiple breeding cycles in one lifetime. This is defined as a length two
vector describing the number of breeding cycles undergone by the final descendant of branch 1 and branch 2 of the dispersal pedigree before
their sampling (or after branching in the case of PO). (where branch one is the 'senior' and branch two the 'junior' member of the pedigree) (so uncle is branch one, nephew branch
two, grandmother branch one, granddaughter branch two, etc.). For each member of the resulting kin pair, the cycle number represents the
number of complete breeding cycles each individual has undergone before the sampling point, where the time between birth and first
reproduction is coded as '0', that between first and second reproduction '1', etc. This enables an application of the simulation
functions defined here to deal with populations with some amount of overlap between generations.
Note that this 'breeding cycle' approach is only applicable in situations where there is an approximate equivalence between the dispersal which
occurs in the first 'juvenile' breeding cycle and that which occurs between later breeding cycles. This parameter is implemented here, but it
will often be more productive to implement it instead as a parameter of the simulate_kindist_custom
function (the cycle parameter
there if set overrides whatever was defined within this object)
The final parameter stored in this object is the breeding stage, breeding_stage
. This describes the stage at which the
descendant individuals are generated (as opposed to fs
& hs
, which describe the point at which they are dispersed
from the parent)
returns object of class DispersalModel
No return value. Called for side effects
returns an object of class DispersalModel
show(DispersalModel)
: print method
initialize(DispersalModel)
: initialization method
dispersal_vector
numeric. Named vector of custom breeding cycle stages and their corresponding axial dispersal values
stages
character. Ordered vector of all dispersal stages across the breeding cycle of the modeled species
fs
character. breeding cycle stage at which first substantial FS-phased dispersal occurs
hs
character. breeding cycle stage at which first substantial HS-phased dispersal occurs
sampling_stage
character. stage in the breeding cycle at which samples are to be collected for kin identification.
cycle
non-negative integer. Breeding cycle numbers of dispersed kin to be modeled. Represents the number of complete breeding cycles each individual has undergone before the sampling point, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0)
breeding_stage
(character) - stage in the cycle at which breeding occurs. Must correspond to a previously described cycle stage name. By default, equated with the .HS stage. This stage corresponds to the generation of next-generation individuals; the .FS & .HS stages correspond to their separation. Needed for situations where individuals are sampled before they separate from the parent. Modify if the modeled .HS gamete dispersal event does not correspond to the initial breeding event.
visible_stage
(character) - stage in the cycle at the beginning of which individuals are visible to the study for
sampling rather than their parents (i.e. the beginning point of cycle 0
). By default, equated with the fs
stage. This parameter
determines how many dispersal stages individuals have gone through before they are sampled - if .sampling_stage
occurs just
after .visible_stage
, the sampled individuals will have dispersed through only a small amount of the breeding cycle. if
.sampling_stage
occurs just before .visible_stage
, the sampled individuals will have dispersed throughout most
of the breeding cycle before being sampled. If .cycle
is set to -1
, dispersal stages between breeding & visibility
can be accessed.
Other kdclasses:
KinPairData-class
,
KinPairSimulation-class
This function is part of a suite of functions handling the interface between the kindisperse app & R
package. Due to how shiny's interactive programming works, ordinary objects are not visible to the reactive functions
embedded in the app. The solution implemented here is to construct a custom environment, env_appdata
, that is
accessible within the app and outside of it.
This function prints a summary of all objects currently stored within the app interface environment, by name and class
display_appdata()
display_appdata()
No return value, called for side effects
Other app_ports:
mount_appdata()
,
reset_appdata()
,
reset_tempdata()
,
retrieve_appdata()
,
retrieve_tempdata()
,
retrieveall_appdata()
,
unmount_appdata()
mount_appdata(kin_pair_data(), "my_kindata") mount_appdata(simulate_kindist_simple(nsims = 10), "my_simdata") display_appdata()
mount_appdata(kin_pair_data(), "my_kindata") mount_appdata(simulate_kindist_simple(nsims = 10), "my_simdata") display_appdata()
distances
category of KinPairData
class objectsAccess or assign distances
category of KinPairData
class objects
distances(x) ## S4 method for signature 'KinPairData' distances(x)
distances(x) ## S4 method for signature 'KinPairData' distances(x)
x |
object of class KinPairData |
KinPairData |
object of class |
Returns a numeric vector of kin separation distances
distances(KinPairData)
:
Other kpdmethods:
kinship()
,
lifestage()
This function is used to manipulate the dimensions parameter in other package functions, which control site dimentions.
These geometries can be entered innto functions in a few ways: (a) a single numeric value, which will be interpreted as the length of the side of a square;
(b) a numeric vector of length two, which will be interpreted as the length & width of the sample site; (c) either of the above passed
to this function, which takes the rectangular site dimensions and alters their aspect ratio
(ratio of
length to width) while preserving the underlying area the study site covers.
elongate(dims, aspect = 1)
elongate(dims, aspect = 1)
dims |
Original rectangle dimensions - either single number (length of side of square) or length 2 numeric vector (lengths of sides x and y of rectangle) |
aspect |
Aspect ratio of side lengths x & y (i.e. x/y) in the new rectangle |
Returns a numeric vector containing the side lengths c(x, y) of a transformed rectangle with preserved area
elongate(10, 100) elongate(c(5, 125), 4)
elongate(10, 100) elongate(c(5, 125), 4)
filter
parameters of KinPairSimulation
objectsThese generics & methods work as an interface between KinPairSimulation
objects and the
sample_kindist
function. They either retrieve the value of pre-existing filter steps that have
been applied to the object (e.g. upper(x)
) or assign such a filtering parameter to the KinPairSimulation
object (e.g. sampledims(x) <- value
). In this case, the method passes the KinPairSimulation
object to the
sample_kindist()
function for subsampling or filtering, then updates the sampling parameter before returning the
modified object. Note that while the sample_kindist
function can take KinPairData
objects, the methods
described here are only applicable to objects of class KinPairSimulation
.
upper(x) upper(x) <- value lower(x) lower(x) <- value spacing(x) spacing(x) <- value samplenum(x) samplenum(x) <- value sampledims(x) sampledims(x) <- value ## S4 method for signature 'KinPairSimulation' upper(x) ## S4 method for signature 'KinPairSimulation' lower(x) ## S4 method for signature 'KinPairSimulation' spacing(x) ## S4 method for signature 'KinPairSimulation' samplenum(x) ## S4 method for signature 'KinPairSimulation' sampledims(x) ## S4 replacement method for signature 'KinPairSimulation' upper(x) <- value ## S4 replacement method for signature 'KinPairSimulation' lower(x) <- value ## S4 replacement method for signature 'KinPairSimulation' spacing(x) <- value ## S4 replacement method for signature 'KinPairSimulation' samplenum(x) <- value ## S4 replacement method for signature 'KinPairSimulation' sampledims(x) <- value
upper(x) upper(x) <- value lower(x) lower(x) <- value spacing(x) spacing(x) <- value samplenum(x) samplenum(x) <- value sampledims(x) sampledims(x) <- value ## S4 method for signature 'KinPairSimulation' upper(x) ## S4 method for signature 'KinPairSimulation' lower(x) ## S4 method for signature 'KinPairSimulation' spacing(x) ## S4 method for signature 'KinPairSimulation' samplenum(x) ## S4 method for signature 'KinPairSimulation' sampledims(x) ## S4 replacement method for signature 'KinPairSimulation' upper(x) <- value ## S4 replacement method for signature 'KinPairSimulation' lower(x) <- value ## S4 replacement method for signature 'KinPairSimulation' spacing(x) <- value ## S4 replacement method for signature 'KinPairSimulation' samplenum(x) <- value ## S4 replacement method for signature 'KinPairSimulation' sampledims(x) <- value
x |
object of class KinPairSimulation |
value |
value for parameter to be adjusted to |
KinPairSimulation |
object of class KinPairSimulation |
either the accessed numeric
filter parameter or a filtered KinPairSimulation
object
upper(KinPairSimulation)
:
lower(KinPairSimulation)
:
spacing(KinPairSimulation)
:
samplenum(KinPairSimulation)
:
sampledims(KinPairSimulation)
:
upper(KinPairSimulation) <- value
:
lower(KinPairSimulation) <- value
:
spacing(KinPairSimulation) <- value
:
samplenum(KinPairSimulation) <- value
:
sampledims(KinPairSimulation) <- value
:
Other kpsmethods:
access_sigmas
,
kernelshape()
,
kerneltype()
,
simtype()
KinPairSimulation
objectAccess filtertype of KinPairSimulation
object
filtertype(x) filtertype(x) <- value ## S4 method for signature 'KinPairSimulation' filtertype(x)
filtertype(x) filtertype(x) <- value ## S4 method for signature 'KinPairSimulation' filtertype(x)
x |
object of class |
value |
new value to assign |
KinPairSimulation |
object of class KinPairSimulation |
character
filter status of simulation
returns a modified object of the relevant class
character
filter status of KinPairSimulation
object
filtertype(KinPairSimulation)
:
DispersalModel
object.Access FS phase split point of DispersalModel
object.
fs(x) ## S4 method for signature 'DispersalModel' fs(x)
fs(x) ## S4 method for signature 'DispersalModel' fs(x)
x |
object of class |
DispersalModel |
object of class |
character
FS phase split
fs(DispersalModel)
:
KinPairSimulation
objectAccess dispersal model of KinPairSimulation
object
get_dispersal_model(x) ## S4 method for signature 'KinPairSimulation' get_dispersal_model(x)
get_dispersal_model(x) ## S4 method for signature 'KinPairSimulation' get_dispersal_model(x)
x |
object of class |
KinPairSimulation |
object of class |
returns an object of class DispersalModel
get_dispersal_model(KinPairSimulation)
:
DispersalModel
object.Access HS phase split point of DispersalModel
object.
hs(x) ## S4 method for signature 'DispersalModel' hs(x)
hs(x) ## S4 method for signature 'DispersalModel' hs(x)
x |
object of class |
DispersalModel |
object of class |
character
HS phase split
hs(DispersalModel)
:
DispersalModel
Check if object is of class DispersalModel
is.DispersalModel(x)
is.DispersalModel(x)
x |
object to be checked |
returns TRUE if of class DispersalModel
, FALSE if not
Check if object is of class KinPairData
is.KinPairData(x)
is.KinPairData(x)
x |
object to be checked |
Returns TRUE if of class KinPairData
, FALSE if not.
Check if object is of class KinPairSimulation
is.KinPairSimulation(x)
is.KinPairSimulation(x)
x |
object to be checked |
Returns TRUE if of class KinPairSimulation, FALSE if not
KinPairSimulation
objectAccess kernel type of KinPairSimulation
object
kernelshape(x) ## S4 method for signature 'KinPairSimulation' kernelshape(x)
kernelshape(x) ## S4 method for signature 'KinPairSimulation' kernelshape(x)
x |
object of class |
KinPairSimulation |
object of class KinPairSimulation |
character
the shape parameter used in kernel simulation (if kerneltype
is vgamma)
character
the shape parameter used in kernel simulation (if kerneltype
is vgamma)
kernelshape(KinPairSimulation)
:
Other kpsmethods:
access_sigmas
,
filter_methods
,
kerneltype()
,
simtype()
KinPairSimulation
objectAccess or assign kerneltype of KinPairSimulation
object
kerneltype(x) kerneltype(x) <- value ## S4 method for signature 'KinPairSimulation' kerneltype(x)
kerneltype(x) kerneltype(x) <- value ## S4 method for signature 'KinPairSimulation' kerneltype(x)
x |
object of class |
value |
new value to assign |
KinPairSimulation |
object of class KinPairSimulation |
character
the type of statistical kernel used to run the simulation (Gaussian, Laplace, vgamma)
returns a modified object of the relevant class with altered kerneltype parameter
character
the type of statistical kernel used to run the simulation (Gaussian, Laplace, vgamma)
kerneltype(KinPairSimulation)
:
Other kpsmethods:
access_sigmas
,
filter_methods
,
kernelshape()
,
simtype()
Make new KinPairData object
kin_pair_data(data = NULL, kinship = NULL, lifestage = NULL, cycle = NULL)
kin_pair_data(data = NULL, kinship = NULL, lifestage = NULL, cycle = NULL)
data |
tlb_df. Tibble of kinpair distances |
kinship |
character. - one of PO, FS, HS, AV, HAV, GG, 1C, H1C, GAV, HGAV, 1C1, H1C1, GGG, 2C, H2C & UN. |
lifestage |
character. - one of 'unknown', 'immature' or 'ovipositional', or alternatively a custom
stage that corresponds to a dispersal stage contained in a |
cycle |
non-negative integer of length one or two (here, 1 is equivalent to c(1, 1)). Represents the number of complete breeding cycles each individual has undergone before the sampling point, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). If the first individual was sampled as a juvenile & the second as an adult of equivalent stage, the vector c(0, 1) would be used. In most situations, the default will be appropriate |
returns an object of class KinPairData
kin_pair_data()
kin_pair_data()
KinPairSimulation
kin_pair_simulation( data = NULL, kinship = NULL, lifestage = NULL, simtype = NULL, kerneltype = NULL, posigma = NULL, initsigma = NULL, breedsigma = NULL, gravsigma = NULL, ovisigma = NULL, customsigma = NULL, simdims = NULL, kernelshape = NULL, cycle = NULL, call = NULL, filtertype = NULL, upper = NULL, lower = NULL, spacing = NULL, samplenum = NULL, sampledims = NULL, model = NULL )
kin_pair_simulation( data = NULL, kinship = NULL, lifestage = NULL, simtype = NULL, kerneltype = NULL, posigma = NULL, initsigma = NULL, breedsigma = NULL, gravsigma = NULL, ovisigma = NULL, customsigma = NULL, simdims = NULL, kernelshape = NULL, cycle = NULL, call = NULL, filtertype = NULL, upper = NULL, lower = NULL, spacing = NULL, samplenum = NULL, sampledims = NULL, model = NULL )
data |
tbl_df. tibble of simulation values |
kinship |
character - one of PO, FS, HS, AV, HAV, GG, 1C, H1C, GAV, HGAV, 1C1, H1C1, GGG, 2C, and H2C. |
lifestage |
character - one of 'unknown', 'immature' or 'ovipositional' |
simtype |
character - simulation type |
kerneltype |
character. - 'Gaussian', 'Laplace' or 'vgamma' (variance-gamma) |
posigma |
numeric - overall value of dispersal sigma (for simple kernel) |
initsigma |
numeric. - value of pre-breeding dispersal sigma (for composite kernel) |
breedsigma |
numeric. - value of breeding dispersal sigma (for composite kernel) |
gravsigma |
numeric. - value of post-breeding dispersal sigma (for composite kernel) |
ovisigma |
numeric. - value of oviposition dispersal sigma (for composite kernel) |
customsigma |
numeric. - vector of named custom dispersal sigmas (for custom kernel) |
simdims |
numeric. - dimensions of sampling area (assumes one side of square) |
kernelshape |
numeric. - value of kernel shape of simulation (if using kernel with shape parameter e.g. vgamma) |
cycle |
integer - number of breeding cycles sampled individual has survived (for custom kernel) |
call |
call. Call to create object |
filtertype |
character. whether the initial sim has been further filtered |
upper |
numeric. - FILTER: upper threshold used |
lower |
numeric. - FILTER: lower threshold used |
spacing |
numeric. - FILTER: spacing used |
samplenum |
numeric. - FILTER: sample number used |
sampledims |
numeric. - FILTER: sample dimensions used |
model |
list - model information if custom simulation used to generate object |
returns an object of class KinPairSimulation
.
kin_pair_simulation()
kin_pair_simulation()
KinPairData
object to .csv
formatThis function is part of suite of functions handling file import/export for kinship dispersal objects. Writing
to .csv or .tsv formats strips most KinPairData
& KinPairSimulation
class metadata and leaves a delimited file
containing ids, kinship category, geographical distance, & x & y coordinates for each simulated pair. (removes class attributes)
kinpair_to_csv(x, file, ...)
kinpair_to_csv(x, file, ...)
x |
Object of class |
file |
The file path to write to |
... |
Additional arguments to pass to |
Invisibly returns the initial object
Other export_functions:
kinpair_to_tibble()
,
kinpair_to_tsv()
,
write_kindata()
Extract KinPairData
class object to tibble. Strips out most class metadata leaving a
dataframe of disersal simulation data with a column added covering lifestage at sampling.
kinpair_to_tibble(x)
kinpair_to_tibble(x)
x |
object of class |
tibble (class tbl_df
)
Other export_functions:
kinpair_to_csv()
,
kinpair_to_tsv()
,
write_kindata()
KinPairData
object to .tsv
formatThis function is part of suite of functions handling file import/export for kinship dispersal objects. Writing
to .csv or .tsv formats strips most KinPairData
& KinPairSimulation
class metadata and leaves a delimited file
containing ids, kinship category, geographical distance, & x & y coordinates for each simulated pair. (removes class attributes)
kinpair_to_tsv(x, file, ...)
kinpair_to_tsv(x, file, ...)
x |
Object of class |
file |
The file path to write to |
... |
Additional arguments to pass to |
Invisibly returns the initial object
Other export_functions:
kinpair_to_csv()
,
kinpair_to_tibble()
,
write_kindata()
The class KinPairData
is a formal (S4) class for storing kinship and lifespan dispersal
information concerning kin pairs. It is the base class on which the KinPairSimulation
class is built.
The KinPairData
class is used to store information about the spatial distribution of kin dyads for use
in calculating axial sigmas of intergenerational dispersal as initially implemented in Jasper et al. 2019
(doi:10.1111/1755-0998.13043).
## S4 method for signature 'KinPairData' show(object) ## S4 method for signature 'KinPairData' initialize( .Object, data = NULL, kinship = NULL, lifestage = NULL, cycle = NULL, ... )
## S4 method for signature 'KinPairData' show(object) ## S4 method for signature 'KinPairData' initialize( .Object, data = NULL, kinship = NULL, lifestage = NULL, cycle = NULL, ... )
object |
an object of class KinpairData |
.Object |
the KinPairData object to be constructed |
data |
data about kinship to be used to construct object (tibble, data.frame, or numeric vector of distances) |
kinship |
character. Kinship category value for object. - one of PO, FS, HS, AV, HAV, GG, 1C, H1C, GAV, HGAV, 1C1, H1C1, GGG, 2C, and H2C. |
lifestage |
character. Lifestage value for object. - one of 'immature', 'ovipositional' or 'unknown' |
cycle |
non-negative integer or vector of two such integers - Represents the number of complete breeding cycles each simulated individual has undergone before the sampling point, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). If the first individual was sampled as a juvenile & the second as an adult of equivalent stage, the vector c(0, 1) would be used. In most situations, defualt will be appropriate |
... |
additional argument to pass to downstream functions in future |
KinPairData |
object of class KinPairData |
This class is essentially wrapped around the tbl_df
class but with (a) expectations around certain columns
that must be present (id1, id2, kinship
, & distance
- three 'character' & one 'numeric' column), as
well as (b) additional attributes (kinship
, lifestage
, & cycle
) characterizing the close-kin
dyads being stored.These attributes, as well as the embedded vector of distances, can be accessed with the methods
kinship
, lifestage
, breeding_cycle
and distances
.
Objects from this class are returned from the df_to_kinpair
and csv_to_kinpair
functions
(& related), and are directly constructed with the namesake KinPairData()
function.
They can be passed to the sample_kindist
function for filtering and subsampling, and to
axial functions (including axials_standard
and axpermute_standard
) for estimation of
axial dispersal.
returns object of class KinPairData
No return value, called for side effects
Returns an object of class KinPairData
show(KinPairData)
: standard print method
initialize(KinPairData)
: initialize method
kinship
character - one of PO, FS, HS, AV, HAV, GG, 1C, H1C, GAV, HGAV, 1C1, H1C1, GGG, 2C, and H2C.
lifestage
character - lifestage at sampling - either 'immature', 'ovipositional' or a stage
corresponding to a DispersalModel
custom stage
cycle
non-negative integer or vector of two such integers - Represents the number of complete breeding cycles each individual has undergone before the sampling point, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0). If the first individual was sampled as a juvenile & the second as an adult of equivalent stage, the vector c(0, 1) would be used. In most situations, the default will be appropriate
tab
tbl_df. - tibble of dispersal values
Other kdclasses:
DispersalModel-class
,
KinPairSimulation-class
Constructor for KinPairSimulation Class (composite)
KinPairSimulation_composite( data = NULL, kinship = NULL, kerneltype = NULL, initsigma = NULL, breedsigma = NULL, gravsigma = NULL, ovisigma = NULL, simdims = NULL, lifestage = NULL, kernelshape = NULL, call = NULL, model = NULL )
KinPairSimulation_composite( data = NULL, kinship = NULL, kerneltype = NULL, initsigma = NULL, breedsigma = NULL, gravsigma = NULL, ovisigma = NULL, simdims = NULL, lifestage = NULL, kernelshape = NULL, call = NULL, model = NULL )
data |
tibble of pairwise kin classes & distances. Ideally contains fields id1 & id2 (chr) an distance (dbl) optionally includes coords (x1, y1, x2, y2), lifestage (ls1 & ls2), kinship (chr) and sims (dbl) |
kinship |
character. Code for kinship category of simulation. one of PO, FS, HS, AV, GG, HAV, GGG, 1C, 1C1, 2C, GAV, HGAV, H1C or H2C |
kerneltype |
character. Statistical model for simulated dispersal kernel. Currently either "Gaussian", "Laplace" or "vgamma" (variance-gamma). |
initsigma |
numeric. Axial sigma of prebreeding ('juvenile') dispersal kernel (axial standard deviation). |
breedsigma |
numeric. Axial sigma of breeding dispersal kernel (axial standard deviation). |
gravsigma |
numeric. Axial sigma of post-breeding ('gravid') dispersal kernel (axial standard deviation). |
ovisigma |
numeric. Axial sigma of oviposition dispersal kernel (axial standard deviation). |
simdims |
numeric. Length of side of simulated area square. |
lifestage |
character. Simulated lifestage of sampling. Either "immature" (sampled at hatching) or "ovipositional" (sampled as an adult during oviposition - essentially one lifespan later than 'immature') |
kernelshape |
numeric. Value of shape parameter for simulated kernel if kernel requires one (e.g. vgamma kernel). |
call |
call object. Use to pass the system call that led to the generation of this class. (via sys.call) |
model |
DispersalModel - model information passed from simulation function |
Returns a KinPairSimulation
Class object with simtype set to 'composite' and relevant fields included.
kindata <- tibble::tibble( id1 = c("a", "b", "c"), id2 = c("x", "y", "z"), distance = c(50, 45, 65), kinship = c("1C", "1C", "1C") ) KinPairSimulation_composite(kindata, kinship = "1C", kerneltype = "Gaussian", initsigma = 15, breedsigma = 25, gravsigma = 20, ovisigma = 10, lifestage = "immature" )
kindata <- tibble::tibble( id1 = c("a", "b", "c"), id2 = c("x", "y", "z"), distance = c(50, 45, 65), kinship = c("1C", "1C", "1C") ) KinPairSimulation_composite(kindata, kinship = "1C", kerneltype = "Gaussian", initsigma = 15, breedsigma = 25, gravsigma = 20, ovisigma = 10, lifestage = "immature" )
Constructor for KinPairSimulation Class (custom)
KinPairSimulation_custom( data = NULL, kinship = NULL, kerneltype = NULL, customsigma = NULL, simdims = NULL, lifestage = NULL, kernelshape = NULL, cycle = NULL, call = NULL, model = NULL )
KinPairSimulation_custom( data = NULL, kinship = NULL, kerneltype = NULL, customsigma = NULL, simdims = NULL, lifestage = NULL, kernelshape = NULL, cycle = NULL, call = NULL, model = NULL )
data |
tibble of pairwise kin classes & distances. Ideally contains fields id1 & id2 (chr) an distance (dbl) optionally includes coords (x1, y1, x2, y2), lifestage (ls1 & ls2), kinship (chr) and sims (dbl) |
kinship |
character. Code for kinship category of simulation. one of PO, FS, HS, AV, GG, HAV, GGG, 1C, 1C1, 2C, GAV, HGAV, H1C or H2C |
kerneltype |
character. Statistical model for simulated dispersal kernel. Currently either "Gaussian", "Laplace" or "vgamma" (variance-gamma). |
customsigma |
numeric. Named vector of custom breeding cycle stages and their corresponding axial dispersal values |
simdims |
numeric. Length of side of simulated area square. |
lifestage |
character. Simulated lifestage of sampling. Here, must correspond to a custom lifestage derived from 'customsigma' |
kernelshape |
numeric. Value of shape parameter for simulated kernel if kernel requires one (e.g. vgamma kernel). |
cycle |
non-negative integer. Breeding cycle numbers of dispersed kin to be modeled. Represents the number of complete breeding cycles each simulated individual has undergone before the sampling point, where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0) |
call |
call object. Use to pass the system call that led to the generation of this class. (via sys.call) |
model |
DispersalModel - model information passed from simulation function |
Returns a KinPairSimulation
Class object with simtype set to 'custom' and relevant fields included.
kindata <- tibble::tibble( id1 = c("a", "b", "c"), id2 = c("x", "y", "z"), distance = c(50, 45, 65), kinship = c("1C", "1C", "1C") ) KinPairSimulation_custom(kindata, kinship = "1C", kerneltype = "Gaussian", customsigma = c(initsigma = 15, breedsigma = 25, gravsigma = 20, ovisigma = 10), lifestage = "ovisigma", cycle = 0 )
kindata <- tibble::tibble( id1 = c("a", "b", "c"), id2 = c("x", "y", "z"), distance = c(50, 45, 65), kinship = c("1C", "1C", "1C") ) KinPairSimulation_custom(kindata, kinship = "1C", kerneltype = "Gaussian", customsigma = c(initsigma = 15, breedsigma = 25, gravsigma = 20, ovisigma = 10), lifestage = "ovisigma", cycle = 0 )
Constructor for KinPairSimulation Class (simple)
KinPairSimulation_simple( data = NULL, kinship = NULL, kerneltype = NULL, posigma = NULL, simdims = NULL, lifestage = NULL, kernelshape = NULL, call = NULL, model = NULL )
KinPairSimulation_simple( data = NULL, kinship = NULL, kerneltype = NULL, posigma = NULL, simdims = NULL, lifestage = NULL, kernelshape = NULL, call = NULL, model = NULL )
data |
tibble of pairwise kin classes & distances. Ideally contains fields id1 & id2 (chr) an distance (dbl) optionally includes coords (x1, y1, x2, y2), lifestage (ls1 & ls2), kinship (chr) and sims (dbl) |
kinship |
character. Code for kinship category of simulation. one of PO, FS, HS, AV, GG, HAV, GGG, 1C, 1C1, 2C, GAV, HGAV, H1C or H2C |
kerneltype |
character. Statistical model for simulated dispersal kernel. Currently either "Gaussian", "Laplace" or "vgamma" (variance-gamma). |
posigma |
numeric. Axial sigma of dispersal kernel (axial standard deviation). |
simdims |
numeric. Length of side of simulated area square. |
lifestage |
character. Simulated lifestage of sampling. Either "immature" (sampled at hatching) or "ovipositional" (sampled as an adult during oviposition - essentially one lifespan later than 'immature') |
kernelshape |
numeric. Value of shape parameter for simulated kernel if kernel requires one (e.g. vgamma kernel). |
call |
call object. Use to pass the system call that led to the generation of this class. (via sys.call) |
model |
DispersalModel - model information passed from simulation function |
Returns a KinPairSimulation
Class object with simtype set to 'simple' and relevant fields included.
kindata <- tibble::tibble( id1 = c("a", "b", "c"), id2 = c("x", "y", "z"), distance = c(50, 45, 65), kinship = c("1C", "1C", "1C") ) KinPairSimulation_simple(kindata, kinship = "1C", kerneltype = "Gaussian", posigma = 38, lifestage = "immature" )
kindata <- tibble::tibble( id1 = c("a", "b", "c"), id2 = c("x", "y", "z"), distance = c(50, 45, 65), kinship = c("1C", "1C", "1C") ) KinPairSimulation_simple(kindata, kinship = "1C", kerneltype = "Gaussian", posigma = 38, lifestage = "immature" )
The class KinPairSimulation
is a formal (S4) class for storing kinship and dispersal
distribution information derived from simulations in the kindisperse
package.
It is derived from the KinPairData
class.
The KinPairSimulation
class is used to store information about the spatial distribution of kin dyads for use
in calculating axial sigmas of intergenerational dispersal as initially implemented in Jasper et al. 2019
(doi:10.1111/1755-0998.13043).
## S4 method for signature 'KinPairSimulation' show(object) ## S4 method for signature 'KinPairSimulation' initialize( .Object, data = NULL, kinship = NULL, lifestage = NULL, simtype = NULL, kerneltype = NULL, kernelshape = NULL, posigma = NULL, initsigma = NULL, breedsigma = NULL, gravsigma = NULL, ovisigma = NULL, customsigma = NULL, cycle = NULL, simdims = NULL, call = NULL, filtertype = NULL, upper = NULL, lower = NULL, spacing = NULL, samplenum = NULL, sampledims = NULL, model = NULL )
## S4 method for signature 'KinPairSimulation' show(object) ## S4 method for signature 'KinPairSimulation' initialize( .Object, data = NULL, kinship = NULL, lifestage = NULL, simtype = NULL, kerneltype = NULL, kernelshape = NULL, posigma = NULL, initsigma = NULL, breedsigma = NULL, gravsigma = NULL, ovisigma = NULL, customsigma = NULL, cycle = NULL, simdims = NULL, call = NULL, filtertype = NULL, upper = NULL, lower = NULL, spacing = NULL, samplenum = NULL, sampledims = NULL, model = NULL )
object |
object of class KinPairSimulation |
.Object |
object to be constructed into KinPairSimulation class |
data |
tbl_df. tibble of simulation values |
kinship |
character - one of PO, FS, HS, AV, HAV, GG, 1C, H1C, GAV, HGAV, 1C1, H1C1, GGG, 2C, and H2C. |
lifestage |
character - one of 'unknown', 'immature' or 'ovipositional' |
simtype |
character - simulation type |
kerneltype |
character. - 'Gaussian', 'Laplace' or 'vgamma' (variance-gamma) |
kernelshape |
numeric. - value of kernel shape of simulation (if using kernel with shape parameter e.g. vgamma) |
posigma |
numeric - overall value of dispersal sigma (for simple kernel) |
initsigma |
numeric. - value of pre-breeding dispersal sigma (for composite kernel) |
breedsigma |
numeric. - value of breeding dispersal sigma (for composite kernel) |
gravsigma |
numeric. - value of post-breeding dispersal sigma (for composite kernel) |
ovisigma |
numeric. - value of oviposition dispersal sigma (for composite kernel) |
customsigma |
numeric. - vector of named custom dispersal sigmas (for custom kernel) |
cycle |
integer - number of breeding cycles sampled individual has survived (for custom kernel) |
simdims |
numeric. - dimensions of sampling area (assumes one side of square) |
call |
call. Call to create object |
filtertype |
character. whether the initial sim has been further filtered |
upper |
numeric. - FILTER: upper threshold used |
lower |
numeric. - FILTER: lower threshold used |
spacing |
numeric. - FILTER: spacing used |
samplenum |
numeric. - FILTER: sample number used |
sampledims |
numeric. - FILTER: sample dimensions used |
model |
list - model information if custom simulation used to generate object |
KinPairSimulation |
an object of class KinPairSimulation |
This class is essentially wrapped around the tbl_df
class but with (a) expectations around certain columns
that must be present (id1, id2, kinship
, & distance
- three 'character' & one 'numeric' column), as
well as (b) additional attributes (kinship
, lifestage
, & cycle
) characterizing the close-kin
dyads being stored.These attributes, as well as the embedded vector of distances, can be accessed with the methods
kinship
, lifestage
, breeding_cycle
and distances
.
In addition to the above attributes (derived from the KinPairData
class), this class contains attributes
capturing the simulation type & parameters used to generate the final distribution of kin dyads.
Objects from this class are returned from the simulate_kindist_composite
,
simulate_kindist_simple
and simulate_kindist_custom
functions
(& related), and are directly constructed with the namesake KinPairSimulation()
function.
They can be passed to the sample_kindist
function for filtering and subsampling, and to
axial functions (including axials_standard
and axpermute_standard
) for estimation of
axial dispersal.
returns object of class KinPairSimulation
No return value, called for side effects
Returns an object of class KinPairSimulation
show(KinPairSimulation)
: print method
initialize(KinPairSimulation)
: initialisation method
kinship
character - one of PO, FS, HS, AV, HAV, GG, 1C, H1C, GAV, HGAV, 1C1, H1C1, GGG, 2C, and H2C.
simtype
character. - one of 'simple', 'composite' or 'custom'
kerneltype
character. - 'Gaussian', 'Laplace' or 'vgamma' (variance-gamma)
posigma
numeric. - overall value of dispersal sigma (for simple kernel)
initsigma
numeric. - value of pre-breeding dispersal sigma (for composite kernel)
breedsigma
numeric. - value of breeding dispersal sigma (for composite kernel)
gravsigma
numeric. - value of post-breeding dispersal sigma (for composite kernel)
ovisigma
numeric. - value of oviposition dispersal sigma (for composite kernel)
customsigma
numeric - vector of named custom dispersal sigmas (for custom kernel)
simdims
numeric. - dimensions of sampling area (assumes 1 side of square)
lifestage
character. - lifestage at sampling - either 'immature' or 'ovipositional'
cycle
integer - number of breeding cycles sampled individuals have survived (for custom kernel)
kernelshape
numeric. - shape parameter if vgamma kerneltype
call
call. - call to create initial simulation
tab
tbl_df. - tibble of simulation values
filtertype
character. - whether the initial sim has been further filtered
upper
numeric. - FILTER: upper threshold used
lower
numeric. - FILTER: lower threshold used
spacing
numeric. - FILTER: spacing used
samplenum
numeric. - FILTER: sample number used
sampledims
numeric. - FILTER: dimensions used
model
DispersalModel
- model of dispersal used to create object (with custom type)
Other kdclasses:
DispersalModel-class
,
KinPairData-class
kinship
category of KinPairData
class objectsAccess or assign kinship
category of KinPairData
class objects
kinship(x) kinship(x) <- value ## S4 method for signature 'KinPairData' kinship(x) ## S4 replacement method for signature 'KinPairData' kinship(x) <- value
kinship(x) kinship(x) <- value ## S4 method for signature 'KinPairData' kinship(x) ## S4 replacement method for signature 'KinPairData' kinship(x) <- value
x |
object of class |
value |
value to assign to slot |
KinPairData |
object of class |
returns character
kinship category of object or KinPairData
object with modified kinship category
kinship(KinPairData)
:
kinship(KinPairData) <- value
:
Other kpdmethods:
distances()
,
lifestage()
lifestage
category of KinPairData
class objectsAccess or assign lifestage
category of KinPairData
class objects
lifestage(x) lifestage(x) <- value ## S4 method for signature 'KinPairData' lifestage(x) ## S4 replacement method for signature 'KinPairData' lifestage(x) <- value
lifestage(x) lifestage(x) <- value ## S4 method for signature 'KinPairData' lifestage(x) ## S4 replacement method for signature 'KinPairData' lifestage(x) <- value
x |
object with relevant method |
value |
new value to assign |
KinPairData |
object of class |
returns character
lifestage of object or KinPairData
object with modified lifestage
lifestage(KinPairData)
:
lifestage(KinPairData) <- value
:
Other kpdmethods:
distances()
,
kinship()
A data file containing the positions & kinship values of 98 Ae. aegypti larval kin pairs collected between September 19 & October 10, 2017 in Mentari Court (Petaling Jaya), Malaysia.
mentari
mentari
A data frame with 98 rows and 10 variables
id of first individual of kinpair
id of second individual of kinpair
kinship category of the pairing
geographical distance between kinpair
relative x coordinate of first individual in metres
relative y coordinate of first individual in metres
relative x coordinate of second individual in metres
relative y coordinate of second individual in metres
lifestage at time of sampling of kinpair
calculated Loiselle's k value for kinpair
162 individuals were sourced as larvae from ovitraps placed in eight apartment buildings (in floors three or four for each), collected over three weeks. Entire larval bodies were extracted and sequenced using the double-digest restriction-site- associated DNA sequencing protocol for Ae. aegypti (doi:10.1186/1471-2164-15-275. After sequencing & genotyping, Loiselle's k was used as an initial estimate of genetic kinship. The program ML-Relate (doi:10.1111/j.1471-8286.2006.01256.x) was then used to estimate the pedigree kinships for the FS and HS categories. Following simulation work described in doi:10.1111/1755-0998.13043 the 1C category was assigned to all remaining unassigned individuals with a Loiselle's k of less than 0.06.
returns an object of class tbl_df
KinPairData
Objects for use in kindisperse appThis function is part of a suite of functions handling the interface between the kindisperse app & R
package. Due to how shiny's interactive programming works, ordinary objects are not visible to the reactive functions
embedded in the app. The solution implemented here is to construct a custom environment, env_appdata
, that is
accessible within the app and outside of it.
This function takes an object of class KinPairData
or KinPairSimulation
, assigns it an identifying name,
and adds it to the app interface environment, making it accessible within the app. Once added, this object will be
accessible under its name from the Load
menu of the app. (The app interface uses the same function
internally, enabling objects to be passed to the interface from the app also).
mount_appdata(x, nm)
mount_appdata(x, nm)
x |
An object of class |
nm |
character. A name to store the object as |
invisibly returns x.
Other app_ports:
display_appdata()
,
reset_appdata()
,
reset_tempdata()
,
retrieve_appdata()
,
retrieve_tempdata()
,
retrieveall_appdata()
,
unmount_appdata()
mount_appdata(kin_pair_data(), "mydata")
mount_appdata(kin_pair_data(), "mydata")
.kindata
filetype back to KinPairData
or KinPairSimulation
object.This function is part of suite of functions handling file import/export for kinship dispersal objects.
The custom .kindata
format enables complete preservation of KinPairData
& KinPairSimulation
formats
without any loss of class attributes or metadata - ideal for saving and retrieving simulation data that is intended for further in-package
processing with kindisperse. This function loads a previously stored object into its original class format.
read_kindata(file)
read_kindata(file)
file |
Character giving path reference to file with extension |
Returns either KinPairData
or KinPairSimulation
object.
Other import_functions:
csv_to_kinpair()
,
df_to_kinpair()
,
tsv_to_kinpair()
,
vector_to_kinpair()
Change the dimensions of a KinPairSimulation Object and shift kinpairs so at least one individual is within the area
rebase_dims(kindist, dims)
rebase_dims(kindist, dims)
kindist |
|
dims |
New site dimensions - either single number (length of side of square) or length 2 vector (lengths of sides x and y of rectangle) |
returns a rebased object of class KinPairSimulation
with adjusted simulation dimensions
simobject <- simulate_kindist_simple() rebase_dims(simobject, c(1, 100)) rebase_dims(simobject, 15)
simobject <- simulate_kindist_simple() rebase_dims(simobject, c(1, 100)) rebase_dims(simobject, 15)
This function is part of a suite of functions handling the interface between the kindisperse app & R
package. Due to how shiny's interactive programming works, ordinary objects are not visible to the reactive functions
embedded in the app. The solution implemented here is to construct a custom environment, env_appdata
, that is
accessible within the app and outside of it.
When called, this function clears all attached objects from the app interface environment, keeping it from becoming over-clutttered & taking up space.
reset_appdata()
reset_appdata()
No return value, called for side effects
Other app_ports:
display_appdata()
,
mount_appdata()
,
reset_tempdata()
,
retrieve_appdata()
,
retrieve_tempdata()
,
retrieveall_appdata()
,
unmount_appdata()
reset_appdata()
reset_appdata()
This function is part of a suite of functions handling the interface between the kindisperse app & R
package. Due to how shiny's interactive programming works, ordinary objects are not visible to the reactive functions
embedded in the app. The solution implemented here is to construct a custom environment, env_appdata
, that is
accessible within the app and outside of it.
This function resets the internal tempdata
environment used by the kindisperse app, keeping it from becoming
over-cluttered & freeing up space.
reset_tempdata()
reset_tempdata()
No return value, called for side effects
Other app_ports:
display_appdata()
,
mount_appdata()
,
reset_appdata()
,
retrieve_appdata()
,
retrieve_tempdata()
,
retrieveall_appdata()
,
unmount_appdata()
reset_tempdata()
reset_tempdata()
KinPairData
object from appdata (single)This function is part of a suite of functions handling the interface between the kindisperse app & R
package. Due to how shiny's interactive programming works, ordinary objects are not visible to the reactive functions
embedded in the app. The solution implemented here is to construct a custom environment, env_appdata
, that is
accessible within the app and outside of it.
This function accesses the app interface environment and retrieves an object (typically of class KinPairData
or
KinPairSimulation
) with the name nm
, making it accessible from within our outside the app. This can be
used to load simulation objects that were saved from the interface while using the app into the regular R environment
(after closing the app). (The app uses this function internally to load objects from the interface into its own internal
environment for display & processing.)
retrieve_appdata(nm)
retrieve_appdata(nm)
nm |
character. Name of item as stored in appdata |
Returns KinPairData object accessible by name nm
Other app_ports:
display_appdata()
,
mount_appdata()
,
reset_appdata()
,
reset_tempdata()
,
retrieve_tempdata()
,
retrieveall_appdata()
,
unmount_appdata()
mount_appdata(kin_pair_data(), "mydata") retrieve_appdata("mydata")
mount_appdata(kin_pair_data(), "mydata") retrieve_appdata("mydata")
This function is part of a suite of functions handling the interface between the kindisperse app & R
package. Due to how shiny's interactive programming works, ordinary objects are not visible to the reactive functions
embedded in the app. The solution implemented here is to construct a custom environment, env_appdata
, that is
accessible within the app and outside of it.
This function accesses the app internal environment and retrieves a named list of all objects (typically of classes
KinPairData
or KinPairSimulation
contained within it, making them accessible outside of the app). This
is used to quickly retrieve all objects stored in the app's internal memory. Ordinarily, these would be passed to the
interface environment, but this function is useful if the app crashed and important results were only present in the
app's internal environment.
retrieve_tempdata()
retrieve_tempdata()
A list of all KinPairData objects in kindisperse app's tempdata
Other app_ports:
display_appdata()
,
mount_appdata()
,
reset_appdata()
,
reset_tempdata()
,
retrieve_appdata()
,
retrieveall_appdata()
,
unmount_appdata()
retrieve_tempdata()
retrieve_tempdata()
KinPairData
objects from appdata (as list)This function is part of a suite of functions handling the interface between the kindisperse app & R
package. Due to how shiny's interactive programming works, ordinary objects are not visible to the reactive functions
embedded in the app. The solution implemented here is to construct a custom environment, env_appdata
, that is
accessible within the app and outside of it.
This function accesses the app interface environment and retrieves a named list of all objects (typically of classes
KinPairData
or KinPairSimulation
contained within it, making them accessible outside of the app). This
is used to quickly pass all simulation objects that were saved to this interface environment while using the app to
the regular R environment (after closing the app).
retrieveall_appdata()
retrieveall_appdata()
Returns a list of objects stored in the appdata environment
Other app_ports:
display_appdata()
,
mount_appdata()
,
reset_appdata()
,
reset_tempdata()
,
retrieve_appdata()
,
retrieve_tempdata()
,
unmount_appdata()
mount_appdata(kin_pair_data(), "k1") mount_appdata(kin_pair_simulation(), "s1") retrieveall_appdata()
mount_appdata(kin_pair_data(), "k1") mount_appdata(kin_pair_simulation(), "s1") retrieveall_appdata()
Run kindisperse app
run_kindisperse()
run_kindisperse()
returns a shiny app instance of kindisperse
KinPairSimulation
or KinPairData
ObjectThis function takes a pre-existing KinPairSimulation
or KinPairData
Object with distance and coordinate data and filters
it to simulate various in-field sampling schemes.
sample_kindist( kindist, upper = NULL, lower = NULL, spacing = NULL, n = NULL, dims = NULL )
sample_kindist( kindist, upper = NULL, lower = NULL, spacing = NULL, n = NULL, dims = NULL )
kindist |
|
upper |
|
lower |
|
spacing |
|
n |
|
dims |
dimensions to sample within (works with the |
This function enables the testing of the impact of some basic sampling constraints that might be encountered in study design or
implementation on the effectiveness of the kindisperse
estimation of intergenerational dispersal. It is typically paired with
a simulation function such as simulate_kindist_composite
to generate a 'pure' dataset, then an estimation function
such as axpermute
to examine the impact of filter settings on the 'detected' value of dispersal sigma. The filter
parameters upper
, lower
, & spacing
all work on the vector of (direction-independent) distances, & the parameter
n
enables the random subsampling of n kin dyads. The parameter dims
requires 2D location information for each individual,
meaning it can ordinarily only be used with the KinPairSimulation
object (not KinPairData
). All filter parameters are
stackable.
The upper
parameter implements a cutoff for the maximum distance allowable in the dataset. If set to e.g. 100m, all kin dyads
separated by a distance greater than 100m will be excluded from the filtered dataset. Note that this is a geometry-independent metric;
it is naive to the edge effects of an actual sample site. The lower
parameter implements a cutoff for the minimum
distance allowable in the dataset.It operates in the same manner as the previous parameter (in this case, removing results smaller
than a distance threshold)
The spacing
parameter as currently implemented takes all distances & alters them to lie at the midpoint of a bin with width set
by this parameter. So if spacing
is set to 10 meters, all kin pairs with distances between 0 and 10m will have their distances
rest to 5m, all between 10 & 20 will be set to 15 m, etc. (quantizing the data). Note that once again this is a geometry-independent
action: These binwiths & 'trap spacing' are not spatially related to each other like they would be in a sample site, and there is no
simulated dropout of kinpairs too far from a trap. There is also no geometry-dependent profiling of possible frequency of recaptures
across each distance category (will be implemented in a future version). (this parameter leaves 2D spatial information intact)
The dims
parameter defines the dimensions of a rectangle within which both individuals of a kin dyad will need to lie
to be included in the filtered dataset. This measure (which excludes e.g. long-distance dispersal into & out of the study site) is
geometry-dependent, unlike the upper
parameter. This enables the testing of (rectangular) site geometries potentially
corresponding to an actual site (two-dimensional estimates of dispersal such as kindisperse
become unreliable as edge effects
significantly reduce the size of either one or both dimensions with respect to the real underlying dispersal sigma). These site
geometries can be entered in a few ways: (a) a single numeric value, which will be interpreted as the length of the side of a square;
(b) a numeric vector of length two, which will be interpreted as the length & width of the sample site; (c) either of the above passed
to the elongate
function, which takes the rectangular site dimensions and alters their aspect ratio
(ratio of
length to width) while preserving the underlying area the study site covers. The implementation of this filtering step permutes the
absolute positions of all dyads so that at least one member of the dyad is in the inial site rectangle, while preserving their relative
positions (and angles) with respect to each other. This means that following this step, the xy coordinate positions of each
individual will not match those contained in the previous round. It also means that the repeated calling of this function will
result in a steady reduction in retained kin dyads due to edge effects.
The n
parameter randomly samples n pairs from the dataset. It is implemented after all other filtering has taken place, so
will only sample surviving individuals A typical strategy for the use of this functions in simulations would be to simulate an
extremely large (e.g. one million pairs) dataset, then pass it repeatedly to this filter function, with a final sub-sampling step of
1,000 included. This enables comparisons across sampling conditions (in most cases) regardless of the amount of data filtered prior to
this step.
As this function returns a KinPairData
or KinPairSimulation
object, the returned object can be passed back for filtering
an arbitrary number of times, or alternatively passed to an estimation strategy.
This function can be used to test for bias in the results of a close-kin dispersal study that has been conducted. After the field
sampling, kin identification, & sigma calculation steps, use the estimated sigmas as inputs into simulation functions that are
then filtered for size & geometry of the actual study site (via the dims
method). Then pass this filtered dataset back to the
sigma-determining functions. If filtering has resulted in a substantial drop in sigma, the estimate of sigma from the study site has
likely been biased by the site geometry (note that the impact of this is dependent on the shape of the dispersal kernel - the more
leptokurtic (dominated by long-distance dispersal), the more severe bias will be for a particular sigma and site geometry.
returns an object of class KinPairData
or KinPairSimulation
containing simulation and filtering
details and a filtered dataset of dispersed individuals.
simobject <- simulate_kindist_simple(nsims = 100000, sigma = 100, kinship = "PO") sample_kindist(simobject, upper = 200, lower = 50, spacing = 15, n = 100)
simobject <- simulate_kindist_simple(nsims = 100000, sigma = 100, kinship = "PO") sample_kindist(simobject, upper = 200, lower = 50, spacing = 15, n = 100)
DispersalModel
or KinPairSimulation
object.Access sampling stage of DispersalModel
or KinPairSimulation
object.
sampling_stage(x) sampling_stage(x) <- value ## S4 method for signature 'DispersalModel' sampling_stage(x) ## S4 replacement method for signature 'DispersalModel' sampling_stage(x) <- value ## S4 method for signature 'KinPairData' sampling_stage(x)
sampling_stage(x) sampling_stage(x) <- value ## S4 method for signature 'DispersalModel' sampling_stage(x) ## S4 replacement method for signature 'DispersalModel' sampling_stage(x) <- value ## S4 method for signature 'KinPairData' sampling_stage(x)
x |
object of class |
value |
|
DispersalModel |
object of class |
KinPairData |
object of class |
character
sampling stage
returns a modified object of class DispersalModel
sampling_stage(DispersalModel)
:
sampling_stage(KinPairData)
:
KinPairSimulation
objectAccess simulation dimensions of KinPairSimulation
object
simdims(x) simdims(x) <- value ## S4 method for signature 'KinPairSimulation' simdims(x)
simdims(x) simdims(x) <- value ## S4 method for signature 'KinPairSimulation' simdims(x)
x |
object of class |
value |
new value to assign |
KinPairSimulation |
object of class KinPairSimulation |
numeric vector
dimensions of simulated object
returns a modified object of the relevant class
numeric vector
simulation dimensions of KinPairSimulation
object
simdims(KinPairSimulation)
:
Simple kin dispersal simulation for graphical display. (returns the data side as a tibble).
simgraph_data(nsims = 1000, posigma = 50, dims = 250, kinship = "2C")
simgraph_data(nsims = 1000, posigma = 50, dims = 250, kinship = "2C")
nsims |
Integer. The number of kin dispersal families to simulate. |
posigma |
Integer. The axial deviation of the (simple) parent-offspring dispersal kernel governing this simulation. |
dims |
Integer. Lays out the length of the sides of a square within which parent individuals are seeded. |
kinship |
Character. Lists the kin category the simulation is reconstructing. One of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV" (no half-categories included) |
Returns a tibble containing the coordinates of the f0 to f2 generations, as well as coordinates and distances relative to the 'focus' kinship categories. (kindist, kinmid, k1 & k2)
Other simgraph:
simgraph_graph()
simgraph_data(nsims = 100, dims = 1000, kinship = "GAV")
simgraph_data(nsims = 100, dims = 1000, kinship = "GAV")
Simple kin dispersal simulation for graphical display. (graphs the pre-existing simulation).
simgraph_graph( result, nsims = 10, labls = TRUE, steps = TRUE, moves = TRUE, shadows = TRUE, kinship = NULL, show_area = TRUE, centred = FALSE, pinwheel = FALSE, scattered = FALSE, lengths = TRUE, lengthlabs = TRUE, histogram = FALSE, binwidth = posigma/5, freqpoly = FALSE )
simgraph_graph( result, nsims = 10, labls = TRUE, steps = TRUE, moves = TRUE, shadows = TRUE, kinship = NULL, show_area = TRUE, centred = FALSE, pinwheel = FALSE, scattered = FALSE, lengths = TRUE, lengthlabs = TRUE, histogram = FALSE, binwidth = posigma/5, freqpoly = FALSE )
result |
simulation supplied from simgraph_data() function (tibble) |
nsims |
number of families to graph |
labls |
Logical. Displays labels. |
steps |
Logical. Whether or not to show any details of dispersal movement |
moves |
Logical. Whether or not to show (curved) lines denoting dispersal movement |
shadows |
Logical. Whether or not to show (dashed) shadows tracing dispersal movement. |
kinship |
Character. Lists the kin category the simulation is reconstructing. One of "PO", "FS", "HS", "AV", "GG", "HAV", "GGG", "1C", "1C1", "2C", "GAV" (no half-categoris included) |
show_area |
Logical. Whether or not to show the parental seed area as defined in data$dims |
centred |
Logical. Whether or not to centre the coordinates on one individual. |
pinwheel |
Logical. Whether the final graph should be of the pinwheel form. |
scattered |
Logical. Whether the final graph should be of the scatter form. |
lengths |
Logical. Whether or not to show a dashed line connecting the 'focus' kin to illustrate overall distance of dispersal. |
lengthlabs |
Logical. Whether to show labels denoting distance of dispersal between focus kin. |
histogram |
Logical. Whether the final graph should be of the histogram form. |
binwidth |
Numeric. Binwidth for histogram or freqpoly. |
freqpoly |
Logical. Whether the final graph should be of the freqpoly form. |
Returns a ggplot object for graphing.
Other simgraph:
simgraph_data()
simdata <- simgraph_data() simgraph_graph(simdata)
simdata <- simgraph_data() simgraph_graph(simdata)
KinPairSimulation
objectAccess or assign simulation type of KinPairSimulation
object
simtype(x) simtype(x) <- value ## S4 method for signature 'KinPairSimulation' simtype(x)
simtype(x) simtype(x) <- value ## S4 method for signature 'KinPairSimulation' simtype(x)
x |
object of class |
value |
new value to assign |
KinPairSimulation |
object of class KinPairSimulation |
character
the kind of simulation stored in the object (simple or composite)
returns a modified object of relevant class
character
the kind of simulation stored in the object (simple or composite)
simtype(KinPairSimulation)
:
Other kpsmethods:
access_sigmas
,
filter_methods
,
kernelshape()
,
kerneltype()
Simulates intergenerational dispersal made up of composite dispersal stages in a species with a defined breeding and dispersal structure similar to that of Ae. aegypti - i.e. with initial, breeding, gravid & ovipositional dispersal phases, approximately non-overlapping life cycles, and defined sampling points.
simulate_kindist_composite( nsims = 100, initsigma = 100, breedsigma = 50, gravsigma = 50, ovisigma = 25, dims = 100, method = "Gaussian", kinship = "FS", lifestage = "immature", shape = 0.5 )
simulate_kindist_composite( nsims = 100, initsigma = 100, breedsigma = 50, gravsigma = 50, ovisigma = 25, dims = 100, method = "Gaussian", kinship = "FS", lifestage = "immature", shape = 0.5 )
nsims |
(integer) - number of pairs to simulate |
initsigma |
(numeric) - size of pre-breeding (axial) sigma |
breedsigma |
(numeric) - size of breeding (axial) sigma |
gravsigma |
(numeric) - size of post-breeding (axial) sigma |
ovisigma |
(numeric) - size of oviposition (axial) sigma |
dims |
(numeric) - length of sides of (square) simulated site area |
method |
(character) - kernel shape to use: either 'Gaussian', 'Laplace' or 'vgamma' (variance-gamma) |
kinship |
(character)- kin category to simulate: one of PO, FS, HS, AV, GG, HAV, GGG, 1C, 1C1, 2C, GAV, HGAV, H1C H1C1 or H2C |
lifestage |
(character) lifestage at sample collection: either 'immature' or 'ovipositional' |
shape |
(numeric) - value of shape parameter to use with 'vgamma' method. Default 0.5. Must be > 0. Increment towards zero for increasingly heavy-tailed (leptokurtic) dispersal |
This function is one of a family of functions that implement the core intergenerational dispersal simulations
contained in the kindisperse
package. Each of these functions proceeds by the following steps:
identify the pedigree relationship, dispersal phase (FS, HS & PO) and sampling stage that must be generated;
randomly assign a coordinate position to the 'root' individual within the pedigree (i.e. last common ancestor of the dyad, inclusive);
'disperse' both pathways from this root position via the appropriately defined phase dispersal (additively via random draws from the underlying statistical model, defined by an axial standard deviation - sigma);
further disperse both phased descendant branches according to the number of realised breeding dispersal cycles contained in the defining pedigree (additively via random draws from the chosen underlying statistical model);
add displacement caused by dispersal before the sampling point in a similar manner to above, defining the final positions of the sampled dispersed kin dyads;
calculating geographical distances between the resulting dyads.
These simulation functions operate under an additive variance framework: all individual dispersal events are modeled as random
draws from a bivariate probability distribution defined by an axial standard deviation sigma
and (sometimes) a shape
parameter. At present, three such distributions are included as options accessible with the method
parameter: the
bivariate normal distribution 'Gaussian
', the bivariate Laplace distribution 'Laplace
', and the bivariate
variance-gamma distribution 'vgamma
'. The Gaussian
(normal) distribution enables easy compatibility with the
framework under which much population genetic & dispersal theory (isolation by distance, neighbourhoods, etc.) have been
developed. The Laplace
distribution is a multivariate adaptation of the (positive) exponential distribution, and
represents a more 'fat-tailed' (leptokurtic) disperal situation than Gaussian. The vgamma
distribution is a mixture
distribution formed by mixing the gamma distribution with the bivariate normal distribution. The flexibility of this
distribution's shape
parameter enables us to model arbitrarily leptokurtic dispesal kernels, providing a helpful way
to examine the impacts of (e.g.) long distance dispersal on the overall disperal distribution and sampling decisions. A
vgamma
distribution with shape parameter equal to 1 reduces to the bivariate Laplace distribution. As shape approaches
infinity, the vgamma
distribution approaches the bivariate normal distribution. As shape approaches zero, the distribution
becomes increasingly leptokurtic.
The simulate_kindist_composite()
function is designed to enable modeling of the composite dispersal events that occur
within the breeding cycle of an organism, and enables the separate treatment of the PO, FS
, and HS
phases (where, for example, the final distributions of full and half siblings are different in contexts where males mate
with multiple females but females primarily carry the offspring of one male). This function has been designed primarily in the
context of modelling dispersal in the mosquito Ae. aegypti; parameter names and the structure of kinship phases
reflect a single-generational breeding organism with an initial dispersal phase, a mating phase (where HS individuals branch),
a gravid phase, and an oviposition phase (where FS individuals branch). The sampling options ('immature' & 'ovipositional')
also reflect common mosquito trapping methods (i.e. ovitraps & gravitraps) which both target individuals dispersing in the
defined oviposition phase. This function should be easily adaptable to a vast number of other animals, especially insects, where
breeding occurs in one generation and parameters such as this hold. For slightly more complex scenarios (multiple breeding cycles,
differing sample points, more or less dispersal components making up a lifespan, different FS/HS branchpoints, etc.), the
enhanced capabilities of the simulate_kindist_custom
function may be required.
Following simulation, the results are returned as an object of the specially defined package class KinPairSimulation
,
which stores the simulation results along with information about all simulation parameters, and can be further passed to
sample filtering & dispersal estimation functions.
returns an object of class KinPairSimulation
containing simulation details and a tibble (tab) of simulation values
Other simulate_kindist:
simulate_kindist_custom()
,
simulate_kindist_simple()
simulate_kindist_composite(nsims = 100) simulate_kindist_composite( nsims = 10000, initsigma = 20, breedsigma = 30, gravsigma = 30, ovisigma = 12, dims = 500, method = "Laplace", kinship = "1C", lifestage = "immature" )
simulate_kindist_composite(nsims = 100) simulate_kindist_composite( nsims = 10000, initsigma = 20, breedsigma = 30, gravsigma = 30, ovisigma = 12, dims = 500, method = "Laplace", kinship = "1C", lifestage = "immature" )
Simulates intergenerational dispersal in a species defined by multiple dispersal components across the breeding cycle, with
dispersal, breeding & sampling & basic generational structure custom-defined by a DispersalModel
object.
simulate_kindist_custom( nsims = 100, model = dispersal_model(init = 100, breed = 50, grav = 50, ovi = 25, .FS = "ovi", .HS = "breed"), dims = 100, method = "Gaussian", kinship = "FS", cycle = 0, shape = 0.5 )
simulate_kindist_custom( nsims = 100, model = dispersal_model(init = 100, breed = 50, grav = 50, ovi = 25, .FS = "ovi", .HS = "breed"), dims = 100, method = "Gaussian", kinship = "FS", cycle = 0, shape = 0.5 )
nsims |
(integer) - number of pairs to simulate |
model |
(object of class |
dims |
(numeric) - length of sides of (square) simulated site area |
method |
(character) - kernel shape to use: either 'Gaussian', 'Laplace' or 'vgamma' (variance-gamma) |
kinship |
(character)- kin category to simulate: one of PO, FS, HS, AV, GG, HAV, GGG, 1C, 1C1, 2C, GAV, HGAV, H1C H1C1 or H2C |
cycle |
(numeric) - breeding cycle number(s) of dispersed kin to be modeled. Must be a integer equal to or greater than -1, (-1, 0, 1, 2, ...)
or vector of two such integers. Represents the number of complete breeding cycles each simulated individual has undergone before the sampling point,
where the time between birth and first reproduction is coded as '0', that between first and second reproduction '1', etc. (default 0).
If |
shape |
(numeric) - value of shape parameter to use with 'vgamma' method. Default 0.5. Must be > 0. Increment towards zero for increasingly heavy-tailed (leptokurtic) dispersal |
This function is one of a family of functions that implement the core intergenerational dispersal simulations
contained in the kindisperse
package. Each of these functions proceeds by the following steps:
identify the pedigree relationship, dispersal phase (FS, HS & PO) and sampling stage that must be generated;
randomly assign a coordinate position to the 'root' individual within the pedigree (i.e. last common ancestor of the dyad, inclusive);
'disperse' both pathways from this root position via the appropriately defined phase dispersal (additively via random draws from the underlying statistical model, defined by an axial standard deviation - sigma);
further disperse both phased descendant branches according to the number of realised breeding dispersal cycles contained in the defining pedigree (additively via random draws from the chosen underlying statistical model);
add displacement caused by dispersal before the sampling point in a similar manner to above, defining the final positions of the sampled dispersed kin dyads;
calculating geographical distances between the resulting dyads.
These simulation functions operate under an additive variance framework: all individual dispersal events are modeled as random
draws from a bivariate probability distribution defined by an axial standard deviation sigma
and (sometimes) a shape
parameter. At present, three such distributions are included as options accessible with the method
parameter: the
bivariate normal distribution 'Gaussian
', the bivariate Laplace distribution 'Laplace
', and the bivariate
variance-gamma distribution 'vgamma
'. The Gaussian
(normal) distribution enables easy compatibility with the
framework under which much population genetic & dispersal theory (isolation by distance, neighbourhoods, etc.) have been
developed. The Laplace
distribution is a multivariate adaptation of the (positive) exponential distribution, and
represents a more 'fat-tailed' (leptokurtic) disperal situation than Gaussian. The vgamma
distribution is a mixture
distribution formed by mixing the gamma distribution with the bivariate normal distribution. The flexibility of this
distribution's shape
parameter enables us to model arbitrarily leptokurtic dispesal kernels, providing a helpful way
to examine the impacts of (e.g.) long distance dispersal on the overall disperal distribution and sampling decisions. A
vgamma
distribution with shape parameter equal to 1 reduces to the bivariate Laplace distribution. As shape approaches
infinity, the vgamma
distribution approaches the bivariate normal distribution. As shape approaches zero, the distribution
becomes increasingly leptokurtic.
The simulate_kindist_custom()
function is designed to enable modeling of the composite dispersal events that occur
within the breeding cycle of an organism, and enables the separate treatment of the PO, FS
, and HS
phases in situations where the breeding and dispersal cycle of an organism is (somewhat more complex that that
encountered in organisms such as mosquitoes (i.e. single-generational breeding organisms with defined sampling
points). This function relies on a custom dispersal model of class DispersalModel
defined via parameter
model
to supply organism-specific information about dispersal stages (with axial sigmas), FS & HS branch points, and
the dispersal stage at which sampling occurs. Via this model object (or overridden by the cycle
parameter) you can
also define the number of breeding cycles each final individual within the close-kin dyad has passed through before sampling.
This is defined as a length one or two non-negative integer (where a length-one integer of value a is converted to a length
two integer of value c(a, a)), where the first integer defines the number of life cycles passed through by the 'senior'
pedigree member of the dyad, and the second the number passed through by the 'junior' member (so the GG phase has a grandparent
as senior, the grandchild as junior, etc. (in practice this distinction is unimportant for dyads). A cycle number of 0
references an individual that hasn't lived through an entire breeding cycle (sampling phase to sampling phase) before being
sampled. A value of 1 references an individual that has lived through one such cycle (e.g. a female entering her second breeding
season, an ovipositing mosquito (where the oviposition dispersal stage overlaps with the larval dispersal stage)). A value of
2 references two such cycles, etc. As all cycles are considered equivalent in the current formulation of this model (whether
an individual enters the cycle as a juvenile or as an adult) care must be taken in applying this system to species where the
dispersal behaviour of a second cycle individual (i.e. adult) is likely to be substantially different to that of a first cycle
individual (often an immature individual).
This function can only handle one kinship pairing & dispersal mode in the one simulation: where multiple dispersal pathways lead to the same kinship outcome, each pathway should be simulated separately, and the resulting distributions combined subsequently.
Following simulation, the results are returned as an object of the specially defined package class KinPairSimulation
,
which stores the simulation results along with information about all simulation parameters, and can be further passed to
sample filtering & dispersal estimation functions.
returns an object of class KinPairSimulation
containing simulation details and a tibble (tab) of simulation values
Other simulate_kindist:
simulate_kindist_composite()
,
simulate_kindist_simple()
custom_dispersal_model <- dispersal_model(a = 10, b = 25, .FS = "b", .HS = "a", .sampling_stage = "b") simulate_kindist_custom(nsims = 100, model = custom_dispersal_model, cycle = c(0, 1), kinship = "FS")
custom_dispersal_model <- dispersal_model(a = 10, b = 25, .FS = "b", .HS = "a", .sampling_stage = "b") simulate_kindist_custom(nsims = 100, model = custom_dispersal_model, cycle = c(0, 1), kinship = "FS")
Simulates intergenerational dispersal defined by a simple dispersal sigma (covering the entire lifecycle) and ignoring phase
differences between full & half sibling dispersal categories. Returns an object of class KinPairSimulation
simulate_kindist_simple( nsims = 100, sigma = 125, dims = 100, method = "Gaussian", kinship = "PO", lifestage = "immature", shape = 0.5 )
simulate_kindist_simple( nsims = 100, sigma = 125, dims = 100, method = "Gaussian", kinship = "PO", lifestage = "immature", shape = 0.5 )
nsims |
(integer) - number of pairs to simulate |
sigma |
(numeric) - size of simple (axial) sigma |
dims |
(numeric) - length of sides of (square) simulated site area |
method |
(character) - kernel shape to use: either 'Gaussian', 'Laplace' or 'vgamma' (variance-gamma) |
kinship |
(character)- kin category to simulate: one of PO, FS, HS, AV, GG, HAV, GGG, 1C, 1C1, 2C, GAV, HGAV, H1C or H2C |
lifestage |
(lifestage) lifestage at sample collection: either 'immature' or 'ovipositional' |
shape |
(numeric) - value of shape parameter to use with 'vgamma' method. Default 0.5. Must be > 0. Increment towards zero for increasingly heavy-tailed (leptokurtic) dispersal |
This function is one of a family of functions that implement the core intergenerational dispersal simulations
contained in the kindisperse
package. Each of these functions proceeds by the following steps:
identify the pedigree relationship, dispersal phase (FS, HS & PO) and sampling stage that must be generated;
randomly assign a coordinate position to the 'root' individual within the pedigree (i.e. last common ancestor of the dyad, inclusive);
'disperse' both pathways from this root position via the appropriately defined phase dispersal (additively via random draws from the underlying statistical model, defined by an axial standard deviation - sigma);
further disperse both phased descendant branches according to the number of realised breeding dispersal cycles contained in the defining pedigree (additively via random draws from the chosen underlying statistical model);
add displacement caused by dispersal before the sampling point in a similar manner to above, defining the final positions of the sampled dispersed kin dyads;
calculating geographical distances between the resulting dyads.
These simulation functions operate under an additive variance framework: all individual dispersal events are modeled as random
draws from a bivariate probability distribution defined by an axial standard deviation sigma
and (sometimes) a shape
parameter. At present, three such distributions are included as options accessible with the method
parameter: the
bivariate normal distribution 'Gaussian
', the bivariate Laplace distribution 'Laplace
', and the bivariate
variance-gamma distribution 'vgamma
'. The Gaussian
(normal) distribution enables easy compatibility with the
framework under which much population genetic & dispersal theory (isolation by distance, neighbourhoods, etc.) have been
developed. The Laplace
distribution is a multivariate adaptation of the (positive) exponential distribution, and
represents a more 'fat-tailed' (leptokurtic) disperal situation than Gaussian. The vgamma
distribution is a mixture
distribution formed by mixing the gamma distribution with the bivariate normal distribution. The flexibility of this
distribution's shape
parameter enables us to model arbitrarily leptokurtic dispesal kernels, providing a helpful way
to examine the impacts of (e.g.) long distance dispersal on the overall disperal distribution and sampling decisions. A
vgamma
distribution with shape parameter equal to 1 reduces to the bivariate Laplace distribution. As shape approaches
infinity, the vgamma
distribution approaches the bivariate normal distribution. As shape approaches zero, the distribution
becomes increasingly leptokurtic.
The simulate_kindist_simple()
function is the most basic of the simulation functions, ignoring all information about
dispersal phase and treating dispersal with a single sigma corresponding to the entire lifecycle to breeding of the
dispersed individuals. It is useful for exploring simple intergenerational dispersal in a stripped back context; for many
typical contexts involving complex dispersal across different phases of the breeding cycle, the other dispersal simulation
functions would be more suitable.
Following simulation, the results are returned as an object of the specially defined package class KinPairSimulation
,
which stores the simulation results along with information about all simulation parameters, and can be further passed to
sample filtering & dispersal estimation functions.
returns an object of class \code{\link{KinPairSimulation}} containing simulation details and a \code{tibble} (tab) of simulation values
Other simulate_kindist:
simulate_kindist_composite()
,
simulate_kindist_custom()
test <- simulate_kindist_simple(nsims = 10, sigma = 50, dims = 1000, method = "Laplace") simulate_kindist_simple(nsims = 10000, sigma = 75, kinship = "PO", lifestage = "ovipositional")
test <- simulate_kindist_simple(nsims = 10, sigma = 50, dims = 1000, method = "Laplace") simulate_kindist_simple(nsims = 10000, sigma = 75, kinship = "PO", lifestage = "ovipositional")
DispersalModel
object.Access breeding cycle stages of DispersalModel
object.
stages(x) ## S4 method for signature 'DispersalModel' stages(x)
stages(x) ## S4 method for signature 'DispersalModel' stages(x)
x |
object of class |
DispersalModel |
object of class |
character
ordered vector of custom lifestages contained in the object
stages(DispersalModel)
:
.tsv
and converts to KinPairData
objectThis function is part of suite of functions handling file import/export for kinship dispersal objects.
.csv
& .tsv
reading functions at minimum require the .delim file to contain a column titled 'distance' containing distances
between kin pairs. It can optionally contain a column of kinship values 'kinship' as well as a column of lifestage values 'lifestage'.
If the file contains more than one value in the kinship or lifestage columns (e.g. bot 'FS' and 'HS') - the corresponding function
parameter must be set to pick a corresponding subset of dispersed pairs. where parameters are set in the absence of file columns,
these values are assigned to the returned KinPairData
object.
tsv_to_kinpair(file, kinship = NULL, lifestage = NULL, ...)
tsv_to_kinpair(file, kinship = NULL, lifestage = NULL, ...)
file |
The file path to read from |
kinship |
character. kin category to assign or extract from data. one of PO, FS, HS, AV, GG, HAV, GGG, 1C, 1C1, 2C, GAV, HGAV, H1C , H1C1 or H2C |
lifestage |
character. lifestage to assign or extract from data. one of 'unknown', 'immature' or 'ovipositional'. |
... |
additional arguments to pass to |
Returns object of class KinPairData
Other import_functions:
csv_to_kinpair()
,
df_to_kinpair()
,
read_kindata()
,
vector_to_kinpair()
KinPairData
Object (clear slot from appdata environment)This function is part of a suite of functions handling the interface between the kindisperse app & R
package. Due to how shiny's interactive programming works, ordinary objects are not visible to the reactive functions
embedded in the app. The solution implemented here is to construct a custom environment, env_appdata
, that is
accessible within the app and outside of it.
When called, this function clears any objects with names found in the vector nms
from the app interface
environment, keeping it from becoming over-cluttered & taking up space.
unmount_appdata(nms)
unmount_appdata(nms)
nms |
A character vector of names of objects to unmount from the appdata environment |
No return value, called for side effects
Other app_ports:
display_appdata()
,
mount_appdata()
,
reset_appdata()
,
reset_tempdata()
,
retrieve_appdata()
,
retrieve_tempdata()
,
retrieveall_appdata()
mount_appdata(kin_pair_data(), "mydata") unmount_appdata("mydata")
mount_appdata(kin_pair_data(), "mydata") unmount_appdata("mydata")
KinPairData
classFunction takes at minimum a (numeric) vector of distances between related kinpairs, and
returns a KinPairData
object. Optional parameters can assign kinship and lifestage values to the
returned object.
vector_to_kinpair(vect, kinship = NULL, lifestage = NULL)
vector_to_kinpair(vect, kinship = NULL, lifestage = NULL)
vect |
vector of kinpair distances |
kinship |
character or character vector containing kinship categories of kinpairs |
lifestage |
character or character vector containing lifestages of kinpairs |
returns valid KinPairData
object.
Other import_functions:
csv_to_kinpair()
,
df_to_kinpair()
,
read_kindata()
,
tsv_to_kinpair()
vector_to_kinpair(1:10, "FS", "immature")
vector_to_kinpair(1:10, "FS", "immature")
Access life stage at which individual is first visible to sampling (i.e. from which breeding cycles are calculated)
visible_stage(x) ## S4 method for signature 'DispersalModel' visible_stage(x)
visible_stage(x) ## S4 method for signature 'DispersalModel' visible_stage(x)
x |
object of class |
DispersalModel |
object of class |
character
stage in life cycle at which an individual is assumed to be sampled by default rather than its parent
(anchors the breeding cycle system)
visible_stage(DispersalModel)
:
KinPairData
or KinPairSimulation
object in .kindata
formatThis function is part of suite of functions handling file import/export for kinship dispersal objects.
Writing to the custom .kindata
format enables complete preservation of KinPairData
& KinPairSimulation
formats
without any loss of class attributes or metadata - ideal for saving simulation data that is intended for further in-package
processing with kindisperse.
write_kindata(x, file)
write_kindata(x, file)
x |
Object of class |
file |
The file path to write to. If is doesn't end it ' |
Invisibly returns the initial object
Other export_functions:
kinpair_to_csv()
,
kinpair_to_tibble()
,
kinpair_to_tsv()