コード例 #1
0
  public static HashMap<String, Double> getOneWayAnovaPValues(ENode root) throws Exception {
    HashMap<String, Double> returnMap = new HashMap<String, Double>();
    HashMap<Float, List<ENode>> map = ReadCluster.getMapByLevel(root);
    System.out.println(map.size());

    for (Float f : map.keySet()) {
      File outFile =
          new File(
              ConfigReader.getETreeTestDir()
                  + File.separator
                  + "Mel74ColumnsAsTaxaFor"
                  + f
                  + ".txt");
      System.out.println(outFile.getAbsolutePath());
      PivotOut.pivotOut(map.get(f), outFile.getAbsolutePath());
      OtuWrapper wrapper = new OtuWrapper(outFile);
      List<List<Double>> list = wrapper.getDataPointsNormalizedThenLogged();

      for (int x = 0; x < wrapper.getOtuNames().size(); x++) {
        double pValue = 1;

        if (!wrapper.getOtuNames().get(x).equals(ETree.ROOT_NAME)) {
          List<Number> data = new ArrayList<Number>();
          List<String> factors = new ArrayList<String>();
          for (int y = 0; y < wrapper.getSampleNames().size(); y++) {
            if (!wrapper.getSampleNames().get(y).equals(ETree.ROOT_NAME)) {
              data.add(list.get(y).get(x));
              factors.add("" + stripSuffix(wrapper.getSampleNames().get(y)));
            }
          }

          OneWayAnova owa = new OneWayAnova(data, factors);

          if (map.containsKey(wrapper.getOtuNames().get(x))) throw new Exception("Duplicate");

          pValue = owa.getPValue();
        }

        returnMap.put(wrapper.getOtuNames().get(x), pValue);
      }
    }

    return returnMap;
  }
コード例 #2
0
  public static void main(String[] args) throws Exception {
    File topDir = new File(ConfigReader.getVanderbiltDir() + File.separator + "krakenOut");

    for (int x = 0; x < KRAKEN_LEVELS.length; x++) {
      HashMap<String, HashMap<String, Integer>> map =
          new HashMap<String, HashMap<String, Integer>>();

      System.out.println(KRAKEN_LEVELS[x]);
      for (String s : topDir.list())
        if (s.startsWith("standardReport_for_Sample_") && s.indexOf("16S") == -1) {
          // System.out.println("NON 16S " + s);
          addToMap(new File(topDir.getAbsolutePath() + File.separator + s), map, KRAKEN_LEVELS[x]);
        }

      File outFile =
          new File(
              ConfigReader.getVanderbiltDir()
                  + File.separator
                  + "spreadsheets"
                  + File.separator
                  + "kraken_"
                  + RDP_LEVELS[x]
                  + "_taxaAsColumns.txt");
      PivotOTUs.writeResults(map, outFile.getAbsolutePath());

      OtuWrapper wrapper = new OtuWrapper(outFile);
      wrapper.writeNormalizedLoggedDataToFile(
          ConfigReader.getVanderbiltDir()
              + File.separator
              + "spreadsheets"
              + File.separator
              + "kraken_"
              + RDP_LEVELS[x]
              + "_taxaAsColumnsLogNorm.txt");
    }

    for (int x = 0; x < KRAKEN_LEVELS.length; x++) {
      HashMap<String, HashMap<String, Integer>> map =
          new HashMap<String, HashMap<String, Integer>>();

      System.out.println(KRAKEN_LEVELS[x]);
      for (String s : topDir.list()) {
        // System.out.println(s);
        if (s.startsWith("standardReport_for_") && s.indexOf("16S") != -1) {
          // System.out.println("For 16S " + s);
          addToMap(new File(topDir.getAbsolutePath() + File.separator + s), map, KRAKEN_LEVELS[x]);
        }
      }

      File outFile =
          new File(
              ConfigReader.getVanderbiltDir()
                  + File.separator
                  + "spreadsheets"
                  + File.separator
                  + "kraken_"
                  + RDP_LEVELS[x]
                  + "_taxaAsColumnsFor16S.txt");
      PivotOTUs.writeResults(map, outFile.getAbsolutePath());

      OtuWrapper wrapper = new OtuWrapper(outFile);
      wrapper.writeNormalizedLoggedDataToFile(
          ConfigReader.getVanderbiltDir()
              + File.separator
              + "spreadsheets"
              + File.separator
              + "kraken_"
              + RDP_LEVELS[x]
              + "_taxaAsColumnsLogNormFor16S.txt");
    }
  }