ibdEstM {dcifer} | R Documentation |
Estimate Relatedness and a Number of Related Strains
Description
Estimates the number of related pairs of strains between two infections along with corresponding relatedness estimates and optional inference.
Usage
ibdEstM(
pair,
coi,
afreq,
Mmax = 6,
pval = FALSE,
confreg = FALSE,
llik = FALSE,
rnull = 0,
alpha = 0.05,
equalr = FALSE,
freqlog = FALSE,
nrs = c(1000, 100, 32, 16, 12, 10),
revals = NULL,
tol0 = 1e-09,
logrs = NULL,
nevals = NULL,
nloc = NULL
)
Arguments
pair |
a list of length two containing data for a pair of samples. |
coi |
a vector containing complexity of infection for each sample. |
afreq |
a list of allele frequencies. Each element of the list corresponds to a locus. |
Mmax |
a maximum number of related pairs of strains to evaluate over.
If greater than |
pval , confreg , llik |
logical values specifying if p-value, confidence
region, and log-likelihood for a range of |
rnull |
a null value of relatedness parameter for hypothesis testing
(needed if |
alpha |
significance level for a 1 - α confidence region. |
equalr |
a logical value. If |
freqlog |
a logical value indicating if |
nrs |
an integer vector where |
revals |
a list where |
tol0 |
a tolerance value for an estimate to be considered zero. |
logrs |
a list where |
nevals |
a vector where |
nloc |
the number of loci. |
Value
A named list if multiple output logical values are TRUE
- or a
vector if only rhat = TRUE
. The output includes:
a relatedness estimate (numeric vector of length corresponding to the estimated number of related pairs);
a p-value if
pval = TRUE
;parameter values from the grid in
revals
that are within the confidence region ifconfreg = TRUE
;log-likelihood values for the parameter grid in
revals
ifllik = TRUE
.
See Also
ibdPair
for estimates of relatedness between two
samples and ibdDat
for pairwise relatedness estimates within
a dataset or between two datasets.
Examples
coi <- getCOI(dsmp, lrank = 2) # estimate COI
afreq <- calcAfreq(dsmp, coi, tol = 1e-5) # estimate allele frequencies
# two samples
ipair <- c(21, 17)
# for higher COI: c(33, 5): COI = 5-6; c(37, 20): 4-3, c(41, 50): 5-4
Mmax <- min(coi[ipair])
# choose resolution of the grid for different M
nrs <- c(1e3, 1e2, 32, 16, 12, 10)[1:Mmax]
revals <- mapply(generateReval, 1:Mmax, nr = nrs)
(res1 <- ibdEstM(dsmp[ipair], coi[ipair], afreq, Mmax = Mmax, equalr = FALSE,
reval = revals))
(res2 <- ibdEstM(dsmp[ipair], coi[ipair], afreq, Mmax = Mmax, equalr = TRUE))
# number of related pairs of strains (M')
sum(res1 > 0)
sum(res2 > 0) # can be 0's