Package phase

Class 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  
    • Constructor Summary

      Constructors 
      Constructor Description
      EstPhase​(GT gt, java.util.List<LongArray> haps)
      Constructs a new EstPhase instance from the specified data.
    • 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 the k-th entry of the specified isMissing array to true if the specified sample's genotype at the k-th marker is missing, and to false 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 the k-th entry of the specified isUnphased array to true if the specified sample's genotype at the k-th marker is an unphased, nonmissing heterozygote, and to false otherwise.
      EstPhase.HapsGT hapsGT()  
      boolean hasMissingGT​(int sample)
      Returns true if the specified sample has a missing genotype, and returns false otherwise.
      boolean hasUnphasedHets​(int sample)
      Returns true if the specified sample has an unphased heterozygote genotype, and returns false 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 the k-th element of the specified hap1 and hap2 arrays to the specified sample's phased genotype at the k-th marker if the genotype is nonmissing, and sets the k-th element of hap1 and hap2 to -1 otherwise.
      void setUnphasedHets​(int sample, IntArray newUnphased)
      Sets the array with marker indices of unphased, nonmissing heterozygote genotypes to the specified array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EstPhase

        public EstPhase​(GT gt,
                        java.util.List<LongArray> haps)
        Constructs a new EstPhase instance from the specified data. The haplotypes for the k-th sample must be stored in entries haps.get(2*k} and haps.get(2*k + 1)
        Parameters:
        gt - the observed genotype data
        haps - the initial haplotypes for each sample
        Throws:
        java.lang.IllegalArgumentException - if gt.nSamples() != hapPairs.nSamples()
        java.lang.IllegalArgumentException - if (hapPairs.get(s).idIndex!= this.gt().samples().idIndex(s)) for any s satisfying (0 <= s && s < gt.nSamples())
        java.lang.NullPointerException - if gt == null || hapPairs == null
        java.lang.NullPointerException - if (hapPairs.get(j) == null) for any j 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)
        Returns true if the specified sample has an unphased heterozygote genotype, and returns false otherwise.
        Parameters:
        sample - the sample index
        Returns:
        true if the specified sample has an unphased heterozygote genotype
        Throws:
        java.lang.IndexOutOfBoundsException - if sample < 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 - if sample < 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 - if sample < 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 index
        newUnphased - the marker indices of unphased heterozygote genotypes
        Throws:
        java.lang.IllegalArgumentException - if the specified newUnphased list is not sorted in increasing order, contains a duplicate elements, or is not a subset of this.getUnphased(sample).
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.nSamples()
        java.lang.NullPointerException - if newUnphased == 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 index
        hap1 - an array whose k-th entry is the estimated allele carried by the sample's first haplotype.
        hap2 - an array whose k-th entry is the estimated allele carried by the sample's second haplotype.
        Throws:
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.nSamples()
        java.lang.IllegalArgumentException - if hap1.length != this.nMarkers() || hap2.length != this.nMarkers()
        java.lang.IllegalArgumentException - if (hap1[k] < 0 || hap1[k] >= this.markers().marker(k).nAlleles()) for any k satisfying (0 <= k && k < this.nMarkers())
        java.lang.IllegalArgumentException - if (hap2[k] < 0 || hap2[k] >= this.markers().marker(k).nAlleles()) for any k satisfying (0 <= k && k < this.nMarkers())
        java.lang.NullPointerException - if hap1 == null || hap2 == null
      • getUnphasedHets

        public void getUnphasedHets​(int sample,
                                    boolean[] isUnphased)
        Sets the k-th entry of the specified isUnphased array to true if the specified sample's genotype at the k-th marker is an unphased, nonmissing heterozygote, and to false otherwise.
        Parameters:
        sample - the sample index
        isUnphased - an array whose k-th entry will be set to true if the specified sample's genotype at the k-th marker is an unphased, nonmissing heterozygote, and to false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if isUnphased.length != this.nMarkers()
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.nSamples()
        java.lang.NullPointerException - if isUnphased == null
      • hasMissingGT

        public boolean hasMissingGT​(int sample)
        Returns true if the specified sample has a missing genotype, and returns false otherwise.
        Parameters:
        sample - the sample index
        Returns:
        true if the specified sample has a missing genotype
        Throws:
        java.lang.IndexOutOfBoundsException - if sample < 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 - if sample < 0 || sample >= this.nSamples()
      • getMissing

        public void getMissing​(int sample,
                               boolean[] isMissing)
        Sets the k-th entry of the specified isMissing array to true if the specified sample's genotype at the k-th marker is missing, and to false otherwise.
        Parameters:
        sample - the sample index
        isMissing - an array whose k-th entry will be set to true if the specified sample's genotype at the k-th marker is missing and to false otherwise
        Throws:
        java.lang.IllegalArgumentException - if isMissing.length != this.nMarkers()
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.nSamples()
        java.lang.NullPointerException - if isMissing == null
      • setHapsWithMaskedMissingAlleles

        public void setHapsWithMaskedMissingAlleles​(int sample,
                                                    int[] hap1,
                                                    int[] hap2)
        Sets the k-th element of the specified hap1 and hap2 arrays to the specified sample's phased genotype at the k-th marker if the genotype is nonmissing, and sets the k-th element of hap1 and hap2 to -1 otherwise.
        Parameters:
        sample - the sample index
        hap1 - an array whose k-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 whose k-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 - if hap1.length != this.nMarkers()
        java.lang.IllegalArgumentException - if hap2.length != this.nMarkers()
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.nSamples()
        java.lang.NullPointerException - if hap1 == null || hap2 == null