public class RecombSingleBaum extends java.lang.Object implements SingleBaumInterface
Class RestrictedSingleBaum
implements the Baum forward and
backward algorithms for a hidden Markov model (HMM) of an individual's
genotype data. The HMM transition probabilities model recent
genetic recombination by allowing jumps between states that are not
connected by a node.
Instances of class RestrictedSingleBaum
are not thread-safe.
Constructor and Description |
---|
RecombSingleBaum(SamplerData samplerData,
long seed,
int nSamplesPerIndividual,
boolean lowMem)
Creates a new
RestrictedSingleBaum 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[] gprobs)
Returns a list of
this.nSamplesPerIndividual() sampled
haplotype pairs for the specified individual. |
long |
seed()
Returns the initial random seed.
|
public RecombSingleBaum(SamplerData samplerData, long seed, int nSamplesPerIndividual, boolean lowMem)
RestrictedSingleBaum
instance from the specified
data.samplerData
- the analysis dataseed
- 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 nSamplesPerIndividual < 1
java.lang.NullPointerException
- if samplerData == 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[] gprobs)
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 indexgprobs
- a array to which posterior genotype probabilities
for the sample will be writtenthis.nSamplesPerIndividual()
sampled
haplotype pairs for the specified individual