Example #1
0
 private void setClusters(int[][] sampleArray) {
   if (sampleArray == null || sampleArray.length == 0) sampleArray = new int[1][];
   clusterCount = sampleArray.length;
   clusterNames = new String[clusterCount];
   clusterColors = new Color[clusterCount];
   clusters = new int[clusterCount][];
   for (int i = 0; i < clusterCount; i++) {
     if (sampleArray[i] == null) {
       int numSamps = experiment.getNumberOfSamples();
       clusters[i] = new int[numSamps];
       for (int j = 0; j < numSamps; j++) {
         clusters[i][j] = j;
       }
       clusterColors[i] = Color.white;
       clusterNames[i] = "All Samples";
     } else {
       clusters[i] = sampleArray[i];
       clusterColors[i] = createClusterColor(i);
       if (sampleClusterNames == null || sampleClusterNames[i].length() < 1) {
         clusterNames[i] = "(Group " + (i + 1) + ")";
       } else {
         clusterNames[i] = sampleClusterNames[i];
       }
     }
   }
 }
Example #2
0
  public AlgorithmData getScriptParameters(IFramework framework) {

    this.experiment = framework.getData().getExperiment();
    exptNamesVector = new Vector<String>();
    int number_of_samples = experiment.getNumberOfSamples();
    // int number_of_genes = experiment.getNumberOfGenes();

    for (int i = 0; i < number_of_samples; i++) {
      exptNamesVector.add(framework.getData().getFullSampleName(experiment.getSampleIndex(i)));
    }

    DEGseqInitBox DEGseqDialog =
        new DEGseqInitBox(
            (JFrame) framework.getFrame(), true, exptNamesVector, framework.getClusterRepository(1)
            // framework.getClusterRepository(0)
            );
    DEGseqDialog.setVisible(true);

    if (!DEGseqDialog.isOkPressed()) return null;

    if (DEGseqDialog.getTestDesign() == DEGseqInitBox.TWO_CLASS) {
      if (DEGseqDialog.getSelectionDesign() == DEGseqInitBox.CLUSTER_SELECTION) {
        groupAssignments = DEGseqDialog.getClusterTwoClassAssignments();
      }
      if (DEGseqDialog.getSelectionDesign() == DEGseqInitBox.BUTTON_SELECTION) {
        groupAssignments = DEGseqDialog.getTwoClassAssignments();
      }
    }

    AlgorithmData data = new AlgorithmData();

    // alg name
    data.addParam("name", "DESeq");

    // alg type
    data.addParam("alg-type", "data-visualization");

    // output class
    data.addParam("output-class", "partition-output");

    // output nodes
    String[] outputNodes = new String[2];
    outputNodes[0] = "Significant Genes";
    outputNodes[1] = "Non-significant Genes";

    data.addStringArray("output-nodes", outputNodes);

    return data;
  }
Example #3
0
  public DefaultMutableTreeNode executeScript(
      IFramework framework, AlgorithmData algData, Experiment experiment)
      throws AlgorithmException {

    Listener listener = new Listener();
    this.experiment = experiment;
    this.data = framework.getData();
    // this.timeAssignments = algData.getIntArray("time_assignments");
    this.groupAssignments = algData.getIntArray("condition_assignments");

    exptNamesVector = new Vector<String>();
    int number_of_samples = experiment.getNumberOfSamples();

    for (int i = 0; i < number_of_samples; i++) {
      exptNamesVector.add(this.data.getFullSampleName(i));
    }

    try {
      algData.addMatrix("experiment", experiment.getMatrix());
      algorithm = framework.getAlgorithmFactory().getAlgorithm("MINET");
      algorithm.addAlgorithmListener(listener);

      this.progress = new Progress(framework.getFrame(), "Running MINET Analysis...", listener);
      this.progress.show();

      long start = System.currentTimeMillis();
      AlgorithmData result = algorithm.execute(algData);
      long time = System.currentTimeMillis() - start;

      AlgorithmParameters params = algData.getParams();

      GeneralInfo info = new GeneralInfo();
      return createResultTree(info);

    } finally {
      if (algorithm != null) {
        algorithm.removeAlgorithmListener(listener);
      }
      if (progress != null) {
        progress.dispose();
      }
    }
  }
