All Downloads are FREE. Search and download functionalities are using the official Maven repository.

imputationtool.preprocessing.DetermineLD Maven / Gradle / Ivy

///*
// * DetermineLD.java
// *
// * Created on August 8, 2006, 4:32 PM
// *
// * To change this template, choose Tools | Template Manager
// * and open the template in the editor.
// */
//
//package imputationtool.preprocessing;
//
//import java.lang.Math;
//import metaqtl2.Containers.GenDataset;
//import metaqtl2.Containers.SNP;
//
///**
// *
// * @author lude
// */
//public class DetermineLD {
//
//    public final static int INCLUDE_CASES_AND_CONTROLS = 1;
//    public final static int INCLUDE_CASES = 2;
//    public final static int INCLUDE_CONTROLS = 3;
//    
//    public final static int RETURN_R_SQUARED = 4;
//    public final static int RETURN_D_PRIME = 5;
//    
//    public double h11 = 0;
//    public double h12 = 0;
//    public double h21 = 0;
//    public double h22 = 0;
//    
//    //Triallelic LD calculations:
//    public double h31 = 0;
//    public double h32 = 0;
//    
//    public int nrCalledGenotypes = 0;
//    
//    /** Creates a new instance of DetermineLD */
//    public DetermineLD(){
//    }
//    
//    public synchronized double getRSquared(SNP snpX, SNP snpY, GenDataset genotypeData, int returnType, int individualsToInclude, boolean print) {
//
//        if (snpX==null||snpY==null) return 0;
//
//	int[] genotypesX = snpX.getGenotype();
//	int[] genotypesY = snpY.getGenotype();
//	
//	if(genotypesX.length!=genotypesY.length)return 0;
//        //Get genotypes:
//        int[][] genotypes = new int[3][3];
//        nrCalledGenotypes = 0;
//	
//
//        for (int ind=0; indalleleFreq[1][0]) a = alleleFreq[0][0]*alleleFreq[1][0];
//                double b = alleleFreq[0][0]*alleleFreq[1][0];
//                if (alleleFreq[0][0]>alleleFreq[1][0]) b = alleleFreq[0][1]*alleleFreq[1][1];
//                dMax = Math.min(a,b);
//            } else {
//                double a = alleleFreq[0][1]*alleleFreq[1][0];
//                if (alleleFreq[0][0]>alleleFreq[1][0]) a = alleleFreq[0][0]*alleleFreq[1][1];
//                double b = alleleFreq[0][0]*alleleFreq[1][1];
//                if (alleleFreq[0][0]>alleleFreq[1][0]) b = alleleFreq[0][1]*alleleFreq[1][0];
//                dMax = Math.min(a,b);
//            }
//            double dPrime = Math.abs(d / dMax);
//            /*
//            if (dPrime>1.01) {
//                System.out.println("");
//                System.out.println(genotypes[0][0] + "\t" + genotypes[0][1] + "\t" + genotypes[0][2]);
//                System.out.println(genotypes[1][0] + "\t" + genotypes[1][1] + "\t" + genotypes[1][2]);
//                System.out.println(genotypes[2][0] + "\t" + genotypes[2][1] + "\t" + genotypes[2][2]);
//                System.out.println(alleleFreq[0][0] + "\t" + alleleFreq[0][1] + "\t" + alleleFreq[1][0] + "\t" + alleleFreq[1][1]);
//                System.out.println(h11 + "\t" + h12 + "\t" + h21 + "\t" + h22);
//                System.out.println(d + "\t" + dMax + "\t" + dPrime);
//            }
//             */
//            return Math.min(1,dPrime);
//        }
//    }
//    
//
//    
//    
//}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy