Package Methods

Class Knni


  • public class Knni
    extends java.lang.Object
    Class to perform standard kNNi imputation
    • Constructor Summary

      Constructors 
      Constructor Description
      Knni()
      Creates an object to perform standard kNNi imputation with the default of k = 5
      Knni​(int k)
      Creates an object to perform standard kNNi with a given value of k
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[][] compute​(byte[][] original)
      Impute missing data
      byte[][] compute​(byte[][] original, double[][] d)
      Impute missing data
      double fastAccuracy​(byte[][] original, Mask mask)
      Performs a fast accuracy calculation - only imputes those genotypes that were masked rather than all missing genotypes.
      double fastAccuracy​(byte[][] original, Mask mask, double[][] d)
      Performs a fast accuracy calculation - only imputes those genotypes that were masked rather than all missing genotypes.
      static double[][] weight​(byte[][] values)
      Calculates distances between samples using a scaled taxicab distances
      • Methods inherited from class java.lang.Object

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

      • Knni

        public Knni()
        Creates an object to perform standard kNNi imputation with the default of k = 5
      • Knni

        public Knni​(int k)
        Creates an object to perform standard kNNi with a given value of k
        Parameters:
        k - The value of k to be used
    • Method Detail

      • fastAccuracy

        public double fastAccuracy​(byte[][] original,
                                   Mask mask)
                            throws NotEnoughGenotypesException
        Performs a fast accuracy calculation - only imputes those genotypes that were masked rather than all missing genotypes.
        Parameters:
        original - The original genotype values
        mask - A mask
        Returns:
        The percentage of genotypes imputed correctly
        Throws:
        NotEnoughGenotypesException - Thrown if there are not k known genotypes avaliable for a SNP
      • fastAccuracy

        public double fastAccuracy​(byte[][] original,
                                   Mask mask,
                                   double[][] d)
                            throws NotEnoughGenotypesException
        Performs a fast accuracy calculation - only imputes those genotypes that were masked rather than all missing genotypes.
        Parameters:
        original - The original genotype values
        mask - A mask
        d - Distance matrix giving the distance between samples
        Returns:
        The percentage of genotypes imputed correctly
        Throws:
        NotEnoughGenotypesException - Thrown if there are not k known genotypes avaliable for a SNP
      • weight

        public static double[][] weight​(byte[][] values)
        Calculates distances between samples using a scaled taxicab distances
        Parameters:
        values - Genotype array
        Returns:
        Distance (between samples) array