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

umcg.genetica.util.CheckAssocationMultipleGeneProbes Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package umcg.genetica.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import umcg.genetica.io.text.TextFile;
import cern.jet.stat.tdouble.Probability;

/**
 *
 * @author MarcJan
 */
public class CheckAssocationMultipleGeneProbes {
    public static void main(String[] args) {
        
        HashMap> hashGenes = new HashMap>();
        LinkedHashMap hashTValues = new LinkedHashMap();
        HashMap hashCpGSites = new HashMap();

        try {
            TextFile in = new TextFile("C:\\Users\\MarcJan\\Desktop\\pcas_450K.txt", TextFile.R);
            String str = in.readLine();

            int i=-1;
            while ((str = in.readLine()) != null) {
                String[] data = str.split("\t");
                String CpG = data[0];
//                if (data.length>7 && !data[7].equals("")) {
                if (data.length>6) {
                    ++i;
                    String gene = data[6];
//                    double t = Double.parseDouble(data[1]);
//                    double t = Double.parseDouble(data[2]);
//                    double t = Double.parseDouble(data[3]);
//                    double t = Double.parseDouble(data[4]);
                    double t = Double.parseDouble(data[5]);
                    hashTValues.put(CpG, t);
                    hashCpGSites.put(CpG, i);
                    
                    if (!hashGenes.containsKey(gene)) {
                        ArrayList CpGs = new ArrayList();
                        CpGs.add(CpG);
                       
                        hashGenes.put(gene, CpGs);
                    } else {
                        hashGenes.get(gene).add(CpG);
                    }
                }
               
            }
            in.close();
//            System.out.println(hashGenes.size());
//            System.out.println(hashTValues.size());
        } catch (Exception e) {
            System.out.println("Error:\t" + e.getMessage());
            e.printStackTrace();
        }
        
        double[] pValues = new double[hashTValues.size()];
//        System.out.println(pValues.length);
        int c=0;
        for (Entry ent : hashTValues.entrySet()) {
            double t = ent.getValue();
//            if (t<0) {
//                pValues[c] = t;
//            } else {
//                pValues[c] = 0;
//            }
//            pValues[c] = Math.abs(t);
            pValues[c] = t;
            c++;
            
        }
        
        RankArray r = new RankArray();
        pValues = r.rank(pValues, false);
        
//        double[] rank = r.rank(pValues, false);
//        for (int i=0; i> ent : hashGenes.entrySet()) {
            String gene = ent.getKey();
            ArrayList sites = ent.getValue();
            double[] pSites = new double[sites.size()];
            double chiSquare = 0;
            double[] zSites = new double[sites.size()];
            for (int p=0; p




© 2015 - 2025 Weber Informatics LLC | Privacy Policy