Search in sources :

Example 6 with AbstractClusterResults

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults in project clusterMaker2 by RBVI.

the class AutoSOMECluster method run.

public void run(TaskMonitor monitor) {
    this.monitor = monitor;
    monitor.setTitle("Performing " + getName());
    String networkID = ModelUtils.getNetworkName(network);
    // Update settings from our context
    settings = context.getSettings();
    // got back to parent to cluster again
    if (networkID.contains("--AutoSOME")) {
        String[] tokens = networkID.split("--AutoSOME");
        networkID = tokens[0];
        network = ModelUtils.getNetworkWithName(clusterManager, networkID);
    }
    List<String> dataAttributes = context.attributeList.getNodeAttributeList();
    // Cluster the nodes
    runAutoSOME = new RunAutoSOME(clusterManager, dataAttributes, network, settings, monitor);
    runAutoSOME.setIgnoreMissing(context.ignoreMissing);
    runAutoSOME.setSelectedOnly(context.selectedOnly);
    runAutoSOME.setDebug(debug);
    monitor.setStatusMessage("Running AutoSOME" + ((settings.distMatrix) ? " Fuzzy Clustering" : ""));
    nodeCluster = runAutoSOME.run(monitor);
    if (nodeCluster == null) {
        monitor.setStatusMessage("Clustering failed!");
        return;
    }
    if (nodeCluster.size() > 0)
        finishedClustering = true;
    monitor.setStatusMessage("Removing groups");
    // Remove any leftover groups from previous runs
    removeGroups(network, getShortName());
    monitor.setStatusMessage("Creating groups");
    if (settings.distMatrix)
        runAutoSOME.getEdges(context.maxEdges);
    attrList = runAutoSOME.attrList;
    attrOrderList = runAutoSOME.attrOrderList;
    nodeOrderList = runAutoSOME.nodeOrderList;
    ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_NODE_ATTRIBUTE, attrList, List.class, String.class);
    ModelUtils.createAndSetLocal(network, network, ClusterManager.ARRAY_ORDER_ATTRIBUTE, attrOrderList, List.class, String.class);
    ModelUtils.createAndSetLocal(network, network, ClusterManager.NODE_ORDER_ATTRIBUTE, nodeOrderList, List.class, String.class);
    ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_TYPE_ATTRIBUTE, getShortName(), String.class, null);
    List<List<CyNode>> nodeClusters;
    if (!settings.distMatrix) {
        nodeClusters = createGroups(network, nodeCluster, GROUP_ATTRIBUTE);
        results = new AbstractClusterResults(network, nodeCluster);
        monitor.setStatusMessage("Done.  AutoSOME results:\n" + results);
    } else {
        nodeClusters = new ArrayList<List<CyNode>>();
        /*
			for (NodeCluster cluster: clusters) {
				List<CyNode>nodeList = new ArrayList();

				for (CyNode node: cluster) {
					nodeList.add(node);
				}
				nodeClusters.add(nodeList);
			}
	   */
        monitor.setStatusMessage("Done.  AutoSOME results:\n" + nodeCluster.size() + " clusters found.");
    }
    if (context.showViz) {
        if (heatmap)
            insertTasksAfterCurrentTask(new KnnView(clusterManager));
        else
            insertTasksAfterCurrentTask(new NewNetworkView(network, clusterManager, true, false, !context.selectedOnly));
    }
}
Also used : NewNetworkView(edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView) ArrayList(java.util.ArrayList) List(java.util.List) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults) KnnView(edu.ucsf.rbvi.clusterMaker2.internal.ui.KnnView)

Example 7 with AbstractClusterResults

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults in project clusterMaker2 by RBVI.

the class HyperlinkInducedTopicSearch method run.

@Override
public void run(TaskMonitor taskMonitor) {
    taskMonitor.setProgress(0.0);
    taskMonitor.setTitle("Hyperlink-Induced Topic Search ranking of clusters");
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Fetching clusters...");
    taskMonitor.setProgress(0.1);
    clusters = ClusterUtils.fetchClusters(network);
    taskMonitor.setProgress(0.5);
    initVariables();
    clusters.forEach(NodeCluster::initNodeScores);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting node scores in clusters");
    addNodes();
    taskMonitor.setProgress(0.6);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting edge scores in clusters");
    addEdges();
    taskMonitor.setProgress(0.7);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Performing HITS algorithm");
    HITS<PRNode, PREdge> hyperlinkInducedTopicSearchPriors = performHITS(graph);
    taskMonitor.setProgress(0.8);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting cluster scores");
    insertScores(clusters, graph, hyperlinkInducedTopicSearchPriors);
    taskMonitor.setProgress(0.9);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Insert cluster information in tables");
    ClusterUtils.insertResultsInColumns(network, clusters, SHORTNAME);
    results = new AbstractClusterResults(network, clusters);
    taskMonitor.setProgress(1.0);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Done...");
}
Also used : NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) PREdge(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.units.PREdge) PRNode(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.units.PRNode) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)

