Package Methods
Class Knni
- java.lang.Object
-
- Methods.Knni
-
public class Knni extends java.lang.Object
Class to perform standard kNNi imputation
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[][]
compute(byte[][] original)
Impute missing databyte[][]
compute(byte[][] original, double[][] d)
Impute missing datadouble
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
-
-
-
Method Detail
-
compute
public byte[][] compute(byte[][] original) throws NotEnoughGenotypesException, WrongNumberOfSNPsException
Impute missing data- Parameters:
original
- The original data set. Missing data is coded as -1- Returns:
- The imputed data set.
- Throws:
NotEnoughGenotypesException
- If there is not enough known genotypes for imputationWrongNumberOfSNPsException
- If the number of SNPs is not the same for every sample
-
compute
public byte[][] compute(byte[][] original, double[][] d) throws NotEnoughGenotypesException, WrongNumberOfSNPsException
Impute missing data- Parameters:
original
- The original data set. Missing data is coded as -1d
- Distance matrix giving the distance between samples- Returns:
- The imputed data set.
- Throws:
NotEnoughGenotypesException
- If there is not enough known genotypes for imputationWrongNumberOfSNPsException
- If the number of SNPs is not the same for every sample
-
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 valuesmask
- 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 valuesmask
- A maskd
- 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
-
-