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);
}
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;
}
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);
}
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;
}
Aggregations