Class GenotypeLikelihoods

java.lang.Object
htsjdk.variant.variantcontext.GenotypeLikelihoods

public final class GenotypeLikelihoods extends Object
  • Field Details

    • MAX_PL

      public static final int MAX_PL
      See Also:
    • MAX_DIPLOID_ALT_ALLELES_THAT_CAN_BE_GENOTYPED

      public static final int MAX_DIPLOID_ALT_ALLELES_THAT_CAN_BE_GENOTYPED
      The maximum number of diploid alternate alleles that we can represent as genotype likelihoods
      See Also:
    • PLindexConversion

      protected static final int[] PLindexConversion
  • Method Details

    • fromPLField

      public static final GenotypeLikelihoods fromPLField(String PLs)
    • fromGLField

      @Deprecated public static final GenotypeLikelihoods fromGLField(String GLs)
      Deprecated.
    • fromLog10Likelihoods

      public static final GenotypeLikelihoods fromLog10Likelihoods(double[] log10Likelihoods)
    • fromPLs

      public static final GenotypeLikelihoods fromPLs(int[] pls)
    • getAsVector

      public double[] getAsVector()
      The genotypes likelihoods in -10log10(x) vector format. pr{AA} = x, this vector returns math.log10(x) for each of the genotypes. Can return null if the genotype likelihoods are "missing".
      Returns:
      genotypes likelihoods in negative log10 vector format
    • getAsPLs

      public int[] getAsPLs()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAsString

      public String getAsString()
    • equals

      public boolean equals(Object aThat)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getAsMap

      public EnumMap<GenotypeType,Double> getAsMap(boolean normalizeFromLog10)
    • getLog10GQ

      @Deprecated public double getLog10GQ(GenotypeType genotype)
      This is really dangerous and returns completely wrong results for genotypes from a multi-allelic context. Use getLog10GQ(Genotype,VariantContext) or getLog10GQ(Genotype,List<Allele>) in place of it. If you know you're biallelic, use getGQLog10FromLikelihoods directly.
      Parameters:
      genotype - - actually a genotype type (no call, hom ref, het, hom var)
      Returns:
      an unsafe quantity that could be negative. In the bi-allelic case, the GQ resulting from best minus next best (if the type is the best).
    • getLog10GQ

      public double getLog10GQ(Genotype genotype, List<Allele> vcAlleles)
    • getLog10GQ

      public double getLog10GQ(Genotype genotype, VariantContext context)
    • getGQLog10FromLikelihoods

      public static double getGQLog10FromLikelihoods(int iOfChoosenGenotype, double[] likelihoods)
    • numLikelihoods

      public static int numLikelihoods(int numAlleles, int ploidy)
      Compute how many likelihood elements are associated with the given number of alleles Equivalent to asking in how many ways N non-negative integers can add up to P is S(N,P) where P = ploidy (number of chromosomes) and N = total # of alleles. Each chromosome can be in one single state (0,...,N-1) and there are P of them. Naive solution would be to store N*P likelihoods, but this is not necessary because we can't distinguish chromosome states, but rather only total number of alt allele counts in all chromosomes. For example, S(3,2) = 6: For alleles A,B,C, on a diploid organism we have six possible genotypes: AA,AB,BB,AC,BC,CC. Another way of expressing is with vector (#of A alleles, # of B alleles, # of C alleles) which is then, for ordering above, (2,0,0), (1,1,0), (0,2,0), (1,1,0), (0,1,1), (0,0,2) In general, for P=2 (regular biallelic), then S(N,2) = N*(N+1)/2 Note this method caches the value for most common num Allele / ploidy combinations for efficiency For non-cached values, the result is calculated via a call to calcNumLikelihoods, which uses the Apache Commons CombinatoricsUtils class using the formula (numAlleles + ploidy - 1) choose ploidy
      Parameters:
      numAlleles - Number of alleles (including ref)
      ploidy - Ploidy, or number of chromosomes in set
      Returns:
      Number of likelihood elements we need to hold.
    • calculatePLindex

      public static int calculatePLindex(int allele1Index, int allele2Index)
    • getAllelePair

      public static GenotypeLikelihoods.GenotypeLikelihoodsAllelePair getAllelePair(int PLindex)
      Get the diploid allele index pair for the given PL index
      Parameters:
      PLindex - the PL index
      Returns:
      the diploid allele index pair
      Throws:
      IllegalStateException - if PLindex is negative value or greater than the cache computed by @see #calculateDiploidPLcache
    • initializeAnyploidPLIndexToAlleleIndices

      @Deprecated public static void initializeAnyploidPLIndexToAlleleIndices(int altAlleles, int ploidy)
      Deprecated.
      as of sept 2020, this method is no longer necessary
      This method is no longer necessary and is now a no-op
      Throws:
      IllegalArgumentException - if altAlleles or ploidy &lt= 0
    • getAlleles

      public static List<Integer> getAlleles(int PLindex, int ploidy)
      Get the allele ploidy indices for the given PL index
      Parameters:
      PLindex - the PL index
      ploidy - number of chromosomes
      Returns:
      the ploidy allele indices
      Throws:
      IllegalStateException - if PLindex < 0 or ploidy < 0
    • getAllelePairUsingDeprecatedOrdering

      @Deprecated public static GenotypeLikelihoods.GenotypeLikelihoodsAllelePair getAllelePairUsingDeprecatedOrdering(int PLindex)
      Deprecated.
      since 2/5/13
      get the allele index pair for the given PL using the deprecated PL ordering: AA,AB,AC,AD,BB,BC,BD,CC,CD,DD instead of AA,AB,BB,AC,BC,CC,AD,BD,CD,DD. Although it's painful to keep this conversion around, our DiploidSNPGenotypeLikelihoods class uses the deprecated ordering and I know with certainty that external users have built code on top of it; changing it now would cause a whole lot of heartache for our collaborators, so for now at least there's a standard conversion method. This method assumes at most 3 alternate alleles.
      Parameters:
      PLindex - the PL index
      Returns:
      the allele index pair
    • getPLIndecesOfAlleles

      @Deprecated public static int[] getPLIndecesOfAlleles(int allele1Index, int allele2Index)
      Deprecated.
      get the PL indices (AA, AB, BB) for the given allele pair; assumes allele1Index <= allele2Index.
      Parameters:
      allele1Index - the index in VariantContext.getAllele() of the first allele
      allele2Index - the index in VariantContext.getAllele() of the second allele
      Returns:
      the PL indexes
    • getPLIndicesOfAlleles

      public static int[] getPLIndicesOfAlleles(int allele1Index, int allele2Index)
      get the PL indices (AA, AB, BB) for the given allele pair; assumes allele1Index <= allele2Index.
      Parameters:
      allele1Index - the index in VariantContext.getAllele() of the first allele
      allele2Index - the index in VariantContext.getAllele() of the second allele
      Returns:
      the PL indexes