Search in sources :

Example 26 with Clusters

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

the class PP_DivideAndRecluster method run.

public void run() {
    /* print score before any post processing */
    // double scoreAtStart = this.cc.getClusteringScore();
    // System.out.println("Score before post processing: "+scoreAtStart);
    /* merging step */
    ArrayList<ArrayList<Integer>> clusterObject = PostProcessingUtility.createClusterObject(this.cc, false);
    HashSet<String> alreadyCompared = new HashSet<String>();
    ClusterObjectComparator comparator = new ClusterObjectComparator();
    PostProcessingUtility.mergeCluster(clusterObject, alreadyCompared, this.cc, comparator, true);
    this.bestScore = PostProcessingUtility.updateClusterInfoInCC(clusterObject, this.cc);
    /* collection ConnectedComponent objects */
    ArrayList<ConnectedComponent> cCsOfSubgraphs = new ArrayList<ConnectedComponent>();
    /* start a new clustering procedure for clusters larger than 3 */
    for (int i = 0; i < clusterObject.size(); i++) {
        ArrayList<Integer> cluster = clusterObject.get(i);
        int clusterSize = cluster.size();
        /* if the clusters are to small, leave them in the clusters object and continue */
        if (clusterSize <= 3) {
            // System.out.println("cluster too small: "+cluster.toString());
            continue;
        }
        /* remove cluster from cluster object and decrease i */
        // TODO!!
        clusterObject.remove(i);
        --i;
        ConnectedComponent ccForCluster = this.cc.createConnectedComponentForCluster(i, cluster);
        cCsOfSubgraphs.add(ccForCluster);
        ClusterPostProcessingTask clusterTask = new ClusterPostProcessingTask(ccForCluster, this.params, this.layouterEnumTypes);
        clusterTask.run();
    }
    for (int i = 0; i < cCsOfSubgraphs.size(); i++) {
        ConnectedComponent subCC = cCsOfSubgraphs.get(i);
        addClustersToTotalClusters(subCC, clusterObject);
    }
    /* update clustering information */
    this.bestScore = PostProcessingUtility.updateClusterInfoInCC(clusterObject, this.cc);
    /* do post post processing - merge and rearrange */
    PP_RearrangeAndMergeBest postProcess1 = new PP_RearrangeAndMergeBest();
    postProcess1.initPostProcessing(this.cc);
    postProcess1.run();
}
Also used : ArrayList(java.util.ArrayList) ClusterPostProcessingTask(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.ClusterPostProcessingTask) ConnectedComponent(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent) HashSet(java.util.HashSet)

Example 27 with Clusters

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.Clusters 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 28 with Clusters

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.Clusters 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 29 with Clusters

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.Clusters 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 30 with Clusters

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.Clusters 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

ArrayList (java.util.ArrayList)30 NodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster)27 CyMatrix (edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix)22 Clusters (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.Clusters)21 AbstractClusterResults (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)16 HashMap (java.util.HashMap)16 List (java.util.List)15 CyNode (org.cytoscape.model.CyNode)13 NewNetworkView (edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView)10 Test (org.junit.Test)9 FuzzyNodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.FuzzyNodeCluster)8 ConnectedComponent (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent)6 Random (java.util.Random)5 Vector (java.util.Vector)5 Semaphore (java.util.concurrent.Semaphore)5 Edges (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.costmatrixcreation.dataTypes.Edges)3 ICCEdges (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges)3 IParameters (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.IParameters)3 ClusteringManager (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.ClusteringManager)3 PREdge (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.ranking.units.PREdge)3