Example #4
0
 public void setClusters(Cluster[] clusterArray) {
   if (clusterArray == null || clusterArray.length == 0) clusterArray = new Cluster[1];
   clusterCount = clusterArray.length;
   clusterNames = new String[clusterCount];
   clusterColors = new Color[clusterCount];
   clusters = new int[clusterCount][];
   for (int i = 0; i < clusterCount; i++) {
     if (clusterArray[i] == null) {
       int numSamps = experiment.getNumberOfSamples();
       clusters[i] = new int[numSamps];
       for (int j = 0; j < numSamps; j++) {
         clusters[i][j] = j;
       }
       clusterColors[i] = Color.white;
       clusterNames[i] = "All Samples";
     } else {
       clusters[i] = clusterArray[i].getIndices();
       clusterColors[i] = clusterArray[i].getClusterColor();
       clusterNames[i] = clusterArray[i].getClusterLabel();
       if (clusterNames[i].length() < 1) clusterNames[i] = "(Cluster " + (i + 1) + ")";
     }
   }
 }
Example #5
0
  private void saveCluster(File file, Experiment experiment, IData data, int[] rows)
      throws Exception {
    PrintWriter out = new PrintWriter(new FileOutputStream(file));
    String[] fieldNames = data.getFieldNames();
    out.print("Original row");
    out.print("\t");
    for (int i = 0; i < fieldNames.length; i++) {
      out.print(fieldNames[i]);
      // if (i < fieldNames.length - 1) {
      out.print("\t");
      // }
    }
    for (int i = 0; i < geneGroupMeans[0].length; i++) {
      out.print("Group" + (i + 1) + " mean\t");
      out.print("Group" + (i + 1) + " std.dev.\t");
    }
    // out.print("\t");
    out.print("F ratio");
    out.print("\t");
    out.print("SS(Groups)\t");
    out.print("SS(Error)\t");
    out.print("df (Groups)\t");
    out.print("df (Error)\t");
    out.print("raw p value\t");
    out.print("adj p value");

    // out.print("UniqueID\tName");
    for (int i = 0; i < experiment.getNumberOfSamples(); i++) {
      out.print("\t");
      out.print(data.getFullSampleName(experiment.getSampleIndex(i)));
    }
    out.print("\n");
    for (int i = 0; i < rows.length; i++) {
      out.print(Integer.toString(experiment.getGeneIndexMappedToData(rows[i]) + 1));
      // out.print(data.getUniqueId(rows[i]));
      out.print("\t");
      // out.print(data.getGeneName(rows[i]));
      for (int k = 0; k < fieldNames.length; k++) {
        out.print(data.getElementAttribute(experiment.getGeneIndexMappedToData(rows[i]), k));
        // if (k < fieldNames.length - 1) {
        out.print("\t");
        // }
      }
      for (int j = 0; j < geneGroupMeans[rows[i]].length; j++) {
        out.print(geneGroupMeans[rows[i]][j] + "\t");
        out.print(geneGroupSDs[rows[i]][j] + "\t");
      }
      // out.print("\t");
      out.print("" + ((Float) fValues.get(rows[i])).floatValue());
      out.print("\t");
      out.print("" + ((Float) ssGroups.get(rows[i])).floatValue());
      out.print("\t");
      out.print("" + ((Float) ssError.get(rows[i])).floatValue());
      out.print("\t");
      out.print("" + ((Float) dfNumValues.get(rows[i])).floatValue());
      out.print("\t");
      out.print("" + ((Float) dfDenomValues.get(rows[i])).floatValue());
      out.print("\t");
      out.print("" + ((Float) rawPValues.get(rows[i])).floatValue());
      out.print("\t");
      out.print("" + ((Float) adjPValues.get(rows[i])).floatValue());
      for (int j = 0; j < experiment.getNumberOfSamples(); j++) {
        out.print("\t");
        out.print(Float.toString(experiment.get(rows[i], j)));
      }
      out.print("\n");
    }
    out.flush();
    out.close();
  }