use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class GroupUtil method updateGroupNodes.
public void updateGroupNodes(final CyNetworkView view) {
if (view == null)
return;
final CyNetwork network = view.getModel();
final CyGroupManager groupMgr = serviceRegistrar.getService(CyGroupManager.class);
final Set<CyGroup> groupSet = groupMgr.getGroupSet(network);
for (CyGroup group : groupSet) {
if (group.isCollapsed(network))
updateGroupNodeLocation(view, group.getGroupNode());
}
}
use of org.cytoscape.group.CyGroup in project clusterMaker2 by RBVI.
the class ClusterManagerImpl method removeGroup.
public void removeGroup(CyNetwork network, Long suid) {
// Make sure to get the node in the root network
CyNode node = ((CySubNetwork) network).getRootNetwork().getNode(suid);
if (node == null)
return;
CyGroup group = groupMgr.getGroup(node, network);
if (group == null)
return;
// Remove the group from this network
if (group.getNetworkSet() != null && group.getNetworkSet().size() > 1) {
group.removeGroupFromNetwork(network);
return;
}
groupMgr.destroyGroup(group);
}
use of org.cytoscape.group.CyGroup in project clusterMaker2 by RBVI.
the class AbstractKClusterAlgorithm 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(ClusterManager clusterManager, int nClusters, int[] clusters, String algorithm, boolean createGroups) {
if (matrix.isTransposed()) {
return;
}
// Create the attribute list
attrList = new ArrayList<String>(matrix.nRows());
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) {
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) {
CyGroup group = clusterManager.createGroup(network, "Cluster_" + cluster, memberList, null, true);
}
}
}
use of org.cytoscape.group.CyGroup in project clusterMaker2 by RBVI.
the class BiMine 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 AbstractNetworkClusterer method createGroups.
protected List<List<CyNode>> createGroups(CyNetwork network, List<NodeCluster> 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>();
List<Double> clusterScores = new ArrayList<Double>(clusters.size());
// Initialize
for (NodeCluster cluster : clusters) {
clusterScores.add(null);
}
boolean haveScores = NodeCluster.getScoreList(clusters) != null;
// Remove the old column, if it's there. Some of the algorithms don't put
// all nodes into clusters, so we might wind up with old data lingering
ModelUtils.deleteColumnLocal(network, CyNode.class, clusterAttributeName);
for (NodeCluster cluster : clusters) {
int clusterNumber = cluster.getClusterNumber();
if (cluster.hasScore()) {
clusterScores.set(clusterNumber - 1, cluster.getClusterScore());
haveScores = true;
}
String groupName = clusterAttributeName + "_" + clusterNumber;
List<CyNode> nodeList = new ArrayList<CyNode>();
for (CyNode node : cluster) {
nodeList.add(node);
ModelUtils.createAndSetLocal(network, node, clusterAttributeName, clusterNumber, Integer.class, null);
}
if (createGroups) {
CyGroup group = clusterManager.createGroup(network, clusterAttributeName + "_" + clusterNumber, nodeList, null, true);
if (group != null) {
groupList.add(group.getGroupNode().getSUID());
if (NodeCluster.hasScore()) {
ModelUtils.createAndSetLocal(network, group.getGroupNode(), clusterAttributeName + "_Score", cluster.getClusterScore(), Double.class, null);
}
}
}
clusterList.add(nodeList);
}
if (haveScores)
ModelUtils.createAndSetLocal(network, network, clusterAttributeName + "_Scores", clusterScores, List.class, Double.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;
}
Aggregations