Search in sources :

Example 1 with PhenomeExpressSubnetwork

use of org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork in project PhenomeScape by soulj.

the class ConnectedComponentAnalyser method traverseReachable.

private PhenomeExpressSubnetwork traverseReachable(Integer index, HashMap<Integer, Protein> index2Protein, AMatrix matrix, Set<Integer> aTraversed) {
    LinkedList<Integer> toTraverse = new LinkedList<Integer>();
    aTraversed.add(index);
    toTraverse.add(index);
    PhenomeExpressSubnetwork subnetwork = new PhenomeExpressSubnetwork(node2Protein);
    Protein protein = index2Protein.get(index);
    subnetwork.getNodeList().add(protein.getNode());
    subnetwork.setSubnetworkScore(subnetwork.getSubnetworkScore() + protein.getScore());
    while (!toTraverse.isEmpty()) {
        final Integer currentNode = toTraverse.removeFirst();
        final AVector neighbours = matrix.getRow(currentNode);
        for (int i = 0; i < neighbours.length(); i++) {
            if (neighbours.get(i) != 0.0) {
                if (!aTraversed.contains(i)) {
                    toTraverse.add(i);
                    protein = index2Protein.get(i);
                    subnetwork.getNodeList().add(protein.getNode());
                    subnetwork.setSubnetworkScore(subnetwork.getSubnetworkScore() + protein.getScore());
                    aTraversed.add(i);
                }
            }
        }
    }
    return subnetwork;
}
Also used : AVector(mikera.vectorz.AVector) LinkedList(java.util.LinkedList) PhenomeExpressSubnetwork(org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork) Protein(org.cytoscape.phenomescape.internal.Protein)

Example 2 with PhenomeExpressSubnetwork

use of org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork in project PhenomeScape by soulj.

the class ConnectedComponentAnalyser method ccFromAdjMatrix.

public ArrayList<PhenomeExpressSubnetwork> ccFromAdjMatrix(AMatrix cooccuranceMat, ProteinNetwork proteinNetwork) {
    HashMap<Integer, Protein> index2Protein = proteinNetwork.getIndex2ProteinMap();
    int notVisitedCount = cooccuranceMat.rowCount();
    Set<Integer> traversed = new HashSet<Integer>(notVisitedCount);
    ArrayList<PhenomeExpressSubnetwork> components = new ArrayList<PhenomeExpressSubnetwork>();
    for (int i = 0; i < cooccuranceMat.rowCount(); i++) {
        if (cooccuranceMat.getRow(i).elementSum() > 0) {
            if (!traversed.contains(i)) {
                PhenomeExpressSubnetwork newComponent = traverseReachable(Integer.valueOf(i), index2Protein, cooccuranceMat, traversed);
                components.add(newComponent);
            }
        }
    }
    return components;
}
Also used : ArrayList(java.util.ArrayList) Protein(org.cytoscape.phenomescape.internal.Protein) PhenomeExpressSubnetwork(org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork) HashSet(java.util.HashSet)

Aggregations

PhenomeExpressSubnetwork (org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork)2 Protein (org.cytoscape.phenomescape.internal.Protein)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 AVector (mikera.vectorz.AVector)1