public class SingleBaum extends java.lang.Object implements SingleBaumInterface
Class SingleBaum
implements the Baum forward and backward
algorithms for a hidden Markov model (HMM) of an individual's genotype data.
SingleBaum
are not thread-safe.Constructor and Description |
---|
SingleBaum(Dag dag,
GL gl,
long seed,
int nSamplesPerIndividual,
boolean lowMem)
Creates a new
SingleBaum instance from the specified data. |
Modifier and Type | Method and Description |
---|---|
Dag |
dag()
Returns the directed acyclic graph that determines the transition
probabilities.
|
GL |
gl()
Returns the emission probabilities.
|
int |
nSamplesPerIndividual()
Returns the number of haplotype pairs that are sampled for each
individual.
|
java.util.List<HapPair> |
randomSample(int sample)
Returns a list of
this.nSamplesPerIndividual() sampled
haplotype pairs for the specified individual. |
java.util.List<HapPair> |
randomSample(int sample,
double[] gtProbs)
Returns a list of
this.nSamplesPerIndividual() sampled
haplotype pairs for the specified individual. |
long |
seed()
Returns the initial random seed.
|
public SingleBaum(Dag dag, GL gl, long seed, int nSamplesPerIndividual, boolean lowMem)
SingleBaum
instance from the specified data.dag
- the directed acyclic graph that determines the
transition probabilitiesgl
- the emission probabilitiesseed
- the random seednSamplesPerIndividual
- the number of haplotype pairs that
will be sampled for each individuallowMem
- true
if a low memory algorithm should be used, and
false
otherwisejava.lang.IllegalArgumentException
- if
dag.markers().equals(gl.markers()) == false
java.lang.IllegalArgumentException
- if nSamplesPerIndividual < 1
java.lang.NullPointerException
- if dag == null || gl == null
public Dag dag()
SingleBaumInterface
dag
in interface SingleBaumInterface
public GL gl()
SingleBaumInterface
gl
in interface SingleBaumInterface
public int nSamplesPerIndividual()
SingleBaumInterface
nSamplesPerIndividual
in interface SingleBaumInterface
public long seed()
SingleBaumInterface
seed
in interface SingleBaumInterface
public java.util.List<HapPair> randomSample(int sample)
SingleBaumInterface
Returns a list of this.nSamplesPerIndividual()
sampled
haplotype pairs for the specified individual. Haplotype pairs are
sampled conditional on the HMM with transition probabilities
determined by this.dag()
and emission probabilities
determined by this.gl()
.
The contract for this method is unspecified if no haplotype pair is consistent with the HMM.
randomSample
in interface SingleBaumInterface
sample
- a sample indexthis.nSamplesPerIndividual()
sampled
haplotype pairs for the specified individualpublic java.util.List<HapPair> randomSample(int sample, double[] gtProbs)
SingleBaumInterface
Returns a list of this.nSamplesPerIndividual()
sampled
haplotype pairs for the specified individual. Haplotype pairs are
sampled conditional on the HMM with transition probabilities determined
by this.dag()
and emission probabilities determined by
this.gl()
. Posterior genotype probabilities are written to
the specified array. The posterior probability of the j
-th
genotype for the k
-th marker is stored at index
gl.markers().sumGenotypes(k) + j
in the gtProbs
array.
The contract for this method is unspecified if no haplotype pair is consistent with the HMM.
randomSample
in interface SingleBaumInterface
sample
- the sample indexgtProbs
- a array to which posterior genotype probabilities
for the sample will be writtenthis.nSamplesPerIndividual()
sampled
haplotype pairs for the specified individual