Пример #1
0
  public AllMultilevelCoefs(CoefArgs args) throws IOException {
    this.args = args;
    files = new Vector<File>();
    keys = new Vector<String>();
    coefs = new Vector<MultilevelCoefs>();

    File dir = args.dir();
    for (int i = 0; i < args.keys.length; i++) {
      keys.add(args.keys[i]);
      File f = CoefArgs.coefFile(dir, args.keys[i]);
      files.add(f);

      coefs.add(new MultilevelCoefs(f));
      System.out.println(String.format("Loaded: %s", args.keys[i]));
    }
  }
Пример #2
0
  public static void main(String[] argarray) {
    CoefArgs args = CoefArgs.parse(argarray);
    try {
      AllMultilevelCoefs coefs = new AllMultilevelCoefs(args);

      Matrix matrix = coefs.matrix(true);
      Matrix covar = matrix.transpose().times(matrix);
      SingularValueDecomposition svd = covar.svd();

      Matrix U = svd.getU();

      double[] d1 = normalize(column(U, 1));
      double[] d2 = normalize(column(U, 2));

      String[] genes = coefs.genes();

      DataFrame<MultilevelCoefs.XYPoint> points =
          new DataFrame<MultilevelCoefs.XYPoint>(MultilevelCoefs.XYPoint.class);

      for (int i = 0; i < genes.length; i++) {
        double[] gr = row(matrix, i);
        double x = inner(gr, d1), y = inner(gr, d2);
        MultilevelCoefs.XYPoint point = new MultilevelCoefs.XYPoint(x, y, genes[i]);
        points.addObject(point);
        System.out.println(point.toString());
      }

      System.out.println("U: ");
      println(U, System.out);

      ModelScatter scatter = new ModelScatter();
      scatter.addModels(points.iterator());

      scatter.setProperty(ModelScatter.colorKey, Coloring.clearer(Color.red));

      coefs.save(
          new File(
              String.format(
                  "C:\\Documents and Settings\\tdanford\\Desktop\\sigma_%s.txt", args.compare)));

      new ModelScatter.InteractiveFrame(scatter, "PCA");

    } catch (IOException e) {
      e.printStackTrace();
    }
  }