Author: shirleyh
Date: 2008-09-23 12:07:05 -0700 (Tue, 23 Sep 2008)
New Revision: 14943
Removed:
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateProgressBar.java
Modified:
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/jmathplot/gui/FrameView.java
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateHistogramWindow.java
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateMenuListener.java
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateSimilarityNetwork.java
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/ExpressionCorrelationAboutDialog.java
Log:
Updated Expression Correlation Plugin to work with Cytoscape 2.6.0
Modified:
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/jmathplot/gui/FrameView.java
===================================================================
---
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/jmathplot/gui/FrameView.java
2008-09-23 19:03:23 UTC (rev 14942)
+++
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/jmathplot/gui/FrameView.java
2008-09-23 19:07:05 UTC (rev 14943)
@@ -8,15 +8,17 @@
public FrameView(JPanel panel) {
setContentPane(panel);
pack();
- show();
+ //show();
+ setVisible(true);
}
public FrameView(String title, JPanel panel) {
super(title);
setContentPane(panel);
pack();
- show();
- }
+ //show();
+ setVisible(true);
+ }
public FrameView(JPanel[] panels) {
JPanel panel = new JPanel();
@@ -25,7 +27,8 @@
}
setContentPane(panel);
pack();
- show();
- }
+ //show();
+ setVisible(true);
+ }
}
\ No newline at end of file
Modified:
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateHistogramWindow.java
===================================================================
---
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateHistogramWindow.java
2008-09-23 19:03:23 UTC (rev 14942)
+++
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateHistogramWindow.java
2008-09-23 19:07:05 UTC (rev 14943)
@@ -11,6 +11,12 @@
import java.beans.PropertyChangeListener;
import java.text.DecimalFormat;
+import cytoscape.task.Task;
+import cytoscape.task.util.TaskManager;
+import cytoscape.task.ui.JTaskConfig;
+import cytoscape.Cytoscape;
+import cytoscape.CytoscapeInit;
+
/* * Copyright (c) 2004 Memorial Sloan-Kettering Cancer Center
* *
* * Code written by: Elena Potylitsine
@@ -55,7 +61,6 @@
public class CorrelateHistogramWindow extends JDialog {
private CorrelateSimilarityNetwork network; //Instance of the
Similarity network function
- CorrelateProgressBar bar = new CorrelateProgressBar(); //Instance of
the timed progress bar
JFormattedTextField lowCutoffValue; //Formated field for input of
the low cutoff value
JFormattedTextField highCutoffValue; //Formated field for input of
the high cutoff value
JFormattedTextField interactionsValue; //Formated field to hold the
number or percent of interactions
@@ -71,7 +76,6 @@
Number valueInteractions; //Holds either the percent or
the number of interactions value
String selectedString = "Number of Interactions"; //represents the choice
from the combo box
-
/**
* One histogram window is generated for either the column or row
similarity matrix calculation
*
@@ -79,7 +83,8 @@
* @param row - boolean variable is true if the matrix being
worked on is the row matrix
* @param newNetwork - instance of the SimilarityMatrix
*/
- public CorrelateHistogramWindow(Frame parentFrame, boolean row,
CorrelateSimilarityNetwork newNetwork, CorrelateProgressBarDialog
progressBarDialog) {
+ public CorrelateHistogramWindow(Frame parentFrame, boolean row,
CorrelateSimilarityNetwork newNetwork) {
+
super(parentFrame, "Matrix Parameters", false);
setResizable(false);
isRow = row;
@@ -92,7 +97,8 @@
network.loadColCutoffs(); //Loads previously saved user column
cutoffs from the singleton class
network.colHistogram(); // get image and values
}
- if(progressBarDialog.isCancelled()) {
+ if (network.cancelled())
+ {
return;
}
DecimalFormat decFormat = new DecimalFormat();
@@ -111,6 +117,7 @@
return new JMultiLineToolTip();
}
};
+
lowCutoffValue.setColumns(4); // 3 + space for the neative sign
lowCutoffValue.addPropertyChangeListener("value", new
CorrelateHistogramWindow.formattedTextFieldAction());
String tipLow = "Look at the Histogram and set the low cutoff for the
network that you want displayed.\n" +
@@ -147,6 +154,7 @@
return new JMultiLineToolTip();
}
};
+
highCutoffValue.setColumns(3);
highCutoffValue.addPropertyChangeListener("value", new
CorrelateHistogramWindow.formattedTextFieldAction());
String tipHigh = "Look at the Histogram and set the high cutoff for
the network that you want displayed.\n" +
@@ -186,6 +194,7 @@
return new JMultiLineToolTip();
}
};
+
interactionsValue.setColumns(6);
interactionsValue.addPropertyChangeListener("value", new
CorrelateHistogramWindow.formattedTextFieldAction());
String tipSize = "Select either the number of interactions you want
displayed.\n" +
@@ -205,7 +214,6 @@
labelFieldPanelsize.add(interactionsValue);
Interactions.add(labelFieldPanelsize, BorderLayout.WEST);
-
String tipInteractions = "Check this box to create a Network with the
Number of Interactions \n"
+ "you want displayed and to set the appropriate cutoffs";
@@ -225,9 +233,6 @@
Interactions.add(labelFieldPanelPercentNumber, BorderLayout.EAST);
Interactions.setBorder(BorderFactory.createEtchedBorder());
-
-
-
//Ok and Cancel Options
JPanel bottomPanel = new JPanel(new FlowLayout());
@@ -247,8 +252,6 @@
panel.add(histoPlot, BorderLayout.CENTER);
panel.add(bottomPanel, BorderLayout.SOUTH);
setContentPane(panel);
-
-
}
/**
@@ -488,21 +491,44 @@
public void actionPerformed(ActionEvent e) {
dialog.dispose();
+ int viewThreshold = 1000;
+ int event = 2;
+ try
+ {
+ viewThreshold =
Integer.parseInt(CytoscapeInit.getProperties().getProperty("viewThreshold"));
+ System.out.println("viewThreshold is " + viewThreshold);
+ } catch (NumberFormatException nfe)
+ {
+ viewThreshold = 0;
+ }
if (isRow) {
interactionsGetSet();
- if (network.getNumberOfInteractions(isRow,
network.getCutoffs(isRow)) < 1000) //if fewer then 1000
- network.setAutoView(true); //allows to view the network
network.saveRowCutoffs();//Saves the row cutoffs in singleton
- bar.CorrelateProgressBar(4, network); // 4 indicates to do the
row netowrk timed event to CorrelateProgressBar
+ event = 4;
} else {
interactionsGetSet();
- if (network.getNumberOfInteractions(isRow,
network.getCutoffs(isRow)) < 1000)
- network.setAutoView(true);
network.saveColCutoffs(); //Saves the column cutoffs in
singleton
- bar.CorrelateProgressBar(2, network); //2 indicates to do the
column network timed event to CorrelateProgressBar
}
+
cutoffs = network.getCutoffs(isRow);
- // System.out.println("The cutoffs selected are: "+cutoffs[0]+" |
"+cutoffs[1]);
+
+ // Create a Correlate Task
+ Task task = new CorrelateTask(event, network);
+
+ // Configure JTask
+ JTaskConfig config = new JTaskConfig();
+ config.setOwner(Cytoscape.getDesktop());
+ config.displayCloseButton(true);
+ config.displayCancelButton(true);
+ config.displayStatus(true);
+
+ // Execute Task via TaskManager
+ // This automatically pops-open a JTask Dialog Box.
+ // This method will block until the JTask Dialog Box is disposed.
+ boolean success = TaskManager.executeTask(task, config);
+
+ cutoffs = network.getCutoffs(isRow);
+ //System.out.println("The cutoffs selected are: "+cutoffs[0]+" |
"+cutoffs[1]);
}
}
@@ -524,4 +550,5 @@
dialog.dispose();
}
}
+
}
\ No newline at end of file
Modified:
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateMenuListener.java
===================================================================
---
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateMenuListener.java
2008-09-23 19:03:23 UTC (rev 14942)
+++
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateMenuListener.java
2008-09-23 19:07:05 UTC (rev 14943)
@@ -1,6 +1,9 @@
package org.mskcc.csplugins.ExpressionCorrelation;
import cytoscape.Cytoscape;
+import cytoscape.task.Task;
+import cytoscape.task.util.TaskManager;
+import cytoscape.task.ui.JTaskConfig;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -58,8 +61,7 @@
JMenuItem source = (JMenuItem) (event.getSource());
selection = source.getText();
-
- if (Cytoscape.getCurrentNetwork().getExpressionData() == null) {
+ if (Cytoscape.getExpressionData() == null) {
JOptionPane.showMessageDialog(Cytoscape.getDesktop(), "You must
load an Expression Matrix File to run this plugin.", "ALERT!!!",
JOptionPane.ERROR_MESSAGE);
} else {
int colNumber = network.getNumberOfCols(); //number of conditions
in the condition network
@@ -102,14 +104,27 @@
performEvent = setEvent(selection);
}
System.out.println("the selection was: " + selection);
- CorrelateProgressBar bar = new CorrelateProgressBar();
- bar.CorrelateProgressBar(performEvent, network);
+ // Create a Correlate Task
+ Task task = new CorrelateTask(performEvent, network);
+
+ // Configure JTask
+ JTaskConfig config = new JTaskConfig();
+ config.setOwner(Cytoscape.getDesktop());
+ config.displayCloseButton(true);
+ config.displayCancelButton(true);
+ config.displayStatus(true);
+
+ // Execute Task via TaskManager
+ // This automatically pops-open a JTask Dialog Box.
+ // This method will block until the JTask Dialog Box is disposed.
+ boolean success = TaskManager.executeTask(task, config);
+
}
}
public int setEvent(String selection) {
int newEvent = 0;
- if (selection.equals("Construct Similarity Network")) {
+ if (selection.equals("Construct Correlation Network")) {
newEvent = 1; //construct both row and column
}
if (selection.equals("Condition Network: Preview Histogram")) {
Deleted:
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateProgressBar.java
===================================================================
---
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateProgressBar.java
2008-09-23 19:03:23 UTC (rev 14942)
+++
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateProgressBar.java
2008-09-23 19:07:05 UTC (rev 14943)
@@ -1,235 +0,0 @@
-package org.mskcc.csplugins.ExpressionCorrelation;
-
-import cytoscape.Cytoscape;
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-
-/**
- * Copyright (c) 2004 Memorial Sloan-Kettering Cancer Center
- * *
- * * Code written by: Elena Potylitsine
- * * Authors: Gary Bader, Elena Potylitsine, Chris Sander, Weston Whitaker
- * *
- * * This library is free software; you can redistribute it and/or modify it
- * * under the terms of the GNU Lesser General Public License as published
- * * by the Free Software Foundation; either version 2.1 of the License, or
- * * any later version.
- * *
- * * This library is distributed in the hope that it will be useful, but
- * * WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- * * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- * * documentation provided hereunder is on an "as is" basis, and
- * * Memorial Sloan-Kettering Cancer Center
- * * has no obligations to provide maintenance, support,
- * * updates, enhancements or modifications. In no event shall the
- * * Memorial Sloan-Kettering Cancer Center
- * * be liable to any party for direct, indirect, special,
- * * incidental or consequential damages, including lost profits, arising
- * * out of the use of this software and its documentation, even if
- * * Memorial Sloan-Kettering Cancer Center
- * * has been advised of the possibility of such damage. See
- * * the GNU Lesser General Public License for more details.
- * *
- * * You should have received a copy of the GNU Lesser General Public License
- * * along with this library; if not, write to the Free Software Foundation,
- * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- * *
- * * User: Elena Potylitsine
- * * Date: Jul 7, 2004
- * * Time: 3:35:11 PM
- * * Description: CorrelateProgressBar for timing of long running events
- * *
- * *
- */
-
-public class CorrelateProgressBar {
- private CorrelateSimilarityNetwork network;
- final CorrelateProgressBarDialog progressBarDialog = new
CorrelateProgressBarDialog(Cytoscape.getDesktop());
- Timer timer; //Instance of timer
- boolean colDone = false; //becomes true when the column
network is complete
- public int performEvent = 0; /**Sets which event thread to run
and time
- *case 1: Run and time both the column and row networks
- *case 2: Run and time the column network
- *case 3: Run and time the column histogram
- *case 4: Run and time the row network
- *case 5: Run and time the row histogram
- */
-
- /**
- * progress_bar runs and monitores the event thread chosen
- *
- * @param newEvent - the chosen event thread to run
- * @param newNetwork - instance of network
- */
- public void CorrelateProgressBar(int newEvent, CorrelateSimilarityNetwork
newNetwork) {
-//set up progress bar
- network = newNetwork;
- progressBarDialog.setIndeterminate(false);
- progressBarDialog.pack();
- progressBarDialog.setVisible(true);
-
- performEvent = newEvent;
-
- //Set up the timer class
- timer = new Timer(1000, new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- if(progressBarDialog.isCancelled()) {
- network.cancel();
- progressBarDialog.dispose();
- timer.stop();
- }
- switch (performEvent) {
- case 1:
- if (colDone) //case one for doing both timing column
and the row network creation
- rowProgress();
- else
- colProgress();
- break;
- case 2:
- colProgress();
- break; //timing of the column network creation
- case 3:
- colProgress();
- break; //timing of the histogram
- case 4:
- rowProgress();
- break; //timing of the row network creation
- case 5:
- rowProgress();
- break;
- }
- }
- });
-
- //threaded not to interfere with cytoscape
- final SwingWorker worker = new SwingWorker() {
- public Object construct() {
- switch (performEvent) {
- case 1:
- colRun();
- rowRun();
- break;
- case 2:
- colRun();
- break;
- case 3:
- colHistogram();
- break;
- case 4:
- rowRun();
- break;
- case 5:
- rowHistogram();
- break;
- }
- if (progressBarDialog.isCancelled()) {
- progressBarDialog.dispose();
- }
- return null;
- }
-
- /**
- * Called on the event dispatching thread (not on the worker
thread)
- * after the <code>construct</code> method has returned.
- */
- public void finished() {
- //Can do gui work here
- System.out.println("The network is complete");
- //progressBarDialog.setString("I am all DONE :)");
- timer.stop();
- progressBarDialog.dispose();
- }
-
- };
- worker.start();
- timer.start();
-
- }
-
-//timing for the condition matrix calculation
- public void colProgress() {
-
- progressBarDialog.setValue(network.getColCurrentStep());
- int steps = 0;
- if (progressBarDialog.getIndeterminate()) //if in indeterminate mode
then get steps
- {
- progressBarDialog.setIndeterminate(false);
- steps = network.getColTotalSteps();
- progressBarDialog.setLengthOfTask(steps);
- }
- if (network.colIsDone()) {
- progressBarDialog.setString("Loading the Matrix");
- progressBarDialog.setIndeterminate(true);
- colDone = true;
- }
- }
-
- //timing for the gene matrix calculation
- public void rowProgress() {
- progressBarDialog.setValue(network.getRowCurrentStep());
- int steps = 0;
- if (progressBarDialog.getIndeterminate()) //if in indeterminate mode
then get steps
- {
- progressBarDialog.setIndeterminate(false);
- steps = network.getRowTotalSteps();
- progressBarDialog.setLengthOfTask(steps);
- }
- if (network.rowIsDone()) {
- progressBarDialog.setString("Loading the Matrix");
- progressBarDialog.setIndeterminate(true);
- }
- }
-
- //the condition matrix calculation
- public void colRun() {
- if (Cytoscape.getCurrentNetwork().getExpressionData() != null) {
- progressBarDialog.setIndeterminate(true);
- progressBarDialog.setString("Calculating the Columns");
- network.calcCols();
- }
- }
-
- //the gene matrix calculation
- public void rowRun() {
- if (Cytoscape.getCurrentNetwork().getExpressionData() != null) {
-
- progressBarDialog.setString("Calculating the Rows");
- System.out.println("starting rows");
- progressBarDialog.setIndeterminate(true);
- network.calcRows();
- }
- }
-
- //the histogram calculations
- public void colHistogram() {
- if (Cytoscape.getCurrentNetwork().getExpressionData() != null) {
-
- progressBarDialog.setString("Creating Column Histogram");
- System.out.println("starting col histogram");
- progressBarDialog.setIndeterminate(true);
- CorrelateHistogramWindow histogram = new
CorrelateHistogramWindow(Cytoscape.getDesktop(), false, network,
progressBarDialog); //not row histogram
- if (progressBarDialog.isCancelled()) {
- return;
- }
- histogram.pack();
- histogram.setVisible(true);
- }
- }
-
- public void rowHistogram() {
- if (Cytoscape.getCurrentNetwork().getExpressionData() != null) {
- progressBarDialog.setString("Creating Row Histogram");
- System.out.println("starting row histogram");
- progressBarDialog.setIndeterminate(true);
- CorrelateHistogramWindow histogram = new
CorrelateHistogramWindow(Cytoscape.getDesktop(), true, network,
progressBarDialog); //row histogram
- if (progressBarDialog.isCancelled()) {
- return;
- }
- histogram.pack();
- histogram.setVisible(true);
- }
- }
-}
\ No newline at end of file
Modified:
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateSimilarityNetwork.java
===================================================================
---
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateSimilarityNetwork.java
2008-09-23 19:03:23 UTC (rev 14942)
+++
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/CorrelateSimilarityNetwork.java
2008-09-23 19:07:05 UTC (rev 14943)
@@ -9,8 +9,11 @@
import cytoscape.CyNetwork;
import cytoscape.CyNode;
import cytoscape.Cytoscape;
+import cytoscape.data.CyAttributes;
+import cytoscape.CytoscapeInit;
import cytoscape.data.ExpressionData;
import cytoscape.data.mRNAMeasurement;
+import cytoscape.task.TaskMonitor;
import javax.swing.*;
import java.util.Vector;
@@ -93,8 +96,8 @@
private boolean cancel = false; //This will cancel the current
loop in calc() or histogram(). To use call cancel().
// The cancel value will automatically be reset to false
private int maxDigits = 5; //Max number of digits being
displayed. Does NOT affect histogram accuracy.
- private boolean autoView = false; //Automatically creates view
while network is being calculated (should be false for large networks)
-
+ private TaskMonitor taskMonitor = null;
+ //private SpearmanRank sr = null;
/**
* One instance of CorrelateSimilarityNetwork should be used for one gene
network and/or one condition network.
*/
@@ -132,7 +135,7 @@
* This gives the network the name of the expression data file.
*/
public void nameNetwork() {
- ExpressionData data =
Cytoscape.getCurrentNetwork().getExpressionData();
+ ExpressionData data = Cytoscape.getExpressionData();
String fullName = data.getFileName();
//System.out.println("File Name: "+fullName);
//fullName = fullName.substring(0,fullName.length()-2);
@@ -142,14 +145,6 @@
colNetName = name + " (conditions)";
}
- public void setAutoView(boolean createView) {
- autoView = createView;
- }
-
- public boolean getAutoView() {
- return autoView;
- }
-
public int getMaxDigits() {
return maxDigits;
}
@@ -239,7 +234,7 @@
*/
public CyNetwork calcRows(String networkName, double lowCutoff, double
highCutoff) {
rowDone = false;
- ExpressionData data =
Cytoscape.getCurrentNetwork().getExpressionData();
+ ExpressionData data = Cytoscape.getExpressionData();
return calcRows(networkName, data, lowCutoff, highCutoff);
}
@@ -266,6 +261,8 @@
rowDone = false;
String[] geneNames = data.getGeneNames();
DoubleMatrix2D inputMatrix = getExpressionMatrix(data);
+ //if (sr ==null)
+ // sr = new SpearmanRank(inputMatrix);
return calcRows(networkName, inputMatrix, lowCutoff, highCutoff,
geneNames);
}
@@ -312,7 +309,7 @@
*/
public CyNetwork calcRows(int geneNumber) {
rowDone = false;
- ExpressionData data =
Cytoscape.getCurrentNetwork().getExpressionData();
+ ExpressionData data = Cytoscape.getExpressionData();
String[] geneNames = data.getGeneNames();
DoubleMatrix2D inputMatrix = getExpressionMatrix(data);
return calc(true, inputMatrix, rowNegCutoff, rowPosCutoff, geneNames,
geneNumber);
@@ -413,7 +410,7 @@
*/
public CyNetwork calcCols(String networkName, double lowCutoff, double
highCutoff) {
colDone = false;
- ExpressionData data =
Cytoscape.getCurrentNetwork().getExpressionData();
+ ExpressionData data = Cytoscape.getExpressionData();
return calcCols(networkName, data, lowCutoff, highCutoff);
}
@@ -440,6 +437,8 @@
colDone = false;
String[] condNames = data.getConditionNames();
DoubleMatrix2D inputMatrix = getExpressionMatrix(data);
+ //if (sr ==null)
+ // sr = new SpearmanRank(inputMatrix);
return calc(false, networkName, inputMatrix, lowCutoff, highCutoff,
condNames);
}
@@ -487,7 +486,7 @@
*/
public CyNetwork calcCols(int condNumber) {
rowDone = false;
- ExpressionData data =
Cytoscape.getCurrentNetwork().getExpressionData();
+ ExpressionData data = Cytoscape.getExpressionData();
String[] condNames = data.getConditionNames();
DoubleMatrix2D inputMatrix = getExpressionMatrix(data);
return calc(false, inputMatrix, colNegCutoff, colPosCutoff, condNames,
condNumber);
@@ -527,10 +526,10 @@
* @return
*/
public CyNetwork calc(boolean isRowNetwork, String networkName,
DoubleMatrix2D inputMatrix, double lowCutoff, double highCutoff, String[]
names) {
- setView();
- //The network is automatically created, but must be manually viewed if
more than 1000 edges (using the "Create View" button in the "Edit" menu)
- CyNetwork newNetwork = Cytoscape.createNetwork(networkName);
+ // When creating the network, don't automatically create the network
view
+ CyNetwork newNetwork = Cytoscape.createNetwork(new int[] {}, new int[]
{}, networkName, null, false);
+
//Does some initial calculations and stores all the calculation data
initiationData data = new initiationData(isRowNetwork, inputMatrix,
true);
@@ -554,6 +553,17 @@
//This loop is set up to calculate the column correlations, so for the
row
// network the matrix has been transposed
+ if (taskMonitor != null)
+ {
+ String type = "condition";
+ if (isRowNetwork)
+ {
+ type = "gene";
+ }
+ taskMonitor.setPercentCompleted(-1);
+ taskMonitor.setStatus("Constructing " + type + " correlation
network...");
+ }
+
//Goes through each column
for (int i = 0; i < data.columns; i++) {
//Calculates the correlations for a single column
@@ -563,15 +573,32 @@
}
if ((i * 10) % (data.columns - mod) == 0) {
- System.out.print("*");
+ //System.out.print("*");
+ if (taskMonitor != null)
+ {
+ taskMonitor.setPercentCompleted((int)((double) (i * 100) /
data.columns));
+ }
}
}
+
+ if (taskMonitor != null)
+ {
+ taskMonitor.setPercentCompleted(100);
+ taskMonitor.setStatus("Finished constructing network");
+ }
+
if (isRowNetwork) {
rowDone = true;
} else {
colDone = true;
}
cancel = false;
+
+ // Create network view if number of nodes is below threshold
+ if (newNetwork.getNodeCount() < Integer.parseInt(CytoscapeInit
+ .getProperties().getProperty("viewThreshold")))
+ Cytoscape.createNetworkView(newNetwork);
+
return newNetwork;
}
@@ -588,9 +615,11 @@
*/
public CyNetwork calc(boolean isRowNetwork, DoubleMatrix2D inputMatrix,
double lowCutoff, double highCutoff, String[] names,
int number) {
- setView();
- //The network is automatically created, but must be manually viewed if
more than 1000 edges (using the "Create View" button in the "Edit" menu)
- CyNetwork newNetwork = Cytoscape.createNetwork(names[number]);
+
+ // When creating the network, don't automatically create the network
view
+ CyNetwork newNetwork = Cytoscape.createNetwork(new int[] {}, new int[]
{}, names[number], null, false);
+
+ //Does some initial calculations and stores all the calculation data
initiationData data = new initiationData(isRowNetwork, inputMatrix,
false);
double[] cutoffs = cutoffCheck(isRowNetwork, lowCutoff, highCutoff);
@@ -606,6 +635,12 @@
colDone = true;
}
cancel = false;
+
+ // Create network view if number of nodes is below threshold
+ if (newNetwork.getNodeCount() < Integer.parseInt(CytoscapeInit
+ .getProperties().getProperty("viewThreshold")))
+ Cytoscape.createNetworkView(newNetwork);
+
return newNetwork;
}
@@ -640,7 +675,9 @@
newEdge = Cytoscape.getCyEdge(names[i], names[i] + "_interaction_"
+ names[j], names[j], "neg_interaction");
}
Double value = new Double(corr);
- newNetwork.setEdgeAttributeValue(newEdge, "Strength", value);
+
+ CyAttributes attributes = Cytoscape.getEdgeAttributes();
+ attributes.setAttribute(newEdge.getIdentifier(),"Strength",value);
newNetwork.addEdge(newEdge);
}
@@ -662,6 +699,7 @@
public boolean usePos = true; //true if positive cutoffs are to
be considered
public boolean useNeg = true; //true if positive cutoffs are to
be considered
boolean fullNetwork; //true if the full network is being
calculated, false if only for one gene or condition
+ TaskMonitor taskMonitor = null;
/**
* Creating an instance of initiationData will automatically do all
the initial calculations
@@ -754,7 +792,6 @@
if (isRowNetwork) {
lowCutoff = rowNegCutoff;
highCutoff = rowPosCutoff;
- ;
} else {
lowCutoff = colNegCutoff;
highCutoff = colPosCutoff;
@@ -788,6 +825,10 @@
if (fullColumn) {
stop = data.columns;
}
+
+ //if (sr == null)
+ // sr = new SpearmanRank(data.inputMatrix);
+
for (int j = 0; j < stop; j++) {
if (data.isRowNetwork) {
rowCurrentStep++;
@@ -795,11 +836,12 @@
colCurrentStep++;
}
- //This is the correlation calculation
- double sumOfProducts = data.cols[i].zDotProduct(data.cols[j]);
- double cov = (sumOfProducts - data.sums[i] * data.sums[j] /
data.rows) / data.rows;
- double corr = cov / (data.stdDev.get(i) * data.stdDev.get(j));
+ double corr = calcPearsonCorr(data,i,j);
+ //double corr = sr.corr(i,j);
+ if (corr < -1.0)
+ continue;
+
//Creates nodes and edges if its above the positive cutoff
if (corr > highCutoff && i != j && data.usePos) {
createEdge(newNetwork, i, j, names, corr);
@@ -816,19 +858,6 @@
}
/**
- * This sets up cytoscape to either automatically display the network or
not display the network
- * If autoView is true, the network will be displayed as it is being
created
- * It should only be true for small networks
- */
- public void setView() {
- if (!autoView) {
- Cytoscape.getCytoscapeObj().setViewThreshold(0);
- } else {
- Cytoscape.getCytoscapeObj().setViewThreshold(500);
- }
- }
-
- /**
* Returns the number of steps to complete the entire column network
*
* @param inputMatrix
@@ -952,6 +981,27 @@
}
+ /**
+ * Calculates the Pearson Correlation
+ * r = Sxx/SQRT(Sxx x Syy)
+ *
+ * @param data - The gene expression data
+ * @param i, j - Calculate the correlation between data vectors
data.cols[i] and data.cols[j]
+ * @return The Pearson correlation value between -1 and 1. If the
correlation calculation contains an error
+ * (i.e. divide by zero), return -2.0
+ */
+ private double calcPearsonCorr(initiationData data,int i, int j)
+ {
+ double sumOfProducts = data.cols[i].zDotProduct(data.cols[j]);
+ double cov = (sumOfProducts - data.sums[i] * data.sums[j] / data.rows)
/ data.rows;
+ double corr = cov / (data.stdDev.get(i) * data.stdDev.get(j));
+
+ if (data.stdDev.get(i) == 0 || data.stdDev.get(j) == 0 )
+ return -2.0;
+ else
+ return corr;
+ }
+
//TODO histogram()
/**
* This calculates either the row or column histogram (a class double
array) which is used by other
@@ -963,6 +1013,7 @@
*/
public void histogram(boolean isRowNetwork, DoubleMatrix2D inputMatrix) {
+ //sr = new SpearmanRank(inputMatrix);
initiationData data = new initiationData(isRowNetwork, inputMatrix,
true);
int bins = 2000; //Adjust this number to change the histogram
accuracy
@@ -975,7 +1026,17 @@
mod = 0;
}
- int binNumber;
+ if (taskMonitor != null)
+ {
+ String type = "condition";
+ if (isRowNetwork)
+ {
+ type = "gene";
+ }
+ taskMonitor.setPercentCompleted(-1);
+ taskMonitor.setStatus("Constructing " + type + " correlation
histogram...");
+ }
+
for (int i = 0; i < data.columns; i++) {
for (int j = 0; j < i; j++) {
if (isRowNetwork) {
@@ -983,11 +1044,15 @@
} else {
colCurrentStep++;
}
- double sumOfProducts = data.cols[i].zDotProduct(data.cols[j]);
- double cov = (sumOfProducts - data.sums[i] * data.sums[j] /
data.rows) / data.rows;
- double corr = cov / (data.stdDev.get(i) * data.stdDev.get(j));
+
+ double corr = calcPearsonCorr(data,i,j);
+ //double corr = sr.corr(i,j);
+
+ if (corr < -1.0)
+ continue;
+
if (i != j) {
- binNumber = (int) ((corr + 1) * (((double) bins - 1) / 2));
+ int binNumber = (int) ((corr + 1) * (((double) bins - 1) /
2));
//System.out.println("corr="+corr+" bin="+binNumber);
histo[binNumber]++;
}
@@ -997,9 +1062,18 @@
}
if ((i * 10) % (data.columns - mod) == 0) {
System.out.print("*");
+ if (taskMonitor != null)
+ {
+ taskMonitor.setPercentCompleted((int)((double) (i * 100) /
data.columns));
+ }
}
}
+ if (taskMonitor != null)
+ {
+ taskMonitor.setPercentCompleted(100);
+ taskMonitor.setStatus("Finished constructing histogram");
+ }
String[] labels = new String[bins];
for (int i = 0; i < bins; i++) {
@@ -1399,7 +1473,6 @@
return 0;
}
int[] histogram;
- int i, j;
int count = 0;
if (isRowNetwork) {
histogram = rowHistogram;
@@ -1408,12 +1481,12 @@
}
boolean[] uses = getUses(isRowNetwork);
if (uses[0]) {
- for (i = 0; (-1.0 + ((double) i * 2) / histogram.length) <
cutoffs[0]; i++) {
+ for (int i = 0; (-1.0 + ((double) i * 2) / histogram.length) <
cutoffs[0]; i++) {
count += histogram[i];
}
}
if (uses[1]) {
- for (j = 0; (1.0 - ((double) j * 2) / histogram.length) >=
cutoffs[1]; j++) {
+ for (int j = 0; (1.0 - ((double) j * 2) / histogram.length) >=
cutoffs[1]; j++) {
count += histogram[histogram.length - j - 1];
}
}
@@ -1452,7 +1525,7 @@
* @return
*/
public DoubleMatrix2D getExpressionMatrix() {
- ExpressionData data =
Cytoscape.getCurrentNetwork().getExpressionData();
+ ExpressionData data = Cytoscape.getExpressionData();
return getExpressionMatrix(data);
}
@@ -1483,7 +1556,7 @@
public int getNumberOfRows() {
if (numberOfRows < 1) {
- ExpressionData data =
Cytoscape.getCurrentNetwork().getExpressionData();
+ ExpressionData data = Cytoscape.getExpressionData();
numberOfRows = data.getNumberOfGenes();
}
return numberOfRows;
@@ -1491,7 +1564,7 @@
public int getNumberOfCols() {
if (numberOfCols < 1) {
- ExpressionData data =
Cytoscape.getCurrentNetwork().getExpressionData();
+ ExpressionData data = Cytoscape.getExpressionData();
numberOfCols = data.getNumberOfConditions();
}
return numberOfCols;
@@ -1566,11 +1639,40 @@
*/
public void cancel() {
cancel = true;
- //System.out.println("Cancel called");
}
+
+ /**
+ * Indicates whether or not the task was cancelled
+ * @return true if cancel is true, otherwise false
+ */
+ public boolean cancelled() {
+ return cancel;
+ }
+
+ /**
+ * Sets the task monitor object
+ * @param taskMonitor This object is used to keep track of the progress of
the correlation network and histogram
+ * calculation tasks
+ */
+ public void setTaskMonitor(TaskMonitor taskMonitor)
+ {
+ this.taskMonitor = taskMonitor;
+
+ }
+
+ /**
+ * Returns the task monitor object used to keep track of the progress of
the task
+ * @return TaskMonitor This object is used to keep track of the progress
of the correlation network and histogram
+ * calculation tasks
+ */
+ public TaskMonitor getTaskMonitor()
+ {
+ return this.taskMonitor;
+ }
}
+
Modified:
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/ExpressionCorrelationAboutDialog.java
===================================================================
---
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/ExpressionCorrelationAboutDialog.java
2008-09-23 19:03:23 UTC (rev 14942)
+++
csplugins/trunk/mskcc/summerstudents/ExpressionCorrelation/src/org/mskcc/csplugins/ExpressionCorrelation/ExpressionCorrelationAboutDialog.java
2008-09-23 19:07:05 UTC (rev 14943)
@@ -52,7 +52,7 @@
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
editorPane.setEditorKit(new HTMLEditorKit());
- editorPane.setText("<html><body><P align=center>Expression Correlation
Network Plugin v1.0 (January 2005)<BR>" +
+ editorPane.setText("<html><body><P align=center>Expression Correlation
Network Plugin v1.1 (May 2007)<BR>" +
"written by Elena Potylitsine and Weston Whitaker<BR>" +
"during the Cornell/MSKCC summer student program 2004<BR>" +
"Chris Sander Group<BR>" +
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en
-~----------~----~----~----~------~----~------~--~---