private Set<String> getDownstream(String mut) {
    Set<String> tfs = new HashSet<String>();
    tfs.add(mut);

    if (depth > 1) tfs.addAll(travSt.getDownstream(tfs, depth - 1));

    return travExp.getDownstream(tfs);
  }
  private void writeWeights(
      String orig, GeneBranch from, GeneBranch to, String edgeType, Writer writer)
      throws IOException {
    Set<String> dwstr = to.getAllGenes();
    dwstr.retainAll(downstream.get(orig));
    assert !dwstr.isEmpty();
    double cumPval = calcPVal(orig, dwstr);
    boolean upreg = calcChangeDirection(orig, to.gene);

    String key = from.gene + " " + edgeType + " " + to.gene;
    writer.write("edge\t" + key + "\tcolor\t" + val2Color(cumPval, 0) + "\n");
    writer.write("edge\t" + key + "\twidth\t2\n");

    if (affectedDw.get(orig).contains(to.gene)) {
      double pval = calcPVal(orig, Collections.singleton(to.gene));
      writer.write("node\t" + to.gene + "\tcolor\t" + val2Color(pval, upreg ? 1 : -1) + "\n");
    } else {
      writer.write("node\t" + to.gene + "\tcolor\t255 255 255\n");
    }
  }
  private boolean[] getMutated(Set<String> genes) {
    boolean[] b = new boolean[portalAcc.getAlterations(genes.iterator().next()).getSize()];

    for (String gene : genes) {
      AlterationPack alts = portalAcc.getAlterations(gene);
      Change[] ch = alts.get(Alteration.MUTATION);
      for (int i = 0; i < ch.length; i++) {
        if (ch[i].isAltered()) b[i] = true;
      }
    }
    return b;
  }
  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;
  }