use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent in project clusterMaker2 by RBVI.
the class ConnectedComponent method reductionicf.
public static FixedParameterTreeNode reductionicf(FixedParameterTreeNode fptnNew, double maxK, ConnectedComponent cc) {
for (int i = 0; i < fptnNew.size; i++) {
for (int j = i + 1; j < fptnNew.size; j++) {
float sumIcf = calculateCostsForSetForbidden(fptnNew, i, j);
if (sumIcf + fptnNew.costs > maxK) {
float costsForMerging = calculateCostsForMerging(fptnNew, i, j);
FixedParameterTreeNode fptnNew2 = mergeNodes(fptnNew, i, j, costsForMerging, cc);
fptnNew2 = reductionicf(fptnNew2, maxK, cc);
return fptnNew2;
}
}
}
return fptnNew;
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent in project clusterMaker2 by RBVI.
the class ConnectedComponentsCluster method run.
public void run(TaskMonitor monitor) {
monitor.setTitle("Performing ConnectedComponents cluster");
this.monitor = monitor;
if (network == null)
network = clusterManager.getNetwork();
// Make sure to update the context
context.setNetwork(network);
NodeCluster.init();
CyMatrix matrix = context.edgeAttributeHandler.getMatrix();
if (matrix == null) {
monitor.showMessage(TaskMonitor.Level.ERROR, "Can't get distance matrix: no attribute value?");
return;
}
// Update our tunable results
clusterAttributeName = context.getClusterAttribute();
createGroups = context.advancedAttributes.createGroups;
if (canceled)
return;
Map<Integer, List<CyNode>> components = MatrixUtils.findConnectedComponents(matrix);
// Create the NodeClusters
Map<Integer, NodeCluster> clusterMap = new HashMap<Integer, NodeCluster>();
for (Integer cluster : components.keySet()) {
clusterMap.put(cluster, new NodeCluster(components.get(cluster)));
}
// Now get the sorted cluster map
int clusterNumber = 1;
HashMap<NodeCluster, NodeCluster> cMap = new HashMap<NodeCluster, NodeCluster>();
for (NodeCluster cluster : NodeCluster.sortMap(clusterMap)) {
if (cMap.containsKey(cluster))
continue;
cMap.put(cluster, cluster);
cluster.setClusterNumber(clusterNumber);
clusterNumber++;
}
List<NodeCluster> clusters = new ArrayList<NodeCluster>(cMap.keySet());
monitor.showMessage(TaskMonitor.Level.INFO, "Removing groups");
// Remove any leftover groups from previous runs
removeGroups(network, GROUP_ATTRIBUTE);
monitor.showMessage(TaskMonitor.Level.INFO, "Creating groups");
params = new ArrayList<String>();
context.edgeAttributeHandler.setParams(params);
List<List<CyNode>> nodeClusters = createGroups(network, clusters, GROUP_ATTRIBUTE);
results = new AbstractClusterResults(network, clusters);
monitor.showMessage(TaskMonitor.Level.INFO, "ConnectedComponent results:\n" + results);
if (context.vizProperties.showUI) {
monitor.showMessage(TaskMonitor.Level.INFO, "Creating network");
insertTasksAfterCurrentTask(new NewNetworkView(network, clusterManager, true, context.vizProperties.restoreEdges, !context.edgeAttributeHandler.selectedOnly));
}
}
Aggregations