Package phase
Class EstPhase
- java.lang.Object
-
- phase.EstPhase
-
public final class EstPhase extends java.lang.Object
Class
EstPhase
stores haplotype pairs, missing genotypes, and unphased, nonmissing heteroygote genotypes for a list of samples.Instances of class
EstPhase
are thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
EstPhase.HapsGT
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IntArray
getMissing(int sample)
Returns a list of marker indices in increasing order for which the specified sample has a missing genotype.void
getMissing(int sample, boolean[] isMissing)
Sets thek
-th entry of the specifiedisMissing
array totrue
if the specified sample's genotype at thek
-th marker is missing, and tofalse
otherwise.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.void
getUnphasedHets(int sample, boolean[] isUnphased)
Sets thek
-th entry of the specifiedisUnphased
array totrue
if the specified sample's genotype at thek
-th marker is an unphased, nonmissing heterozygote, and tofalse
otherwise.EstPhase.HapsGT
hapsGT()
boolean
hasMissingGT(int sample)
Returnstrue
if the specified sample has a missing genotype, and returnsfalse
otherwise.boolean
hasUnphasedHets(int sample)
Returnstrue
if the specified sample has an unphased heterozygote genotype, and returnsfalse
otherwise.Markers
markers()
Returns the list of markers.int
nMarkers()
Returns the number of markers.int
nSamples()
Returns the number of samples.int
nUnphasedHets(int sample)
Returns the number of unphased, non-missing heterozygote genotypes.Samples
samples()
Returns the list of target samples.void
setHapPair(int sample, int[] hap1, int[] hap2)
Sets the haplotype pair for the specified sample to the specified haplotypes.void
setHapsWithMaskedMissingAlleles(int sample, int[] hap1, int[] hap2)
Sets thek
-th element of the specifiedhap1
andhap2
arrays to the specified sample's phased genotype at thek
-th marker if the genotype is nonmissing, and sets thek
-th element ofhap1
andhap2
to-1
otherwise.void
setUnphasedHets(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 newEstPhase
instance 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 anys
satisfying(0 <= s && s < gt.nSamples())
java.lang.NullPointerException
- ifgt == null || hapPairs == null
java.lang.NullPointerException
- if(hapPairs.get(j) == null)
for anyj
satisfying(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)
Returnstrue
if the specified sample has an unphased heterozygote genotype, and returnsfalse
otherwise.- Parameters:
sample
- the sample index- Returns:
true
if 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 specifiednewUnphased
list 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 anyk
satisfying(0 <= k && k < this.nMarkers())
java.lang.IllegalArgumentException
- if(hap2[k] < 0 || hap2[k] >= this.markers().marker(k).nAlleles())
for anyk
satisfying(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 specifiedisUnphased
array totrue
if the specified sample's genotype at thek
-th marker is an unphased, nonmissing heterozygote, and tofalse
otherwise.- Parameters:
sample
- the sample indexisUnphased
- an array whosek
-th entry will be set totrue
if the specified sample's genotype at thek
-th marker is an unphased, nonmissing heterozygote, and tofalse
otherwise.- 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)
Returnstrue
if the specified sample has a missing genotype, and returnsfalse
otherwise.- Parameters:
sample
- the sample index- Returns:
true
if 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 specifiedisMissing
array totrue
if the specified sample's genotype at thek
-th marker is missing, and tofalse
otherwise.- Parameters:
sample
- the sample indexisMissing
- an array whosek
-th entry will be set totrue
if the specified sample's genotype at thek
-th marker is missing and tofalse
otherwise- 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 specifiedhap1
andhap2
arrays to the specified sample's phased genotype at thek
-th marker if the genotype is nonmissing, and sets thek
-th element ofhap1
andhap2
to-1
otherwise.- 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()
-
-