Package htsjdk.variant.variantcontext
Class GenotypeLikelihoods
java.lang.Object
htsjdk.variant.variantcontext.GenotypeLikelihoods
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum number of diploid alternate alleles that we can represent as genotype likelihoodsstatic final int
protected static final int[]
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
calculatePLindex
(int allele1Index, int allele2Index) boolean
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) getAllelePair
(int PLindex) Get the diploid allele index pair for the given PL indexgetAllelePairUsingDeprecatedOrdering
(int PLindex) Deprecated.since 2/5/13getAlleles
(int PLindex, int ploidy) Get the allele ploidy indices for the given PL indexgetAsMap
(boolean normalizeFromLog10) int[]
getAsPLs()
double[]
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 usegetLog10GQ(Genotype, VariantContext)
orgetLog10GQ(Genotype, List)
static int[]
getPLIndecesOfAlleles
(int allele1Index, int allele2Index) Deprecated.7/18 usegetPLIndicesOfAlleles(int, int)
insteadstatic 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 necessarystatic 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.toString()
-
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_GENOTYPEDThe maximum number of diploid alternate alleles that we can represent as genotype likelihoods- See Also:
-
PLindexConversion
protected static final int[] PLindexConversion
-
-
Method Details
-
fromPLField
-
fromGLField
Deprecated. -
fromLog10Likelihoods
-
fromPLs
-
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
-
getAsString
-
equals
-
hashCode
public int hashCode() -
getAsMap
-
getLog10GQ
Deprecated.since 2/5/13 usegetLog10GQ(Genotype, VariantContext)
orgetLog10GQ(Genotype, List)
This is really dangerous and returns completely wrong results for genotypes from a multi-allelic context. UsegetLog10GQ(Genotype,VariantContext)
orgetLog10GQ(Genotype,List<Allele>)
in place of it. If you know you're biallelic, usegetGQLog10FromLikelihoods
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
-
getLog10GQ
-
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
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.as of sept 2020, this method is no longer necessaryThis method is no longer necessary and is now a no-op- Throws:
IllegalArgumentException
- if altAlleles or ploidy <= 0
-
getAlleles
Get the allele ploidy indices for the given PL index- Parameters:
PLindex
- the PL indexploidy
- 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/13get 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.7/18 usegetPLIndicesOfAlleles(int, int)
insteadget the PL indices (AA, AB, BB) for the given allele pair; assumes allele1Index <= allele2Index.- Parameters:
allele1Index
- the index in VariantContext.getAllele() of the first alleleallele2Index
- 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 alleleallele2Index
- the index in VariantContext.getAllele() of the second allele- Returns:
- the PL indexes
-