Package phase
Class SamplePhase
java.lang.Object
phase.SamplePhase
Each instance of class SamplePhase
stores an estimated haplotype
pair for a sample, the list of markers with missing genotypes for the sample,
a list of markers whose genotype phase with respect to the preceding
heterozygote genotype is considered to be uncertain for the sample, and
a set of marker clusters for the sample.
Instances of class SamplePhase
are not thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionSamplePhase
(Markers markers, DoubleArray genPos, int[] hap1, int[] hap2, IntArray unphased, IntArray missing) Constructs a newSamplePhase
instance from the specified data. -
Method Summary
Modifier and TypeMethodDescriptionint
allele1
(int marker) Returns the allele on the first haplotype for the specified marker.int
allele2
(int marker) Returns the allele on the second haplotype for the specified marker.int[]
Returns the (exclusive) end marker indices of each marker cluster.void
Copies the stored haplotypes to the specifiedBitList
objectshap1()
Returns the first haplotype.hap2()
Returns the second haplotype.markers()
Returns the list of markers.missing()
Returns a list of marker indices in increasing order for which the genotype is missing.void
setAllele1
(int marker, int allele) Sets the allele on the first haplotype for the specified marker to the specified allelevoid
setAllele2
(int marker, int allele) Sets the allele on the second haplotype for the specified marker to the specified allelevoid
setUnphased
(IntArray unphased) Sets the list of markers whose genotype phase with respect to the preceding non-missing heterozygote genotype is unknown.void
swapHaps
(int start, int end) Swaps the alleles of the two haplotypes in the specified range of markers.static BitArray[]
toBitLists
(EstPhase estPhase) Returns the current estimated phased genotypes.unphased()
Returns a list of marker indices in increasing order whose genotype phase with respect to the preceding non-missing heterozygote genotype is unknown.
-
Constructor Details
-
SamplePhase
public SamplePhase(Markers markers, DoubleArray genPos, int[] hap1, int[] hap2, IntArray unphased, IntArray missing) Constructs a newSamplePhase
instance from the specified data.- Parameters:
markers
- the list of markersgenPos
- the genetic positions of the specifed markershap1
- the list of alleles on the first haplotypehap2
- the list of alleles on the second haplotypeunphased
- the indices of markers whose genotype phase with respect to the preceding heterozygote is unknownmissing
- the indices of markers whose genotype is missing- Throws:
IllegalArgumentException
- ifgenPos.size() != markers.nMarkers()
IllegalArgumentException
- ifhap1.length != markers.nMarkers() || hap2.length != markers.nMarkers()
IllegalArgumentException
- if the specifiedunphased
ormissing
list is not a strictly increasing list of marker indices between 0 (inclusive) andmarkers.nMarkers()
(exclusive)NullPointerException
- if any argument isnull
-
-
Method Details
-
clustEnds
public int[] clustEnds()Returns the (exclusive) end marker indices of each marker cluster. The returned list is sorted in increasing order.- Returns:
- the (exclusive) end marker indices of each marker cluster
-
markers
Returns the list of markers.- Returns:
- the list of markers
-
missing
Returns a list of marker indices in increasing order for which the genotype is missing.- Returns:
- a list of marker indices in increasing order for which the genotype is missing
-
unphased
Returns a list of marker indices in increasing order whose genotype phase with respect to the preceding non-missing heterozygote genotype is unknown.- Returns:
- a list of markers indices in increasing order whose genotype phase with respect to the preceding non-missing heterozygote genotype is unknown
-
setUnphased
Sets the list of markers whose genotype phase with respect to the preceding non-missing heterozygote genotype is unknown.- Parameters:
unphased
- a list of markers whose genotype phase with respect to the preceding non-missing heterozygote genotype is unknown- Throws:
IllegalArgumentException
- if the specified list or marker indices is not a strictly increasing list of indices between 0 (inclusive) andthis.markers().nMarkers()
(exclusive)NullPointerException
- ifunphased == null
-
getHaps
Copies the stored haplotypes to the specifiedBitList
objects- Parameters:
hap1
- aBitList
in which the sample's first haplotype's alleles will be storedhap2
- aBitList
in which the sample's second haplotype's alleles will be stored- Throws:
IllegalArgumentException
- ifhap1.size() != this.markers().sumHaplotypeBits()
IllegalArgumentException
- ifhap2.size()!= this.markers().sumHaplotypeBits()
NullPointerException
- ifhap1 == null || hap2 == null
-
allele1
public int allele1(int marker) Returns the allele on the first haplotype for the specified marker.- Parameters:
marker
- the marker index- Returns:
- the allele on the first haplotype for the specified marker
- Throws:
IndexOutOfBoundsException
- ifmarker < 0 || marker >= this.markers().nMarkers()
-
allele2
public int allele2(int marker) Returns the allele on the second haplotype for the specified marker.- Parameters:
marker
- the marker index- Returns:
- the allele on the second haplotype for the specified marker
- Throws:
IndexOutOfBoundsException
- ifmarker < 0 || marker >= this.markers().nMarkers()
-
setAllele1
public void setAllele1(int marker, int allele) Sets the allele on the first haplotype for the specified marker to the specified allele- Parameters:
marker
- the marker indexallele
- the allele- Throws:
IndexOutOfBoundsException
- ifmarker < 0 || marker >= this.markers().nMarkers()
IndexOutOfBoundsException
- ifallele < 0 || allele >= this.markers().marker(marker).nAlleles()
-
setAllele2
public void setAllele2(int marker, int allele) Sets the allele on the second haplotype for the specified marker to the specified allele- Parameters:
marker
- the marker indexallele
- the allele- Throws:
IndexOutOfBoundsException
- ifmarker < 0 || marker >= this.markers().nMarkers()
IndexOutOfBoundsException
- ifallele < 0 || allele >= this.markers().marker(marker).nAlleles()
-
swapHaps
public void swapHaps(int start, int end) Swaps the alleles of the two haplotypes in the specified range of markers.- Parameters:
start
- the start marker index (inclusive)end
- the end marker index (exclusive)- Throws:
IndexOutOfBoundsException
- ifstart < 0 || start > end || start >= this.markers().nMarkers()
-
hap1
Returns the first haplotype. The haplotype is encoded with thethis.markers().allelesToBits()
method.- Returns:
- the first haplotype
-
hap2
Returns the second haplotype. The haplotype is encoded with thethis.markers().allelesToBits()
method.- Returns:
- the second haplotype
-
toBitLists
Returns the current estimated phased genotypes. This method converts column-major data into row-major data.- Parameters:
estPhase
- the current estimated phased genotypes for each target sample- Returns:
- the current estimated phased genotypes
- Throws:
NullPointerException
- ifestPhase == null
-