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(); } } }
/** * This method should return a tree with calculation results or null, if analysis start was * canceled. * * @param framework the reference to <code>IFramework</code> implementation, which is used to * obtain an initial analysis data and parameters. * @throws AlgorithmException if calculation was failed. * @throws AbortException if calculation was canceled. * @see IFramework */ public DefaultMutableTreeNode execute(IFramework framework) throws AlgorithmException { if (sysMsg("R 2.11.x", "DEGSeq") != JOptionPane.OK_OPTION) return null; this.data = framework.getData(); exptNamesVector = new Vector<String>(); for (int i = 0; i < this.data.getFeaturesCount(); i++) { exptNamesVector.add(framework.getData().getFullSampleName(i)); } DEGseqInitBox DEGseqDialog = new DEGseqInitBox( (JFrame) framework.getFrame(), true, exptNamesVector, framework.getClusterRepository(1)); DEGseqDialog.setVisible(true); if (!DEGseqDialog.isOkPressed()) return null; infMethod = DEGseqDialog.getMethodName(); sigMethod = DEGseqDialog.getCutOffField(); sigCutOff = DEGseqDialog.getPValue(); dataDesign = DEGseqDialog.getTestDesign(); if (DEGseqDialog.getTestDesign() == DEGseqInitBox.TWO_CLASS) { groupAssignments = DEGseqDialog.getTwoClassAssignments(); if (DEGseqDialog.getSelectionDesign() == DEGseqInitBox.CLUSTER_SELECTION) { groupAssignments = DEGseqDialog.getClusterTwoClassAssignments(); } if (DEGseqDialog.getSelectionDesign() == DEGseqInitBox.BUTTON_SELECTION) { groupAssignments = DEGseqDialog.getTwoClassAssignments(); } } // count # of samples used in analysis int samplesUsed = 0; for (int i = 0; i < groupAssignments.length; i++) { if (groupAssignments[i] != 0) samplesUsed++; } // get samples indices used int sampleIndices[] = new int[samplesUsed]; for (int i = 0, ii = 0; i < groupAssignments.length; i++) { if (groupAssignments[i] != 0) sampleIndices[ii++] = i; } // set up the group struct for algo int[] twoClassGrps = new int[samplesUsed]; for (int i = 0, ii = 0; i < groupAssignments.length; i++) { if (groupAssignments[i] != 0) twoClassGrps[ii++] = groupAssignments[i]; } // Test int grp1 = 0; int grp2 = 0; String grp1ColIndStr = ""; String grp2ColIndStr = ""; for (int i = 0; i < twoClassGrps.length; i++) { if (twoClassGrps[i] == 1) { grp1++; grp1ColIndStr += String.valueOf(i + 2) + ","; // 1 for 0 based index, 1 for UID col in file } if (twoClassGrps[i] == 2) { grp2++; grp2ColIndStr += String.valueOf(i + 2) + ","; } } // remove last "," grp1ColIndStr = grp1ColIndStr.substring(0, grp1ColIndStr.lastIndexOf(",")); grp2ColIndStr = grp2ColIndStr.substring(0, grp2ColIndStr.lastIndexOf(",")); System.out.println("groupAssignments: " + Arrays.toString(groupAssignments)); System.out.println("twoClassGrps: " + Arrays.toString(twoClassGrps)); System.out.println( samplesUsed + " out of " + groupAssignments.length + " used. Sample indices: " + Arrays.toString(sampleIndices)); System.out.println("grp1ColInd: " + grp1ColIndStr); System.out.println("grp2ColInd: " + grp2ColIndStr); this.experiment = framework.getData().getExperiment(); // int number_of_samples = this.data.getFeaturesCount();//experiment.getNumberOfSamples(); // int [] columnIndices = experiment.getColumnIndicesCopy(); sampleLabels = new ArrayList<String>(); geneLabels = new ArrayList<String>(); for (int i = 0; i < samplesUsed; i++) { sampleLabels.add(framework.getData().getFullSampleName(sampleIndices[i])); // Raktim } // Raktim Use probe index as the gene labels in R for (int i = 0; i < this.data.getFeaturesSize(); /*experiment.getNumberOfGenes();*/ i++) { // geneLabels.add(framework.getData().getElementAnnotation(i, // AnnotationFieldConstants.PROBE_ID)[0]); //Raktim geneLabels.add(String.valueOf(i)); } // Make Count Matrix based on data int numGenes = this.data.getFeaturesSize(); System.out.println( "data.getFeaturesCount(): " + this.data.getFeaturesCount() + " data.getFeaturesSize(): " + this.data.getFeaturesSize()); ArrayList<IRNASeqSlide> temp = (ArrayList<IRNASeqSlide>) data.getFeaturesList(); // TEst Code from EH RNASeqChipAnnotation chipAnnotation = (RNASeqChipAnnotation) data.getChipAnnotation(); System.out.println("Library size, first sample: " + temp.get(0).getLibrarySize()); System.out.println("Library size, last sample: " + temp.get(temp.size() - 1).getLibrarySize()); System.out.println("\n"); System.out.println("Read length: " + chipAnnotation.getReadLength()); System.out.println("\n"); System.out.println("first count value for first slide: " + temp.get(0).getCount(0)); System.out.println( "last count value for first slide: " + temp.get(0).getCount(temp.get(0).getSize() - 1)); System.out.println("\n"); System.out.println( "first count value for last slide: " + temp.get(temp.size() - 1).getCount(0)); System.out.println( "last count value for last slide: " + temp.get(temp.size() - 1).getCount(temp.get(0).getSize() - 1)); System.out.println("\n"); System.out.println( "transcript length 0,0: " + ((RNASeqElement) (temp.get(0).getSlideDataElement(0))).getTranscriptLength()); System.out.println( "classcode for 0,0: " + ((RNASeqElement) (temp.get(0).getSlideDataElement(0))).getClasscode()); // End EH Test Code // My test code // System.out.println("transcript length 0,0: " + // ((RNASeqElement)(temp.get(0).getSlideDataElement(9))).getTranscriptLength()); // System.out.println("classcode for 0,0: " + // ((RNASeqElement)(temp.get(0).getSlideDataElement(9))).getClasscode()); // End my test code /** ArrayList<IRNASeqSlide> temp = (ArrayList<IRNASeqSlide>)data.getFeaturesList(); */ int[][] countMatrix = new int[numGenes][samplesUsed]; int[] libSize = new int[samplesUsed]; for (int row = 0; row < numGenes; row++) { for (int col = 0; col < sampleIndices.length; col++) { // get count value countMatrix[row][col] = temp.get(sampleIndices[col]).getCount(row); } // get transcript len for each gene // transcriptLen[row] = // ((RNASeqElement)(temp.get(row).getSlideDataElement(row))).getTranscriptLength(); // transcriptLen[row] = // ((RNASeqElement)(temp.get(0).getSlideDataElement(row))).getTranscriptLength(); } // get lib size for each sample used for (int col = 0; col < sampleIndices.length; col++) { // get count value libSize[col] = temp.get(sampleIndices[col]).getLibrarySize(); } // System.out.println("CountMatrix: " + Arrays.deepToString(countMatrix)); // System.out.println("transcriptLen: " + Arrays.toString(transcriptLen)); // System.out.println("libSize: " + Arrays.toString(libSize)); Listener listener = new Listener(); try { algorithm = framework.getAlgorithmFactory().getAlgorithm("DEGSEQ"); algorithm.addAlgorithmListener(listener); this.progress = new Progress(framework.getFrame(), "Running DEGseq ...", listener); this.progress.show(); AlgorithmData data = new AlgorithmData(); data.addIntMatrix("experiment", countMatrix); data.addParam("dataDesign", String.valueOf(dataDesign)); data.addIntArray("group_assignments", twoClassGrps); data.addParam("grp1ColIndStr", grp1ColIndStr); data.addParam("grp2ColIndStr", grp2ColIndStr); data.addIntArray("libSize", libSize); data.addParam("numGenes", String.valueOf(numGenes)); data.addParam("numExps", String.valueOf(samplesUsed)); data.addParam("grp1", String.valueOf(grp1)); data.addParam("grp2", String.valueOf(grp2)); data.addParam("infMethod", infMethod); data.addStringArray("geneLabels", geneLabels.toArray(new String[geneLabels.size()])); data.addStringArray("sampleLabels", sampleLabels.toArray(new String[sampleLabels.size()])); // run algorithm long start = System.currentTimeMillis(); AlgorithmData result = algorithm.execute(data); long time = System.currentTimeMillis() - start; // getting the results resultMatrix = result.getMatrix("result"); resultRowNames = result.getStringArray("rownames"); // System.out.println(Arrays.toString(resultRowNames)); // Process results createHeaderNames(); createAuxData(); createResultClusters(); GeneralInfo info = new GeneralInfo(); info.time = time; System.out.println("Creating Viewers for DEGSeq..."); return createResultTree(info); } finally { if (algorithm != null) { algorithm.removeAlgorithmListener(listener); } if (progress != null) { progress.dispose(); } } }