Search in sources :

Example 11 with NewNetworkView

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

the class AbstractNetworkFilter method run.

public void run(TaskMonitor monitor) {
    monitor.setTitle("Filtering using " + getName());
    this.monitor = monitor;
    if (network == null)
        network = clusterManager.getNetwork();
    clusterAttributeName = getClusterAttributeName();
    // get the cluster list
    List<NodeCluster> clusterList = AbstractNetworkClusterer.getNodeClusters(network, getClusterAttribute());
    List<NodeCluster> newClusterList = new ArrayList<NodeCluster>();
    Map<NodeCluster, List<CyNode>> addedNodeMap = new HashMap<NodeCluster, List<CyNode>>();
    // Iterate over clusters and build a new clusterList
    for (NodeCluster nodeList : clusterList) {
        NodeCluster newCluster = doFilter(nodeList, addedNodeMap);
        if (newCluster != null && newCluster.size() > 0)
            newClusterList.add(newCluster);
    }
    // Fixup our clusters
    if (addedNodeMap.size() > 0) {
        // until this stabelized...
        for (NodeCluster addedCluster : addedNodeMap.keySet()) {
            for (NodeCluster cluster : newClusterList) {
                if (cluster.equals(addedCluster))
                    continue;
                removeNodes(cluster, addedNodeMap.get(addedCluster));
            }
        }
    }
    monitor.showMessage(TaskMonitor.Level.INFO, "Removing groups");
    // Remove any leftover groups from previous runs
    removeGroups(network, groupAttribute);
    monitor.showMessage(TaskMonitor.Level.INFO, "Creating groups");
    List<List<CyNode>> nodeClusters = createGroups(network, newClusterList, groupAttribute);
    results = new AbstractClusterResults(network, clusterList);
    ClusterResults results2 = new AbstractClusterResults(network, newClusterList);
    monitor.showMessage(TaskMonitor.Level.INFO, "Done.  Results:\n\nBefore Filter:\n" + results + "\n\nAfter Filter:\n" + results2);
    if (showUI()) {
        monitor.showMessage(TaskMonitor.Level.INFO, "Creating network");
        insertTasksAfterCurrentTask(new NewNetworkView(network, clusterManager, true, restoreEdges(), false));
    }
}
Also used : FuzzyNodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.FuzzyNodeCluster) NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) NewNetworkView(edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CyNode(org.cytoscape.model.CyNode) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults) ClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterResults)

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