Package phase
Class EstPhase
- java.lang.Object
-
- phase.EstPhase
-
public final class EstPhase extends java.lang.ObjectClass
EstPhasestores haplotype pairs, missing genotypes, and unphased, nonmissing heteroygote genotypes for a list of samples.Instances of class
EstPhaseare thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classEstPhase.HapsGT
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IntArraygetMissing(int sample)Returns a list of marker indices in increasing order for which the specified sample has a missing genotype.voidgetMissing(int sample, boolean[] isMissing)Sets thek-th entry of the specifiedisMissingarray totrueif the specified sample's genotype at thek-th marker is missing, and tofalseotherwise.IntArraygetUnphasedHets(int sample)Returns a list of marker indices in increasing order for which the specified sample has an unphased, non-missing heterozygote genotype.voidgetUnphasedHets(int sample, boolean[] isUnphased)Sets thek-th entry of the specifiedisUnphasedarray totrueif the specified sample's genotype at thek-th marker is an unphased, nonmissing heterozygote, and tofalseotherwise.EstPhase.HapsGThapsGT()booleanhasMissingGT(int sample)Returnstrueif the specified sample has a missing genotype, and returnsfalseotherwise.booleanhasUnphasedHets(int sample)Returnstrueif the specified sample has an unphased heterozygote genotype, and returnsfalseotherwise.Markersmarkers()Returns the list of markers.intnMarkers()Returns the number of markers.intnSamples()Returns the number of samples.intnUnphasedHets(int sample)Returns the number of unphased, non-missing heterozygote genotypes.Samplessamples()Returns the list of target samples.voidsetHapPair(int sample, int[] hap1, int[] hap2)Sets the haplotype pair for the specified sample to the specified haplotypes.voidsetHapsWithMaskedMissingAlleles(int sample, int[] hap1, int[] hap2)Sets thek-th element of the specifiedhap1andhap2arrays to the specified sample's phased genotype at thek-th marker if the genotype is nonmissing, and sets thek-th element ofhap1andhap2to-1otherwise.voidsetUnphasedHets(int sample, IntArray newUnphased)Sets the array with marker indices of unphased, nonmissing heterozygote genotypes to the specified array.
-
-
-
Constructor Detail
-
EstPhase
public EstPhase(GT gt, java.util.List<LongArray> haps)
Constructs a newEstPhaseinstance from the specified data. The haplotypes for thek-th sample must be stored in entrieshaps.get(2*k} andhaps.get(2*k + 1)- Parameters:
gt- the observed genotype datahaps- the initial haplotypes for each sample- Throws:
java.lang.IllegalArgumentException- ifgt.nSamples() != hapPairs.nSamples()java.lang.IllegalArgumentException- if(hapPairs.get(s).idIndex!= this.gt().samples().idIndex(s))for anyssatisfying(0 <= s && s < gt.nSamples())java.lang.NullPointerException- ifgt == null || hapPairs == nulljava.lang.NullPointerException- if(hapPairs.get(j) == null)for anyjsatisfying(0 <= j && j < hapPairs.size())
-
-
Method Detail
-
nSamples
public int nSamples()
Returns the number of samples.- Returns:
- the number of samples
-
samples
public Samples samples()
Returns the list of target samples.- Returns:
- the list of target samples
-
nMarkers
public int nMarkers()
Returns the number of markers.- Returns:
- the number of markers
-
markers
public Markers markers()
Returns the list of markers.- Returns:
- the list of markers
-
hasUnphasedHets
public boolean hasUnphasedHets(int sample)
Returnstrueif the specified sample has an unphased heterozygote genotype, and returnsfalseotherwise.- Parameters:
sample- the sample index- Returns:
trueif the specified sample has an unphased heterozygote genotype- Throws:
java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()
-
nUnphasedHets
public int nUnphasedHets(int sample)
Returns the number of unphased, non-missing heterozygote genotypes.- Parameters:
sample- the sample index- Returns:
- the number of unphased, non-missing heterozygote genotypes
- Throws:
java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()
-
getUnphasedHets
public IntArray getUnphasedHets(int sample)
Returns a list of marker indices in increasing order for which the specified sample has an unphased, non-missing heterozygote genotype.- Parameters:
sample- the sample index- Returns:
- a list of marker indices in increasing order for which the specified sample has an unphased heterozygote genotype
- Throws:
java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()
-
setUnphasedHets
public void setUnphasedHets(int sample, IntArray newUnphased)Sets the array with marker indices of unphased, nonmissing heterozygote genotypes to the specified array.- Parameters:
sample- the sample indexnewUnphased- the marker indices of unphased heterozygote genotypes- Throws:
java.lang.IllegalArgumentException- if the specifiednewUnphasedlist is not sorted in increasing order, contains a duplicate elements, or is not a subset ofthis.getUnphased(sample).java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()java.lang.NullPointerException- ifnewUnphased == null
-
setHapPair
public void setHapPair(int sample, int[] hap1, int[] hap2)Sets the haplotype pair for the specified sample to the specified haplotypes.- Parameters:
sample- the sample indexhap1- an array whosek-th entry is the estimated allele carried by the sample's first haplotype.hap2- an array whosek-th entry is the estimated allele carried by the sample's second haplotype.- Throws:
java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()java.lang.IllegalArgumentException- ifhap1.length != this.nMarkers() || hap2.length != this.nMarkers()java.lang.IllegalArgumentException- if(hap1[k] < 0 || hap1[k] >= this.markers().marker(k).nAlleles())for anyksatisfying(0 <= k && k < this.nMarkers())java.lang.IllegalArgumentException- if(hap2[k] < 0 || hap2[k] >= this.markers().marker(k).nAlleles())for anyksatisfying(0 <= k && k < this.nMarkers())java.lang.NullPointerException- ifhap1 == null || hap2 == null
-
getUnphasedHets
public void getUnphasedHets(int sample, boolean[] isUnphased)Sets thek-th entry of the specifiedisUnphasedarray totrueif the specified sample's genotype at thek-th marker is an unphased, nonmissing heterozygote, and tofalseotherwise.- Parameters:
sample- the sample indexisUnphased- an array whosek-th entry will be set totrueif the specified sample's genotype at thek-th marker is an unphased, nonmissing heterozygote, and tofalseotherwise.- Throws:
java.lang.IllegalArgumentException- ifisUnphased.length != this.nMarkers()java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()java.lang.NullPointerException- ifisUnphased == null
-
hasMissingGT
public boolean hasMissingGT(int sample)
Returnstrueif the specified sample has a missing genotype, and returnsfalseotherwise.- Parameters:
sample- the sample index- Returns:
trueif the specified sample has a missing genotype- Throws:
java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()
-
getMissing
public IntArray getMissing(int sample)
Returns a list of marker indices in increasing order for which the specified sample has a missing genotype.- Parameters:
sample- the sample index- Returns:
- a list of marker indices in increasing order for which the specified sample has a missing genotype
- Throws:
java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()
-
getMissing
public void getMissing(int sample, boolean[] isMissing)Sets thek-th entry of the specifiedisMissingarray totrueif the specified sample's genotype at thek-th marker is missing, and tofalseotherwise.- Parameters:
sample- the sample indexisMissing- an array whosek-th entry will be set totrueif the specified sample's genotype at thek-th marker is missing and tofalseotherwise- Throws:
java.lang.IllegalArgumentException- ifisMissing.length != this.nMarkers()java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()java.lang.NullPointerException- ifisMissing == null
-
setHapsWithMaskedMissingAlleles
public void setHapsWithMaskedMissingAlleles(int sample, int[] hap1, int[] hap2)Sets thek-th element of the specifiedhap1andhap2arrays to the specified sample's phased genotype at thek-th marker if the genotype is nonmissing, and sets thek-th element ofhap1andhap2to-1otherwise.- Parameters:
sample- the sample indexhap1- an array whosek-th entry will be set to the current estimated allele carried by the sample's first haplotype if the observed genotype is non-missing and to -1 otherwise.hap2- an array whosek-th entry will be set to the current estimated allele carried by the sample's second haplotype if the observed genotype is non-missing and to -1 otherwise.- Throws:
java.lang.IllegalArgumentException- ifhap1.length != this.nMarkers()java.lang.IllegalArgumentException- ifhap2.length != this.nMarkers()java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= this.nSamples()java.lang.NullPointerException- ifhap1 == null || hap2 == null
-
hapsGT
public EstPhase.HapsGT hapsGT()
-
-