Package htsjdk.variant.variantcontext

# Class GenotypeLikelihoods

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

public final class GenotypeLikelihoods extends Object

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`GenotypeLikelihoods.GenotypeLikelihoodsAllelePair`

## Field Summary

Fields
Modifier and Type
Field
Description
`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
`static final int`
`MAX_PL`
`protected static final int[]`
`PLindexConversion`

## Method Summary

Modifier and Type
Method
Description
`static int`
`calculatePLindex(int allele1Index, int allele2Index)`
`boolean`
`equals(Object aThat)`
`static final GenotypeLikelihoods`
`fromGLField(String GLs)`
Deprecated.
`static final GenotypeLikelihoods`
`fromLog10Likelihoods(double[] log10Likelihoods)`
`static final GenotypeLikelihoods`
`fromPLField(String PLs)`
`static final GenotypeLikelihoods`
`fromPLs(int[] pls)`
`static GenotypeLikelihoods.GenotypeLikelihoodsAllelePair`
`getAllelePair(int PLindex)`
Get the diploid allele index pair for the given PL index
`static GenotypeLikelihoods.GenotypeLikelihoodsAllelePair`
`getAllelePairUsingDeprecatedOrdering(int PLindex)`
Deprecated.
since 2/5/13
`static List<Integer>`
`getAlleles(int PLindex, int ploidy)`
Get the allele ploidy indices for the given PL index
`EnumMap<GenotypeType,Double>`
`getAsMap(boolean normalizeFromLog10)`
`int[]`
`getAsPLs()`
`String`
`getAsString()`
`double[]`
`getAsVector()`
The genotypes likelihoods in -10log10(x) vector format.
`static double`
`getGQLog10FromLikelihoods(int iOfChoosenGenotype, double[] likelihoods)`
`double`
`getLog10GQ(Genotype genotype, VariantContext context)`
`double`
`getLog10GQ(Genotype genotype, List<Allele> vcAlleles)`
`double`
`getLog10GQ(GenotypeType genotype)`
Deprecated.
since 2/5/13 use `getLog10GQ(Genotype, VariantContext)` or `getLog10GQ(Genotype, List)`
`static int[]`
`getPLIndecesOfAlleles(int allele1Index, int allele2Index)`
Deprecated.
7/18 use `getPLIndicesOfAlleles(int, int)` instead
`static int[]`
`getPLIndicesOfAlleles(int allele1Index, int allele2Index)`
get the PL indices (AA, AB, BB) for the given allele pair; assumes allele1Index <= allele2Index.
`int`
`hashCode()`
`static void`
`initializeAnyploidPLIndexToAlleleIndices(int altAlleles, int ploidy)`
Deprecated.
as of sept 2020, this method is no longer necessary
`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.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### MAX_PL

public static final int MAX_PL

See Also:
  - Constant Field Values

### 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:
  - Constant Field Values

### 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)
Deprecated.
since 2/5/13 use `getLog10GQ(Genotype, VariantContext)` or `getLog10GQ(Genotype, List)`
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 invalid input: '&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 invalid input: '<' 0 or ploidy invalid input: '<' 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.
7/18 use `getPLIndicesOfAlleles(int, int)` instead
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