compute_posterior(
y,
fs,
prior = NULL,
MOIs = NULL,
return.RG = FALSE,
return.logp = FALSE,
progress.bar = TRUE
)List of lists encoding allelic data. The outer list contains
episodes in chronological order. The inner list contains named
markers per episode. Marker names must be consistent across episodes. NA
indicates missing marker data; otherwise, specify a per-marker
vector of distinct alleles detected (presently, compute_posterior() does
not support data on the proportional abundance of detected alleles).
Repeat alleles and NA entries within allelic vectors are ignored.
Allele names are arbitrary, allowing for different data types, but must
correspond with frequency names.
List of per-marker allele frequency vectors, with names matching
marker names in y. Per-marker alleles frequencies mut contain one
frequency per named allele, with names matching alleles in y. Per-marker
frequencies must sum to one.
Matrix of prior probabilities of recurrence states per episode,
with rows as episodes in chronological order, and columns named "C", "L",
and "I" for recrudescence, relapse and reinfection, respectively. Row names
are ignored. If NULL (default), per-episode recurrence states are assumed
equally likely a priori.
Vector of per-episode multiplicities of infection (MOIs); because
the Pv3Rs model assumes no genotyping errors, MOIs must be greater than
or equal to the most parsimonious MOI estimates compatible with the data;
see determine_MOIs(y). These are the estimates used when
MOIs = NULL (default).
Logical; returns the relationship graphs
(default FALSE). Automatically set to TRUE if return.logp = TRUE.
Logical; returns the log-likelihood for each relationship
graph (default FALSE). Setting TRUE disables permutation symmetry
optimisation and thus increases runtime, especially when MOIs are large.
Does not affect the output of the posterior probabilities; for an an
example of permutation symmetry, see Exploration of relationship graphs in
{demonstrate-usage}{exploration-of-relationship-graphs}{Demonstrate Pv3Rs usage}.
progress.barLogical; show progress bars (default TRUE).
Note that the progress bar may update non-uniformly.
List containing:
margMatrix of marginal posterior probabilities for each recurrence, with rows as recurrences and columns as "C" (recrudescence), "L" (relapse), and "I" (reinfection). Each marginal probability sums over a subset of joint probabilities. For example, the marginal probability of "C" at the first of two recurrences sums over the joint probabilities of "CC", "CL", and "CI".
jointVector of joint posterior probabilities for each recurrence state sequence; within a sequence "C", "L", and "I" are used as above.
RGsList of lists encoding relationship graphs; returned only if
return.RG = TRUE (default FALSE), and with log-likelihoods if
return.logp = TRUE (default FALSE). A relationship graph
encoded as a list can be converted into a igraph object using
RG_to_igraph and thus plotted using
plot_RG. For more details on relationship graphs, see
enumerate_RGs.
Computes per-person posterior probabilities of P. vivax recurrence states —
recrudescence, relapse, reinfection — using per-person genetic data on two
or more episodes. For usage, see Examples below and{demonstrate-usage}{}{Demonstrate Pv3Rs usage}.
For a more complete understanding of compute_posterior output, see
Understand posterior probabilities.Note: The progress bar may increment non-uniformly (see
Details); it may appear stuck when computations are ongoing.compute_posterior() computes posterior probabilities proportional to
the likelihood multiplied by the prior. The likelihood sums over:
ways to phase allelic data onto haploid genotypes
graphs of relationships between haploid genotypes
ways to partition alleles into clusters of identity-by-descent
enumerate_RGs. For each relationship graph, the model sums over
all possible identity-by-descent partitions. Because some graphs are
compatible with more partitions than others, the log p(Y|RG) progress bar may
advance non-uniformly. We do not recommend running `compute_posterior() when
the total genotype count (sum of MOIs) exceeds eight because there are too
many relationship graphs.Notable model assumptions and limitations:
All siblings are regular siblings
Recrudescent parasites derive only from the immediately preceding episode
Recrudescence, relapse and reinfection are mutually exclusive
Undetected alleles, genotyping errors, and de novo mutations are not modelled
Population structure and various other complexities that confound molecular correction are not modelled