use of org.cytoscape.group.CyGroup in project clusterMaker2 by RBVI.
the class AbstractNetworkClusterer method createFuzzyGroups.
protected List<List<CyNode>> createFuzzyGroups(CyNetwork network, List<FuzzyNodeCluster> clusters, String group_attr) {
// List of node lists
List<List<CyNode>> clusterList = new ArrayList<List<CyNode>>();
// keep track of the groups we create
List<Long> groupList = new ArrayList<Long>();
for (FuzzyNodeCluster cluster : clusters) {
int clusterNumber = cluster.getClusterNumber();
String groupName = clusterAttributeName + "_" + clusterNumber;
List<CyNode> nodeList = new ArrayList<CyNode>();
for (CyNode node : cluster) {
nodeList.add(node);
// network.getRow(node).set(clusterAttributeName, clusterNumber);
if (FuzzyNodeCluster.hasScore()) {
ModelUtils.createAndSetLocal(network, node, clusterAttributeName + "_" + clusterNumber + "_Membership", cluster.getMembership(node), Double.class, null);
// network.getRow(node).set(clusterAttributeName+"_Score", cluster.getClusterScore());
}
}
if (createGroups) {
CyGroup group = clusterManager.createGroup(network, clusterAttributeName + "_" + clusterNumber, nodeList, null, true);
if (group != null)
groupList.add(group.getGroupNode().getSUID());
}
clusterList.add(nodeList);
}
// Adding a column per node by the clusterAttributeName, which will store a list of all the clusters to which the node belongs
List<CyNode> nodeList = network.getNodeList();
for (int i = 0; i < nodeList.size(); i++) {
CyNode node = nodeList.get(i);
List<Integer> listOfClusters = new ArrayList<Integer>();
for (FuzzyNodeCluster cluster : clusters) {
if (cluster.getMembership(node) != null) {
listOfClusters.add(cluster.getClusterNumber());
}
}
ModelUtils.createAndSetLocal(network, node, clusterAttributeName, listOfClusters, List.class, Integer.class);
}
ModelUtils.createAndSetLocal(network, network, group_attr, groupList, List.class, Long.class);
ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_TYPE_ATTRIBUTE, getShortName(), String.class, null);
ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_ATTRIBUTE, clusterAttributeName, String.class, null);
if (params != null)
ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_PARAMS_ATTRIBUTE, params, List.class, String.class);
return clusterList;
}
use of org.cytoscape.group.CyGroup in project clusterMaker2 by RBVI.
the class ClusterManagerImpl method createGroup.
public CyGroup createGroup(CyNetwork network, String name, List<CyNode> nodeList, List<CyEdge> edgeList, boolean registerGroup) {
CyGroup group = groupFactory.createGroup(network, nodeList, edgeList, registerGroup);
if (group != null) {
CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
// The name of the group node is the name of the group
rootNetwork.getRow(group.getGroupNode()).set(CyNetwork.NAME, name);
rootNetwork.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS).set(CyRootNetwork.SHARED_NAME, name);
}
return group;
}
use of org.cytoscape.group.CyGroup in project clusterMaker2 by RBVI.
the class BicFinder method createBiclusterGroups.
protected void createBiclusterGroups(Map<Integer, List<Long>> clusterNodes) {
// List of node lists
List<List<CyNode>> clusterList = new ArrayList<List<CyNode>>();
// keep track of the groups we create
List<Long> groupList = new ArrayList<Long>();
createGroups = context.createGroups;
attrList = new ArrayList<String>();
for (Integer bicluster : clusterNodes.keySet()) {
String groupName = clusterAttributeName + "_" + bicluster;
List<Long> suidList = clusterNodes.get(bicluster);
List<CyNode> nodeList = new ArrayList<CyNode>();
for (Long suid : suidList) {
CyNode node = network.getNode(suid);
attrList.add(network.getRow(node).get(CyNetwork.NAME, String.class) + "\t" + bicluster);
nodeList.add(node);
}
if (createGroups) {
CyGroup group = clusterManager.createGroup(network, groupName, nodeList, null, true);
if (group != null)
groupList.add(group.getGroupNode().getSUID());
}
}
// Adding a column per node by the clusterAttributeName, which will store a list of all the clusters to which the node belongs
ModelUtils.createAndSetLocal(network, network, GROUP_ATTRIBUTE, groupList, List.class, Long.class);
ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_TYPE_ATTRIBUTE, getShortName(), String.class, null);
ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_ATTRIBUTE, clusterAttributeName, String.class, null);
if (params != null)
ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_PARAMS_ATTRIBUTE, params, List.class, String.class);
}
use of org.cytoscape.group.CyGroup in project clusterMaker2 by RBVI.
the class ChengChurch method createBiclusterGroups.
protected void createBiclusterGroups(Map<Integer, List<Long>> clusterNodes) {
// List of node lists
List<List<CyNode>> clusterList = new ArrayList<List<CyNode>>();
// keep track of the groups we create
List<Long> groupList = new ArrayList<Long>();
createGroups = context.createGroups;
attrList = new ArrayList<String>();
for (Integer bicluster : clusterNodes.keySet()) {
String groupName = clusterAttributeName + "_" + bicluster;
List<Long> suidList = clusterNodes.get(bicluster);
List<CyNode> nodeList = new ArrayList<CyNode>();
for (Long suid : suidList) {
CyNode node = network.getNode(suid);
attrList.add(network.getRow(node).get(CyNetwork.NAME, String.class) + "\t" + bicluster);
nodeList.add(node);
}
if (createGroups) {
CyGroup group = clusterManager.createGroup(network, groupName, nodeList, null, true);
if (group != null)
groupList.add(group.getGroupNode().getSUID());
}
}
// Adding a column per node by the clusterAttributeName, which will store a list of all the clusters to which the node belongs
ModelUtils.createAndSetLocal(network, network, GROUP_ATTRIBUTE, groupList, List.class, Long.class);
ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_TYPE_ATTRIBUTE, getShortName(), String.class, null);
ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_ATTRIBUTE, clusterAttributeName, String.class, null);
if (params != null)
ModelUtils.createAndSetLocal(network, network, ClusterManager.CLUSTER_PARAMS_ATTRIBUTE, params, List.class, String.class);
}
use of org.cytoscape.group.CyGroup in project clusterMaker2 by RBVI.
the class AbstractAttributeClusterer method createGroups.
/**
* This protected method is called to create all of our groups (if desired).
* It is used by all of the k-clustering algorithms.
*
* @param nClusters the number of clusters we created
* @param cluster the list of values and the assigned clusters
*/
protected void createGroups(CyNetwork net, CyMatrix matrix, int nClusters, int[] clusters, String algorithm) {
if (matrix.isTransposed()) {
return;
}
network = net;
if (monitor != null)
monitor.setStatusMessage("Creating groups");
attrList = new ArrayList<String>(matrix.nRows());
// Create the attribute list
for (int cluster = 0; cluster < nClusters; cluster++) {
List<CyNode> memberList = new ArrayList<CyNode>();
for (int i = 0; i < matrix.nRows(); i++) {
if (clusters[i] == cluster) {
// System.out.println("Setting cluster # for node "+matrix.getRowLabel(i)+"("+i+") to "+cluster);
attrList.add(matrix.getRowLabel(i) + "\t" + cluster);
memberList.add(matrix.getRowNode(i));
ModelUtils.createAndSetLocal(network, matrix.getRowNode(i), algorithm + " Cluster", cluster, Integer.class, null);
}
}
if (createGroups) {
// System.out.println("Creating group: Cluster_"+cluster+" with "+memberList.size()+" nodes");
CyGroup group = clusterManager.createGroup(network, "Cluster_" + cluster, memberList, null, true);
}
}
}
Aggregations