Package phase
Class SamplePhase
- java.lang.Object
-
- phase.SamplePhase
-
public final class SamplePhase extends java.lang.ObjectEach instance of class
SamplePhasestores 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
SamplePhaseare not thread-safe.
-
-
Constructor Summary
Constructors Constructor Description SamplePhase(Markers markers, DoubleArray genPos, int[] hap1, int[] hap2, IntArray unphased, IntArray missing)Constructs a newSamplePhaseinstance from the specified data.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intallele1(int marker)Returns the allele on the first haplotype for the specified marker.intallele2(int marker)Returns the allele on the second haplotype for the specified marker.int[]clustEnds()Returns the (exclusive) end marker indices of each marker cluster.voidgetHaps(BitArray hap1, BitArray hap2)Copies the stored haplotypes to the specifiedBitListobjectsBitArrayhap1()Returns the first haplotype.BitArrayhap2()Returns the second haplotype.Markersmarkers()Returns the list of markers.IntArraymissing()Returns a list of marker indices in increasing order for which the genotype is missing.voidsetAllele1(int marker, int allele)Sets the allele on the first haplotype for the specified marker to the specified allelevoidsetAllele2(int marker, int allele)Sets the allele on the second haplotype for the specified marker to the specified allelevoidsetUnphased(IntArray unphased)Sets the list of markers whose genotype phase with respect to the preceding non-missing heterozygote genotype is unknown.voidswapHaps(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.IntArrayunphased()Returns a list of marker indices in increasing order whose genotype phase with respect to the preceding non-missing heterozygote genotype is unknown.
-
-
-
Constructor Detail
-
SamplePhase
public SamplePhase(Markers markers, DoubleArray genPos, int[] hap1, int[] hap2, IntArray unphased, IntArray missing)
Constructs a newSamplePhaseinstance 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:
java.lang.IllegalArgumentException- ifgenPos.size() != markers.nMarkers()java.lang.IllegalArgumentException- ifhap1.length != markers.nMarkers() || hap2.length != markers.nMarkers()java.lang.IllegalArgumentException- if the specifiedunphasedormissinglist is not a strictly increasing list of marker indices between 0 (inclusive) andmarkers.nMarkers()(exclusive)java.lang.NullPointerException- if any argument isnull
-
-
Method Detail
-
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
public Markers markers()
Returns the list of markers.- Returns:
- the list of markers
-
missing
public IntArray 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
public IntArray 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
public void setUnphased(IntArray unphased)
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:
java.lang.IllegalArgumentException- if the specified list or marker indices is not a strictly increasing list of indices between 0 (inclusive) andthis.markers().nMarkers()(exclusive)java.lang.NullPointerException- ifunphased == null
-
getHaps
public void getHaps(BitArray hap1, BitArray hap2)
Copies the stored haplotypes to the specifiedBitListobjects- Parameters:
hap1- aBitListin which the sample's first haplotype's alleles will be storedhap2- aBitListin which the sample's second haplotype's alleles will be stored- Throws:
java.lang.IllegalArgumentException- ifhap1.size() != this.markers().sumHaplotypeBits()java.lang.IllegalArgumentException- ifhap2.size()!= this.markers().sumHaplotypeBits()java.lang.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:
java.lang.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:
java.lang.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:
java.lang.IndexOutOfBoundsException- ifmarker < 0 || marker >= this.markers().nMarkers()java.lang.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:
java.lang.IndexOutOfBoundsException- ifmarker < 0 || marker >= this.markers().nMarkers()java.lang.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:
java.lang.IndexOutOfBoundsException- ifstart < 0 || start > end || start >= this.markers().nMarkers()
-
hap1
public BitArray hap1()
Returns the first haplotype. The haplotype is encoded with thethis.markers().allelesToBits()method.- Returns:
- the first haplotype
-
hap2
public BitArray hap2()
Returns the second haplotype. The haplotype is encoded with thethis.markers().allelesToBits()method.- Returns:
- the second haplotype
-
toBitLists
public static BitArray[] toBitLists(EstPhase estPhase)
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:
java.lang.NullPointerException- ifestPhase == null
-
-