public List<String> find() throws IOException { // Set<String> g1 = new HashSet<String>(Arrays.asList("HRAS", "NRAS", "KRAS")); // Set<String> g2 = new HashSet<String>(Arrays.asList("BRAF")); Set<String> g1 = new HashSet<String>(Arrays.asList("HRAS")); Set<String> g2 = new HashSet<String>(Arrays.asList("NRAS", "KRAS")); Map<String, Double> pvals = calcDifferencePvals(g1, g2); System.out.println("pvals.size() = " + pvals.size()); List<String> list = FDR.select(pvals, null, fdrThr); System.out.println("result size = " + list.size()); Map<String, Boolean> dirs = getChangeDirections(list, g1, g2); int up = 0; int dw = 0; for (String gene : dirs.keySet()) { Boolean d = dirs.get(gene); if (d) up++; else dw++; } System.out.println("up = " + up); System.out.println("dw = " + dw); return list; }
private Map<String, Double> getExpressionPvals( Set<String> targets, boolean[] set1, boolean[] set2) { Map<String, Double> map = new HashMap<String, Double>(); Histogram2D h = new Histogram2D(0.2); System.out.println("targets = " + targets.size()); Progress prg = new Progress(targets.size()); for (String sym : targets) { prg.tick(); if (expMan.getNonZeroRatio(sym) == 0) continue; double pval = calcDiffPval(sym, set1, set2, true); if (Double.isNaN(pval)) continue; if (pval == 0) pval = 1E-11; double pPerm = calcDiffPval(sym, set1, set2, false); if (pPerm == 0) pPerm = 1E-5; h.count(-Math.log(pval), -Math.log(pPerm)); // pval = 0 is not real and it is not compatible with fisher's combined probability. // below is a better approximation. // if (pval == 0) // { // pval = 1E-11; // } map.put(sym, pval); } Histogram2DPlot p = new Histogram2DPlot(h); p.setLines(Arrays.asList(new double[] {1, 0})); p.setVisible(true); return map; }