Search in sources :

Example 1 with Protein

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

the class GOTermAnalyser method goTermsinSubnetwork.

private Map<GOTerm, Integer> goTermsinSubnetwork(ProteinNetwork proteinNetwork, PhenomeExpressSubnetwork subnetwork) {
    Collection<CyNode> nodes = subnetwork.getNodeList();
    List<GOTerm> goTerms = new ArrayList<GOTerm>();
    for (CyNode node : nodes) {
        Protein protein = subnetwork.getNode2Protein().get(node);
        List<GOTerm> proteinGOTerms = proteinName2GOTerms.get(protein.getName());
        if (proteinGOTerms != null) {
            goTerms.addAll(proteinName2GOTerms.get(protein.getName()));
        }
    }
    Map<GOTerm, Integer> counts = new LinkedHashMap<GOTerm, Integer>();
    for (GOTerm goterm : goTerms) {
        Integer sum = counts.get(goterm);
        if (!counts.containsKey(goterm)) {
            counts.put(goterm, 1);
        } else {
            counts.put(goterm, counts.get(goterm) + 1);
        }
    }
    return (counts);
}
Also used : ArrayList(java.util.ArrayList) CyNode(org.cytoscape.model.CyNode) Protein(org.cytoscape.phenomescape.internal.Protein) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with Protein

use of org.cytoscape.phenomescape.internal.Protein 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 3 with Protein

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

the class GOTermAnalyser2 method goTermsinSubnetwork.

private Map<GOTerm, Integer> goTermsinSubnetwork(ProteinNetwork proteinNetwork, PhenomeExpressSubnetwork subnetwork) {
    Collection<CyNode> nodes = subnetwork.getNodeList();
    List<GOTerm> goTerms = new ArrayList<GOTerm>();
    for (CyNode node : nodes) {
        Protein protein = subnetwork.getNode2Protein().get(node);
        List<GOTerm> proteinGOTerms = proteinName2GOTerms.get(protein.getName());
        if (proteinGOTerms != null) {
            goTerms.addAll(proteinName2GOTerms.get(protein.getName()));
        }
    }
    Map<GOTerm, Integer> counts = new LinkedHashMap<GOTerm, Integer>();
    for (GOTerm goterm : goTerms) {
        Integer sum = counts.get(goterm);
        if (!counts.containsKey(goterm)) {
            counts.put(goterm, 1);
        } else {
            counts.put(goterm, counts.get(goterm) + 1);
        }
    }
    return (counts);
}
Also used : ArrayList(java.util.ArrayList) CyNode(org.cytoscape.model.CyNode) Protein(org.cytoscape.phenomescape.internal.Protein) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with Protein

use of org.cytoscape.phenomescape.internal.Protein 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

Protein (org.cytoscape.phenomescape.internal.Protein)4 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)2 CyNode (org.cytoscape.model.CyNode)2 PhenomeExpressSubnetwork (org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork)2 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 AVector (mikera.vectorz.AVector)1