Example 8 with AbstractClusterResults

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults in project clusterMaker2 by RBVI.

the class MultipleAttributeAddition method run.

@Override
public void run(TaskMonitor taskMonitor) {
    taskMonitor.setProgress(0.0);
    taskMonitor.setTitle("Multiple Node Edge Additive ranking of clusters");
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Fetching clusters...");
    taskMonitor.setProgress(0.1);
    List<NodeCluster> clusters = ClusterUtils.fetchClusters(network);
    taskMonitor.setProgress(0.5);
    String clusterColumnName = ClusterUtils.getClusterAttribute(network);
    List<String> nodeAttributes = context.getSelectedNodeAttributes();
    List<String> edgeAttributes = context.getSelectedEdgeAttributes();
    taskMonitor.setProgress(0.6);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting node scores in clusters");
    clusters = ClusterUtils.setNodeScoresInCluster(network, clusters, nodeAttributes, clusterColumnName, false);
    taskMonitor.setProgress(0.75);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting edge scores in clusters");
    clusters = ClusterUtils.setEdgeScoresInCluster(network, clusters, edgeAttributes, clusterColumnName, false);
    taskMonitor.setProgress(0.80);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Sorting and ranking clusters");
    ClusterUtils.ascendingSort(clusters);
    NodeCluster.setClusterRanks(clusters);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Insert cluster information in tables");
    ClusterUtils.insertResultsInColumns(network, clusters, SHORTNAME);
    results = new AbstractClusterResults(network, clusters);
    taskMonitor.setProgress(1.0);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Done...");
}
Also used : NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)

Example 9 with AbstractClusterResults

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults in project clusterMaker2 by RBVI.

the class MultipleAttributeMultiplicative method run.

@Override
public void run(TaskMonitor taskMonitor) {
    taskMonitor.setProgress(0.0);
    taskMonitor.setTitle("Multiple Node Edge Multiplum ranking of clusters");
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Fetching clusters...");
    taskMonitor.setProgress(0.1);
    List<NodeCluster> clusters = ClusterUtils.fetchClusters(network);
    taskMonitor.setProgress(0.5);
    String clusterColumnName = ClusterUtils.getClusterAttribute(network);
    List<String> nodeAttributes = context.getSelectedNodeAttributes();
    List<String> edgeAttributes = context.getSelectedEdgeAttributes();
    taskMonitor.setProgress(0.6);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting node scores in clusters");
    clusters = ClusterUtils.setNodeScoresInCluster(network, clusters, nodeAttributes, clusterColumnName, true);
    taskMonitor.setProgress(0.75);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting edge scores in clusters");
    clusters = ClusterUtils.setEdgeScoresInCluster(network, clusters, edgeAttributes, clusterColumnName, true);
    taskMonitor.setProgress(0.80);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Sorting and ranking clusters");
    ClusterUtils.ascendingSort(clusters);
    NodeCluster.setClusterRanks(clusters);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Insert cluster information in tables");
    ClusterUtils.insertResultsInColumns(network, clusters, SHORTNAME);
    results = new AbstractClusterResults(network, clusters);
    taskMonitor.setProgress(1.0);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Done...");
}
Also used : NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)

Example 10 with AbstractClusterResults

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults in project clusterMaker2 by RBVI.

the class PR method run.

@Override
public void run(TaskMonitor taskMonitor) {
    taskMonitor.setProgress(0.0);
    taskMonitor.setTitle("PRWP with Priors ranking of clusters");
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Fetching clusters...");
    taskMonitor.setProgress(0.1);
    List<NodeCluster> clusters = ClusterUtils.fetchClusters(network);
    taskMonitor.setProgress(0.5);
    initVariables();
    clusters.forEach(NodeCluster::initNodeScores);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting node scores in clusters");
    addNodes();
    taskMonitor.setProgress(0.6);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Setting edge scores in clusters");
    addEdges();
    taskMonitor.setProgress(0.7);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Calculating PageRank scores");
    PageRank<PRNode, PREdge> pageRank = performPageRank();
    taskMonitor.setProgress(0.8);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Inserting scores into clusters");
    insertScores(clusters, pageRank);
    taskMonitor.setProgress(0.9);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Insert cluster information in tables");
    ClusterUtils.insertResultsInColumns(network, clusters, SHORTNAME);
    results = new AbstractClusterResults(network, clusters);
    taskMonitor.setProgress(1.0);
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Done...");
}
Also used : NodeCluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster) PREdge(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.units.PREdge) PRNode(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.units.PRNode) AbstractClusterResults(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)

Aggregations

AbstractClusterResults (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)17 NodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster)14 ArrayList (java.util.ArrayList)12 List (java.util.List)12 NewNetworkView (edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView)11 CyMatrix (edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix)6 FuzzyNodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.FuzzyNodeCluster)3 PREdge (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.units.PREdge)3 PRNode (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.units.PRNode)3 HashMap (java.util.HashMap)3 CyNode (org.cytoscape.model.CyNode)3 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