public class IBSDistanceMatrix
This class calculates an identity by state matrix. It is scaled so only non-missing comparison are used. It conducts bit level calculations of IBS for genotypes. Only the two most common alleles are used in the distance calculations.
Please note that when heterozygous genotypes are used, Het to Het distance is 0.5 NOT 0.0. The default along the identity diagonal is 0 (isTrueIBS = false), but changing isTrueIBS = true will calculate the identity.
The distance estimates become wildly inaccurate when too few sites are used to calculate distance. The minSiteComp parameter can be used to control the minimum number of sites used for a calculation. If there are insufficient sites in the estimate, then Double.NaN is returned.
public static DistanceMatrix getInstance(GenotypeTable theAlignment)
Compute observed distances for all taxa. Missing sites are ignored.
theAlignment - Alignment used to computed distancespublic static DistanceMatrix getInstance(GenotypeTable theAlignment, ProgressListener listener)
Compute observed distances for all taxa. Missing sites are ignored.
theAlignment - Alignment used to computed distanceslistener - Listener to track progress in calculationspublic static DistanceMatrix getInstance(GenotypeTable theAlignment, int minSiteComp, ProgressListener listener)
Compute observed distances for all taxa. Missing sites are ignored.
theAlignment - Alignment used to computed distancesminSiteComp - Minimum number of sites needed to estimate distancelistener - Listener to track progress in calculationspublic static DistanceMatrix getInstance(GenotypeTable theAlignment, int minSiteComp, boolean trueIBS, ProgressListener listener, boolean useThirdState)
Compute observed distances for all taxa. Missing sites are ignored.
theAlignment - Alignment used to computed distancesminSiteComp - Minimum number of sites needed to estimate distancetrueIBS - estimate diagonal distance based IBS (default = false, i=i=0.0)listener - Listener to track progress in calculationsuseThirdState - public static kotlin.Array[] computeHetDistances(kotlin.Array[] first,
kotlin.Array[] second,
int minSitesComp)
public static kotlin.Array[] computeHetBitDistances(GenotypeTable theTBA, int taxon1, int taxon2)
Compute distance for a pair of taxa.
theTBA - input alignmenttaxon1 - index of taxon 1taxon2 - index of taxon 2public static kotlin.Array[] computeHetBitDistances(GenotypeTable theTBA, int taxon1, int taxon2, int minSitesCompared)
Compute distance for a pair of taxa.
theTBA - input alignmenttaxon1 - index of taxon 1taxon2 - index of taxon 2minSitesCompared - Minimum number of sites needed to estimate distancepublic static kotlin.Array[] computeHetBitDistances(GenotypeTable theTBA, int taxon1, int taxon2, int minSitesCompared, int firstWord, int lastWord, BitSet maskBadSet)
Compute distance for a pair of taxa. Optimized for calculations sites within a certain range of underlying word (64 sites chunks) in the TBit array
theTBA - input alignmenttaxon1 - index of taxon 1taxon2 - index of taxon 2minSitesCompared - Minimum number of sites needed to estimate distancefirstWord - starting word for calculating distance site=(firstWord*64)lastWord - ending word for calculating distance inclusive site=(lastWord*64+63)maskBadSet - Optional mask for sites (those set to 1 are kept)public static kotlin.Array[] computeHetBitDistances(kotlin.Array[] iMj,
kotlin.Array[] iMn,
kotlin.Array[] jMj,
kotlin.Array[] jMn,
int minSitesCompared)
Calculation of distance using the bit vector of major and minor alleles.
iMj - Vector of major alleles for taxon iiMn - Vector of minor alleles for taxon ijMj - Vector of major alleles for taxon jjMn - Vector of minor alleles for taxon jminSitesCompared - Minimum number of sites needed to estimate distancepublic static kotlin.Array[] computeHetBitDistancesThirdState(kotlin.Array[] iMj,
kotlin.Array[] iMn,
kotlin.Array[] iMn2,
kotlin.Array[] jMj,
kotlin.Array[] jMn,
kotlin.Array[] jMn2,
int minSitesCompared)
Calculation of distance using the bit vector of the first three alleles.
iMj - Vector of major alleles for taxon iiMn - Vector of minor alleles for taxon ijMj - Vector of major alleles for taxon jjMn - Vector of minor alleles for taxon jminSitesCompared - Minimum number of sites needed to estimate distancepublic static kotlin.Array[] computeHetBitDistances(kotlin.Array[] iMj,
kotlin.Array[] iMn,
kotlin.Array[] jMj,
kotlin.Array[] jMn,
int minSitesCompared,
int firstWord,
int lastWord)
Calculation of distance using the bit vector of major and minor alleles.
iMj - Vector of major alleles for taxon iiMn - Vector of minor alleles for taxon ijMj - Vector of major alleles for taxon jjMn - Vector of minor alleles for taxon jminSitesCompared - Minimum number of sites needed to estimate distancefirstWord - first world for calculating distancelastWord - last word for calculating distance inclusive site=(endWord*64+63)public static kotlin.Array[] computeHetBitDistancesThirdState(kotlin.Array[] iMj,
kotlin.Array[] iMn,
kotlin.Array[] iMn2,
kotlin.Array[] jMj,
kotlin.Array[] jMn,
kotlin.Array[] jMn2,
int minSitesCompared,
int firstWord,
int lastWord)
Calculation of distance using the bit vectors of the first three alleles.
iMj - Vector of major alleles for taxon iiMn - Vector of minor alleles for taxon iiMn2 - Vector of second minor alleles for taxon ijMj - Vector of major alleles for taxon jjMn - Vector of minor alleles for taxon jjMn2 - Vector of second minor alleles for taxon jminSitesCompared - Minimum number of sites needed to estimate distancefirstWord - first world for calculating distancelastWord - last word for calculating distance inclusive site=(endWord*64+63)