Search in sources :

Example 11 with Matrix

use of edu.ucsf.rbvi.clusterMaker2.internal.api.Matrix in project clusterMaker2 by RBVI.

the class SimpleMatrix method like.

public Matrix like(Matrix initial) {
    Matrix newMat = like();
    newMat.initialize(initial.nRows(), initial.nColumns(), initial.toArray());
    return newMat;
}
Also used : Matrix(edu.ucsf.rbvi.clusterMaker2.internal.api.Matrix)

Example 12 with Matrix

use of edu.ucsf.rbvi.clusterMaker2.internal.api.Matrix in project clusterMaker2 by RBVI.

the class SimpleMatrix method like.

public Matrix like(int rows, int columns, double[][] initial) {
    Matrix newMat = like();
    newMat.initialize(rows, columns, initial);
    return newMat;
}
Also used : Matrix(edu.ucsf.rbvi.clusterMaker2.internal.api.Matrix)

Example 13 with Matrix

use of edu.ucsf.rbvi.clusterMaker2.internal.api.Matrix in project clusterMaker2 by RBVI.

the class SimpleOps method wrap.

private Matrix wrap(DoubleMatrix2D mat) {
    Matrix result = new SimpleMatrix();
    result.initialize(mat.rows(), mat.columns(), mat.toArray());
    return result;
}
Also used : Matrix(edu.ucsf.rbvi.clusterMaker2.internal.api.Matrix)

Example 14 with Matrix

use of edu.ucsf.rbvi.clusterMaker2.internal.api.Matrix 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 15 with Matrix

use of edu.ucsf.rbvi.clusterMaker2.internal.api.Matrix 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

CyMatrix (edu.ucsf.rbvi.clusterMaker2.internal.api.CyMatrix)34 Matrix (edu.ucsf.rbvi.clusterMaker2.internal.api.Matrix)22 ArrayList (java.util.ArrayList)15 HashMap (java.util.HashMap)13 NodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster)12 CyNode (org.cytoscape.model.CyNode)12 List (java.util.List)9 AbstractClusterResults (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.AbstractClusterResults)7 NewNetworkView (edu.ucsf.rbvi.clusterMaker2.internal.ui.NewNetworkView)7 FuzzyNodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.FuzzyNodeCluster)5 CyTable (org.cytoscape.model.CyTable)5 Test (org.junit.Test)4 Clusters (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.attributeClusterers.Clusters)3 ColtMatrix (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.matrix.ColtMatrix)3 DoubleMatrix2D (cern.colt.matrix.tdouble.DoubleMatrix2D)2 DistanceMetric (edu.ucsf.rbvi.clusterMaker2.internal.api.DistanceMetric)2 ScatterPlotDialog (edu.ucsf.rbvi.clusterMaker2.internal.ui.ScatterPlotDialog)2 CyEdge (org.cytoscape.model.CyEdge)2 DoubleArrayList (cern.colt.list.tdouble.DoubleArrayList)1 IntArrayList (cern.colt.list.tint.IntArrayList)1