Package phase
Class BasicPhaseStates
java.lang.Object
phase.BasicPhaseStates
Class BasicPhaseStates
has methods for constructing a Li and
Stephens HMM for a target haplotype or target sample.
Instances of BasicPhaseStates
are not thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionBasicPhaseStates
(PbwtPhaseIbs ibsHaps, int maxStates) Constructs a newBasicPhaseStates
object from the specified data. -
Method Summary
Modifier and TypeMethodDescriptionint
ibsStates
(int sample, byte[][][] nMismatches) Stores the Li and Stephens HMM for the specified target sample in the specified arrays.int
ibsStates
(MarkerCluster mc, List<int[]> refAtMissingGT, byte[][][] nMismatches) Stores the Li and Stephens HMM for the specified target sample in the specified arrays.ThenMismatches
parameter is an array of three two-dimensional arrays:nMismatches[0]
stores stores the allele mismatch data between the reference haplotypes and the haplotype composed of homozygous target genotypes,nMismatches[1]
stores the allele mismatch data between the reference haplotypes and the first target haplotype, andnMismatches[2]
stores the allele mismatch data between the reference haplotypes and the first target haplotype.int
Returns the maximum number of HMM states at a marker.int
nMarkers()
Returns the number of markers.int
Returns the number of target samples.
-
Constructor Details
-
BasicPhaseStates
Constructs a newBasicPhaseStates
object from the specified data.- Parameters:
ibsHaps
- the IBS haplotype segmentsmaxStates
- the maximum number of composite reference haplotypes that will be constructed- Throws:
IllegalArgumentException
- ifmaxStates < 1
NullPointerException
- ifibsHaps == null
-
-
Method Details
-
nTargSamples
public int nTargSamples()Returns the number of target samples.- Returns:
- the number of target samples
-
nMarkers
public int nMarkers()Returns the number of markers.- Returns:
- the number of markers
-
maxStates
public int maxStates()Returns the maximum number of HMM states at a marker.- Returns:
- the maximum number of HMM states at a marker
-
ibsStates
Stores the Li and Stephens HMM for the specified target sample in the specified arrays.ThenMismatches
parameter is an array of three two-dimensional arrays:nMismatches[0]
stores stores the allele mismatch data between the reference haplotypes and the haplotype composed of homozygous target genotypes,nMismatches[1]
stores the allele mismatch data between the reference haplotypes and the first target haplotype, andnMismatches[2]
stores the allele mismatch data between the reference haplotypes and the first target haplotype. Each two-dimensional array must have at leastmc.nClusters()
rows, and a column for each HMM state. An element of the two-dimensional array is 0 if the target and reference allele match and is 1 otherwise.- Parameters:
mc
- the marker clustersrefAtMissingGT
- a list of arrays in which HMM state alleles at markers for which one or both target haplotypes have a missing allelenMismatches
- arrays for storing present or absence of mismatches between target and reference alleles- Returns:
- the number of state alleles at each marker
- Throws:
IndexOutOfBoundsException
- ifsample < 0 || sample >= this.nTargSamples()
IndexOutOfBoundsException
- ifnMismatches.length < 3
IndexOutOfBoundsException
- if there existsj
such that0 < j && j < 3 && nMismatches[j].length < mc.nClusters()
IndexOutOfBoundsException
- if there existsj, m
such that(0 < j && j < 3 && 0 < m && m < mc.nClusters())
, andnMismatches[j][m].length
is less than the number of model states at markerm
IndexOutOfBoundsException
- ifmissAlleles.get(j)
is less than the number of model states for anyj
that indexes the missing genotypesNullPointerException
- if(samplePhase == null || mc == null || refAtMissingGT == null)
or if any array isnull
-
ibsStates
public int ibsStates(int sample, byte[][][] nMismatches) Stores the Li and Stephens HMM for the specified target sample in the specified arrays. The number of allele mismatches (0 or 1) betweenhap1[m]
andhap2[m]
for thej
-th state are stored innMismatchs[0][m][j]
andnMismatches[1][m][j]
respectively.- Parameters:
sample
- the target sample indexnMismatches
- an array of two two-dimensional arrays in which the number of allele mismatches with reference haplotypes for the first haplotype and the second haplotype will be stored- Returns:
- the number of state alleles at each marker
- Throws:
IndexOutOfBoundsException
- ifsample < 0 || sample >= this.nTargSamples()
IndexOutOfBoundsException
- ifnMismatches.length < 2
IndexOutOfBoundsException
- if there existsj
such that(0 < j && j < 2 && nMismatches[j].length < this.nMarkers())
IndexOutOfBoundsException
- if there existsj, m
such that(0 < j && j < 2 && 0 < m && m < this.nMarkers())
, andnMismatches[j][m].length
is less than the total number of model statesNullPointerException
- if any array isnull
-