Author: scooter
Date: 2011-08-22 17:42:09 -0700 (Mon, 22 Aug 2011)
New Revision: 26625
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/Matrix.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/edgeConverters/EdgeAttributeHandler.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/AP/APCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/AbstractNetworkClusterer.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/ConnectedComponents/ConnectedComponentsCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/MCL/MCLCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/MCODE/MCODECluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/SCPS/SCPSCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/TransClust/TransClustCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/glay/GLayCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NewNetworkView.java
Log:
Updated to save parameters as part of the network and use saved parameters to
guid new network generation.
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/Matrix.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/Matrix.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/Matrix.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -389,6 +389,7 @@
}
// XXX Isn't this the same as clusterMaker.algorithms.DistanceMatrix?
+ @SuppressWarnings("unchecked")
private void buildSymmetricalMatrix(CyNetwork network, String weight,
boolean ignoreMissing, boolean
selectedOnly) {
@@ -464,6 +465,7 @@
}
// XXX Do we need a new constructor to
clusterMaker.algorithms.DistanceMatrix?
+ @SuppressWarnings("unchecked")
private void buildGeneArrayMatrix(CyNetwork network, String[]
weightAttributes,
boolean transpose, boolean
ignoreMissing,
boolean selectedOnly) {
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/edgeConverters/EdgeAttributeHandler.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/edgeConverters/EdgeAttributeHandler.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/edgeConverters/EdgeAttributeHandler.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -100,7 +100,8 @@
converters.add(new SCPSConverter());
converter = converters.get(0); // Initialize to the None
converter
- initializeTunables(clusterProperties);
+ if (clusterProperties != null)
+ initializeTunables(clusterProperties);
}
public void initializeTunables(ClusterProperties clusterProperties) {
@@ -317,6 +318,27 @@
return this.matrix;
}
+ public void setParams(List<String> params) {
+ if (adjustLoops)
+ params.add("adjustLoops");
+ if (edgeCutOff != null)
+ params.add("edgeCutOff="+edgeCutOff.toString());
+ if (selectedOnly)
+ params.add("selectedOnly");
+ if (undirectedEdges)
+ params.add("undirectedEdges");
+ params.add("converter="+converter.getShortName());
+ params.add("dataAttribute="+dataAttribute);
+ }
+
+ public EdgeWeightConverter getConverter(String converterName) {
+ for (EdgeWeightConverter ewc: converters) {
+ if (converterName.equals(ewc.getShortName()))
+ return ewc;
+ }
+ return null;
+ }
+
private void getAttributesList(List<String>attributeList, CyAttributes
attributes) {
String[] names = attributes.getAttributeNames();
for (int i = 0; i < names.length; i++) {
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/AP/APCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/AP/APCluster.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/AP/APCluster.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -70,10 +70,6 @@
double lambda = .5;
int rNumber = 8;
double preference = -1;
- EdgeAttributeHandler edgeAttributeHandler = null;
-
- TaskMonitor monitor = null;
- CyLogger logger = null;
RunAP runAP = null;
public APCluster() {
@@ -199,4 +195,10 @@
runAP.halt();
}
+ public void setParams(List<String>params) {
+ params.add("lambda="+lambda);
+ params.add("rNumber="+rNumber);
+ params.add("preference="+preference);
+ super.setParams(params);
+ }
}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/AbstractNetworkClusterer.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/AbstractNetworkClusterer.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/AbstractNetworkClusterer.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -39,6 +39,7 @@
import cytoscape.groups.CyGroup;
import cytoscape.groups.CyGroupManager;
import cytoscape.layout.Tunable;
+import cytoscape.logger.CyLogger;
import cytoscape.task.TaskMonitor;
import cytoscape.task.ui.JTaskConfig;
@@ -55,6 +56,7 @@
import clusterMaker.ui.ClusterTask;
import clusterMaker.algorithms.AbstractClusterAlgorithm;
import clusterMaker.algorithms.NodeCluster;
+import clusterMaker.algorithms.edgeConverters.EdgeAttributeHandler;
/**
* This abstract class is the base class for all of the network clusterers
provided by
@@ -62,8 +64,12 @@
* partition a network based on properties of the relationships between nodes.
*/
public abstract class AbstractNetworkClusterer extends
AbstractClusterAlgorithm {
+ // Shared instance variables
+ protected EdgeAttributeHandler edgeAttributeHandler = null;
+ protected TaskMonitor monitor = null;
+ protected CyLogger logger = null;
+ protected List<String>params = null;
-
// For simple divisive clustering, these routines will do the group
handling
@SuppressWarnings("unchecked")
protected void removeGroups(CyAttributes netAttributes, String
networkID) {
@@ -131,15 +137,24 @@
// Save the network attribute so we remember which groups are
ours
netAttributes.setListAttribute(networkID, GROUP_ATTRIBUTE,
groupList);
+ // Add parameters to our list
+ params = new ArrayList<String>();
+ setParams(params);
+
// Set up the appropriate attributes
-
netAttributes.setAttribute(Cytoscape.getCurrentNetwork().getIdentifier(),
- ClusterMaker.CLUSTER_TYPE_ATTRIBUTE,
getShortName());
-
netAttributes.setAttribute(Cytoscape.getCurrentNetwork().getIdentifier(),
- ClusterMaker.CLUSTER_ATTRIBUTE,
clusterAttributeName);
+ String netId = Cytoscape.getCurrentNetwork().getIdentifier();
+ netAttributes.setAttribute(netId,
ClusterMaker.CLUSTER_TYPE_ATTRIBUTE, getShortName());
+ netAttributes.setAttribute(netId,
ClusterMaker.CLUSTER_ATTRIBUTE, clusterAttributeName);
+ netAttributes.setListAttribute(netId,
ClusterMaker.CLUSTER_PARAMS_ATTRIBUTE, params);
return clusterList;
}
+ protected void setParams(List<String> params) {
+ if (edgeAttributeHandler != null)
+ edgeAttributeHandler.setParams(params);
+ }
+
public boolean isAvailable() {
CyNetwork network = Cytoscape.getCurrentNetwork();
CyAttributes networkAttributes =
Cytoscape.getNetworkAttributes();
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/ConnectedComponents/ConnectedComponentsCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/ConnectedComponents/ConnectedComponentsCluster.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/ConnectedComponents/ConnectedComponentsCluster.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -68,12 +68,6 @@
// clusterMaker imports
public class ConnectedComponentsCluster extends AbstractNetworkClusterer {
-
- EdgeAttributeHandler edgeAttributeHandler = null;
-
- TaskMonitor monitor = null;
- CyLogger logger = null;
-
public ConnectedComponentsCluster() {
super();
clusterAttributeName =
Cytoscape.getCurrentNetwork().getIdentifier()+"_CC_cluster";
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/MCL/MCLCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/MCL/MCLCluster.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/MCL/MCLCluster.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -72,10 +72,6 @@
double clusteringThresh = 1e-15;
double maxResidual = 0.001;
int maxThreads = 0;
- EdgeAttributeHandler edgeAttributeHandler = null;
-
- TaskMonitor monitor = null;
- CyLogger logger = null;
RunMCL runMCL = null;
public MCLCluster() {
@@ -232,4 +228,12 @@
if (runMCL != null)
runMCL.halt();
}
+
+ public void setParams(List<String>params) {
+ params.add("inflation_parameter="+inflation_parameter);
+ params.add("rNumber="+rNumber);
+ params.add("clusteringThresh="+clusteringThresh);
+ params.add("maxResidual="+maxResidual);
+ super.setParams(params);
+ }
}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/MCODE/MCODECluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/MCODE/MCODECluster.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/MCODE/MCODECluster.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -78,9 +78,6 @@
RunMCODE runMCODE;
- TaskMonitor monitor = null;
- CyLogger logger = null;
-
public MCODECluster() {
super();
clusterAttributeName =
Cytoscape.getCurrentNetwork().getIdentifier()+"_MCODE_cluster";
@@ -284,4 +281,16 @@
canceled = true;
runMCODE.halt();
}
+
+ public void setParams(List<String>params) {
+ params.add("scope="+currentParamsCopy.getScope());
+ params.add("includeLoops="+currentParamsCopy.isIncludeLoops());
+ params.add("degreeCutoff="+currentParamsCopy.getDegreeCutoff());
+ params.add("kCore="+currentParamsCopy.getKCore());
+
params.add("maxDepth="+currentParamsCopy.getMaxDepthFromStart());
+
params.add("nodeScoreCutoff="+currentParamsCopy.getNodeScoreCutoff());
+ params.add("fluff="+currentParamsCopy.isFluff());
+ params.add("haircut="+currentParamsCopy.isHaircut());
+ super.setParams(params);
+ }
}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/SCPS/SCPSCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/SCPS/SCPSCluster.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/SCPS/SCPSCluster.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -69,12 +69,7 @@
double epsilon = 1.02;
int rNumber = 50;
- int knumber = -1;
-
- EdgeAttributeHandler edgeAttributeHandler = null;
-
- TaskMonitor monitor = null;
- CyLogger logger = null;
+ int knumber = -1;
RunSCPS runSCPS = null;
public SCPSCluster() {
@@ -201,4 +196,10 @@
runSCPS.halt();
}
+ public void setParams(List<String>params) {
+ params.add("epsilon="+epsilon);
+ params.add("rNumber="+rNumber);
+ params.add("knumber="+knumber);
+ super.setParams(params);
+ }
}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/TransClust/TransClustCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/TransClust/TransClustCluster.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/TransClust/TransClustCluster.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -25,13 +25,8 @@
public class TransClustCluster extends AbstractNetworkClusterer{
- private CyLogger logger = null;
- private TaskMonitor monitor = null;
-
private List<CyNode> nodes;
- EdgeAttributeHandler edgeAttributeHandler = null;
-
private static final long serialVersionUID = 1L;
private String groupAttribute = "__TransClustGroups";
@@ -292,4 +287,11 @@
runTransClust.halt();
}
+ public void setParams(List<String>params) {
+ params.add("mergeSimilar="+mergeSimilar);
+ params.add("mergeThreshold="+mergeThreshold);
+ params.add("maxSubclusterSize="+maxSubclusterSize);
+ params.add("maxTime="+maxTime);
+ super.setParams(params);
+ }
}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/glay/GLayCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/glay/GLayCluster.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/networkClusterers/glay/GLayCluster.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -62,8 +62,6 @@
public class GLayCluster extends AbstractNetworkClusterer {
- TaskMonitor monitor = null;
- CyLogger logger = null;
FastGreedyAlgorithm fa = null;
boolean selectedOnly = false;
boolean createNewNetwork = false;
@@ -199,4 +197,8 @@
if (fa != null)
fa.halt();
}
+
+ public void setParams(List<String>params) {
+ super.setParams(params);
+ }
}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NewNetworkView.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NewNetworkView.java
2011-08-22 21:00:11 UTC (rev 26624)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NewNetworkView.java
2011-08-23 00:42:09 UTC (rev 26625)
@@ -79,6 +79,8 @@
// ClusterMaker imports
import clusterMaker.ClusterMaker;
+import clusterMaker.algorithms.edgeConverters.EdgeAttributeHandler;
+import clusterMaker.algorithms.edgeConverters.EdgeWeightConverter;
import clusterMaker.algorithms.networkClusterers.AbstractNetworkClusterer;
import clusterMaker.algorithms.ClusterAlgorithm;
import clusterMaker.algorithms.ClusterProperties;
@@ -258,13 +260,25 @@
public PropertyChangeSupport getPropertyChangeSupport() {return pcs;}
+ @SuppressWarnings("unchecked")
private void createClusteredNetwork(String clusterAttribute) {
CyNetwork currentNetwork = Cytoscape.getCurrentNetwork();
CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
CyAttributes edgeAttributes = Cytoscape.getEdgeAttributes();
+ CyAttributes netAttributes = Cytoscape.getNetworkAttributes();
+ // Get the clustering parameters
+ List<String> params = null;
+ if (netAttributes.hasAttribute(currentNetwork.getIdentifier(),
ClusterMaker.CLUSTER_PARAMS_ATTRIBUTE))
+ params =
netAttributes.getListAttribute(currentNetwork.getIdentifier(),
+
ClusterMaker.CLUSTER_PARAMS_ATTRIBUTE);
+ else
+ params = new ArrayList<String>();
+
// Create the new network
CyNetwork net =
Cytoscape.createNetwork(currentNetwork.getTitle()+"--clustered",currentNetwork,false);
+ if (params.size() > 0)
+ netAttributes.setListAttribute(net.getIdentifier(),
ClusterMaker.CLUSTER_PARAMS_ATTRIBUTE, params);
// Create the cluster Map
HashMap<Object, List<CyNode>> clusterMap = new HashMap<Object,
List<CyNode>>();
@@ -287,18 +301,38 @@
}
// System.out.println("Adding node "+node+" to
"+cluster.toString());
clusterMap.get(cluster).add(node);
- net.addNode(node);
}
+ net.addNode(node);
}
+ // Special handling for edge weight thresholds
+ EdgeWeightConverter converter = null;
+ String dataAttribute = null;
+ double cutOff = 0.0;
+ for (String param: params) {
+ if (param.startsWith("converter")) {
+ String[] conv = param.split("=");
+ converter = new EdgeAttributeHandler(null,
false).getConverter(conv[1]);
+ } else if (param.startsWith("edgeCutOff")) {
+ String[] cut = param.split("=");
+ cutOff = Double.parseDouble(cut[1]);
+ } else if (param.startsWith("dataAttribute")) {
+ String[] attr = param.split("=");
+ dataAttribute = attr[1];
+ }
+ }
+
HashMap<CyEdge,CyEdge> edgeMap = new HashMap<CyEdge,CyEdge>();
-
for (Object cluster: clusterMap.keySet()) {
// Get the list of nodes
List<CyNode> nodeList = clusterMap.get(cluster);
// Get the list of edges
List<CyEdge> edgeList =
currentNetwork.getConnectingEdges(nodeList);
for (CyEdge edge: edgeList) {
+ if (converter != null && dataAttribute != null)
{
+ if (edgeWeightCheck(edgeAttributes,
edge, dataAttribute, converter, cutOff))
+ continue;
+ }
net.addEdge(edge);
edgeMap.put(edge,edge);
// Add the cluster attribute to the edge so we
can style it later
@@ -346,6 +380,26 @@
return;
}
+ private boolean edgeWeightCheck(CyAttributes edgeAttributes, CyEdge
edge, String dataAttribute,
+ EdgeWeightConverter converter, double
cutoff) {
+ if (!edgeAttributes.hasAttribute(edge.getIdentifier(),
dataAttribute))
+ return false;
+ byte type = edgeAttributes.getType(dataAttribute);
+ double val;
+ if (type == CyAttributes.TYPE_FLOATING)
+ val =
edgeAttributes.getDoubleAttribute(edge.getIdentifier(),
dataAttribute).doubleValue();
+ else if (type == CyAttributes.TYPE_INTEGER)
+ val =
edgeAttributes.getIntegerAttribute(edge.getIdentifier(),
dataAttribute).doubleValue();
+ else
+ return false;
+
+ if (converter.convert(val, 0.0, Double.MAX_VALUE) > cutoff)
+ return false;
+
+ return true;
+ }
+
+ @SuppressWarnings("deprecation")
private VisualStyle createNewStyle(String attribute, String suffix) {
boolean newStyle = false;
--
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.