Allocates the memory for and initializes a forward table.
Arguments
- pars
a
kalisParameters
object specifying the genetics parameters to be associated with this forward table. These parameters can be set up by using theParameters()
function.- from_recipient
first recipient haplotype included if creating a partial forward table. By default all are included from the first recipient haplotype. Haplotypes are indexed from 1.
- to_recipient
last recipient haplotype included if creating a partial forward table. By default all are included upto the last recipient haplotype. Haplotypes are indexed from 1.
Value
A specialized list of class kalisForwardTable
.
The elements of the forward table list are:
l
denotes the current variant position. 2147483647 indicates a newly created forward table which has not yet been propagated to any variant.
alpha
is a matrix of rescaled forward probabilities under the Li and Stephens HMM. Each column of
alpha
corresponds to an independent HMM such that \(\alpha^l_{ji}\) is proportional to the probability that haplotype \(j\) is copied by haplotype \(i\) at variant \(l\) and observing haplotype \(i\) from variant 1 up through variant \(l\).alpha.f
is a vector containing scaling constants needed to continue propagating the HMM (TODO: add ref please see kalis paper for details).
A kalisForwardTable
also carries with it a checksum key for the parameters pars
it was provided.
If one attempts to interact a kalisForwardTable
with a kalisBackwardTable
with mismatched parameters, an error will be thrown.
Details
MakeForwardTable
initializes a kalisForwardTable
object that will store the rescaled forward probabilities for each recipient haplotype.
Note: since all other haplotypes loaded by CacheHaplotypes()
into the kalis cache are taken as potential donor haplotypes, this table will be of size (total haplotypes in cache)x(number of recipients).
Also note that this table object is linked to a given set of Li and Stephens hidden Markov model parameters, created by Parameters()
, to ensure consistency for any given HMM run.
The returned kalisForwardTable
is ready to be propagated to a given target variant with the function Forward()
.
Since each column corresponds to an independent Li and Stephens hidden Markov model (ie for each recipient), it is possible to create a partial forward table object which corresponds to a subset of recipients using the from_recipient
and to_recipient
arguments.
See also
Forward()
to propagate the newly created kalisForwardTable
;
MakeBackwardTable()
to create a corresponding kalisBackwardTable
.
Examples
# Load the toy haplotype example and set toy parameters
data("SmallHaps")
data("SmallMap")
CacheHaplotypes(SmallHaps)
#> Warning: haplotypes already cached ... overwriting existing cache.
rho <- CalcRho(diff(SmallMap))
pars <- Parameters(rho)
# Create the forward table we want to propagate
fwd <- MakeForwardTable(pars)
fwd
#> Full Forward Table object for 300 haplotypes.
#> Newly created table, currently uninitialised to any variant (ready for Forward function next).
#> Memory consumed: 723.98 kB
# Now ready to run the HMM forward recursions with Forward() ...