Search in sources :

Example 1 with NewNetworkView

use of edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView in project clusterMaker2 by RBVI.

the class Fuzzifier method run.

/**
 * The method run creates an instance of the RunFuzzifier and creates the fuzzy clusters
 * by calling the fuzzifier algorithm.
 * Also creates fuzzy groups and the Fuzzy Cluster Table
 *
 * @param Task Monitor
 */
public void run(TaskMonitor monitor) {
    monitor.setTitle("Performing Fuzzifier clustering");
    this.monitor = monitor;
    if (network == null)
        network = clusterManager.getNetwork();
    super.network = network;
    this.Clusters = getClusters();
    this.cNumber = Clusters.size();
    // Make sure to update the context
    context.setNetwork(network);
    Long networkID = network.getSUID();
    CyTable nodeAttributes = network.getDefaultNodeTable();
    CyMatrix distanceMatrix = context.edgeAttributeHandler.getMatrix();
    if (distanceMatrix == null) {
        monitor.showMessage(TaskMonitor.Level.ERROR, "Can't get distance matrix: no attribute value?");
        return;
    }
    // Update our tunable results
    clusterAttributeName = context.getClusterAttribute();
    runFuzzifier = new RunFuzzifier(Clusters, distanceMatrix, cNumber, context.membershipThreshold.getValue(), context.maxThreads, monitor);
    runFuzzifier.setDebug(debug);
    if (canceled)
        return;
    monitor.showMessage(TaskMonitor.Level.INFO, "Clustering...");
    List<FuzzyNodeCluster> FuzzyClusters = runFuzzifier.run(network, monitor);
    // Canceled?
    if (FuzzyClusters == null)
        return;
    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 = createFuzzyGroups(network, FuzzyClusters, GROUP_ATTRIBUTE);
    results = new AbstractClusterResults(network, FuzzyClusters);
    monitor.showMessage(TaskMonitor.Level.INFO, "Done.  Fuzzifier 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));
    } else {
        monitor.showMessage(TaskMonitor.Level.INFO, "Done.  Fizzifier results:\n" + results);
    }
    System.out.println("Creating fuzzy table");
    createFuzzyTable(FuzzyClusters);
    System.out.println("Done");
}
Also used : CyTable(org.cytoscape.model.CyTable) CyMatrix(edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix) NewNetworkView(edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView) ArrayList(java.util.ArrayList) List(java.util.List) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults) FuzzyNodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.FuzzyNodeCluster)

Example 2 with NewNetworkView

use of edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView in project clusterMaker2 by RBVI.

the class SCPSCluster method run.

public void run(TaskMonitor monitor) {
    monitor.setTitle("Performing SCPS 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;
    // Cluster the nodes
    runSCPS = new RunSCPS(matrix, context.epsilon, context.clusters, context.iterations, monitor);
    monitor.showMessage(TaskMonitor.Level.INFO, "Clustering...");
    List<NodeCluster> clusterList = runSCPS.run(network, monitor);
    // Canceled?
    if (clusterList == null)
        return;
    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, clusterList, GROUP_ATTRIBUTE);
    results = new AbstractClusterResults(network, clusterList);
    monitor.showMessage(TaskMonitor.Level.INFO, "Done.  SCPS 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));
    }
}
Also used : CyMatrix(edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix) NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) NewNetworkView(edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView) ArrayList(java.util.ArrayList) List(java.util.List) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)

Example 3 with NewNetworkView

use of edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView in project clusterMaker2 by RBVI.

the class TransClustCluster method run.

/**
 * Perform the actual clustering.  For TransClust, there are really
 * two steps:
 * 	1) Assign all of the connected components
 * 	2) Do the TransClust clustering.
 *
 * There is also an optional approach called evolutionary parameter
 * tuning, which takes a lot longer and is probably less relevant for
 * the Cytoscape integration.
 *
 * @param monitor the TaskMonitor to use
 */
public void run(TaskMonitor monitor) {
    monitor.setTitle("Performing Transitivity clustering");
    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;
    }
    updateSettings();
    runTransClust = new RunTransClust(matrix, context.edgeAttributeHandler.edgeCutOff.getValue(), monitor);
    if (canceled)
        return;
    monitor.showMessage(TaskMonitor.Level.INFO, "Clustering...");
    createGroups = context.advancedAttributes.createGroups;
    // Cluster the nodes
    List<NodeCluster> clusters = runTransClust.run(monitor, network);
    // Canceled?
    if (clusters == null)
        return;
    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.setStatusMessage("Done.  TransClust 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));
    }
}
Also used : CyMatrix(edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix) NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) NewNetworkView(edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView) ArrayList(java.util.ArrayList) List(java.util.List) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)

Example 4 with NewNetworkView

use of edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView in project clusterMaker2 by RBVI.

the class APCluster method run.

public void run(TaskMonitor monitor) {
    monitor.setTitle("Performing AP 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;
    // Cluster the nodes
    runAP = new RunAP(matrix, context.lambda, context.preference, context.rNumber, monitor, debug);
    if (canceled)
        return;
    monitor.showMessage(TaskMonitor.Level.INFO, "Clustering...");
    List<NodeCluster> clusters = runAP.run(network, monitor);
    // Canceled?
    if (clusters == null)
        return;
    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);
    setParams(params);
    List<List<CyNode>> nodeClusters = createGroups(network, clusters, GROUP_ATTRIBUTE);
    results = new AbstractClusterResults(network, clusters);
    monitor.showMessage(TaskMonitor.Level.INFO, "Done.  AP 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));
    }
}
Also used : CyMatrix(edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix) NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) NewNetworkView(edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView) ArrayList(java.util.ArrayList) List(java.util.List) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)

Example 5 with NewNetworkView

use of edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView in project clusterMaker2 by RBVI.

the class MCLCluster method run.

public void run(TaskMonitor monitor) {
    monitor.setTitle("Performing MCL cluster");
    this.monitor = monitor;
    if (network == null)
        network = clusterManager.getNetwork();
    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;
    // Cluster the nodes
    runMCL = new RunMCL(matrix, context.inflation_parameter, context.iterations, context.clusteringThresh, context.maxResidual, context.maxThreads, context.forceDecliningResidual, monitor);
    runMCL.setDebug(false);
    if (canceled)
        return;
    monitor.showMessage(TaskMonitor.Level.INFO, "Clustering...");
    // results = runMCL.run(monitor);
    List<NodeCluster> clusters = runMCL.run(network, monitor);
    // Canceled?
    if (clusters == null)
        return;
    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, "MCL 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));
    }
}
Also used : CyMatrix(edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix) NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) NewNetworkView(edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView) ArrayList(java.util.ArrayList) List(java.util.List) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)

Aggregations

AbstractClusterResults (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)11 NewNetworkView (edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView)11 ArrayList (java.util.ArrayList)11 List (java.util.List)11 NodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster)8 CyMatrix (edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix)6 FuzzyNodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.FuzzyNodeCluster)3 HashMap (java.util.HashMap)2 CyNode (org.cytoscape.model.CyNode)2 CyTable (org.cytoscape.model.CyTable)2 ClusterResults (edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterResults)1 KnnView (edu.ucsf.rbvi.clusterMaker2.internal.ui.KnnView)1 NumberFormat (java.text.NumberFormat)1