use of mikera.vectorz.AVector in project PhenomeScape by soulj.
the class PhenoGeneNetwork method normaliseT.
public AMatrix normaliseT(double transitionProb) {
AMatrix matrix = bipartiteAdjMatrixT.copy();
for (int i = 0; i < matrix.rowCount(); i++) {
AVector row = matrix.getRow(i);
double sum = row.elementSum();
if (sum > 0) {
row = row.mutable();
row.multiply(transitionProb);
row.divide(sum);
matrix.replaceRow(i, row);
}
}
return (matrix);
}
use of mikera.vectorz.AVector in project PhenomeScape by soulj.
the class PhenomeExpress method addSeedPhenotypes.
private void addSeedPhenotypes(CySubNetwork subnetwork) {
phenotypesAdded = new ArrayList<CyNode>();
phenoEdges = new ArrayList<CyEdge>();
if (proteinNetwork.getNodeTable().getColumn("PhenotypeID") == null) {
proteinNetwork.getNodeTable().createColumn("PhenotypeID", String.class, false);
}
for (Phenotype phenotype : selectedPhenotypes) {
HashMap<String, Integer> nameMap = phenoGeneNetwork.getPhenotypeName2IndexMap();
Integer index = nameMap.get(phenotype.getID());
if (index == null) {
continue;
}
AVector row = phenoGeneNetwork.getBipartiteAdjMatrix().getRow(Integer.valueOf(index));
for (CyNode node : subnetwork.getNodeList()) {
// get the node index
Integer proteinIndex = proteinNetwork.getNode2IndexMap().get(node);
if (proteinIndex == null) {
continue;
}
// check if there is an association or not
if (row.get(proteinIndex) != 0.0) {
CyNode phenoNode = null;
if (proteinNetwork.getNodeTable().getMatchingRows("name", phenotype.getID()).isEmpty()) {
phenoNode = proteinNetwork.getNetwork().addNode();
proteinNetwork.getNodeTable().getRow(phenoNode.getSUID()).set(CyNetwork.NAME, phenotype.getID());
proteinNetwork.getNodeTable().getRow(phenoNode.getSUID()).set("name", phenotype.getID());
proteinNetwork.getNodeTable().getRow(phenoNode.getSUID()).set("PhenotypeID", phenotype.getName());
} else {
phenoNode = NetworkUtils.getNodeWithName(proteinNetwork.getNetwork(), proteinNetwork.getNodeTable(), "name", phenotype.getID());
}
subnetwork.addNode(phenoNode);
subnetwork.getDefaultNodeTable().getRow(phenoNode.getSUID()).set("name", phenotype.getName());
subnetwork.getDefaultNodeTable().getRow(phenoNode.getSUID()).set("PhenotypeID", phenotype.getID());
phenotypesAdded.add(phenoNode);
proteinNetwork.getNetwork().addEdge(phenoNode, node, true);
CyEdge addedEdge = subnetwork.addEdge(phenoNode, node, true);
String proteinName = proteinNetwork.getIndex2ProteinMap().get(proteinIndex).getName();
proteinNetwork.getEdgeTable().getRow(addedEdge.getSUID()).set("interaction", "pgi");
proteinNetwork.getEdgeTable().getRow(addedEdge.getSUID()).set("name", phenotype.getID() + " (pgi) " + proteinName);
phenoEdges.add(addedEdge);
}
}
}
}
use of mikera.vectorz.AVector in project PhenomeScape by soulj.
the class PhenomeNetwork method normalise.
public AMatrix normalise(double transitionProb, PhenoGeneNetwork phenoGeneNetwork) {
Collection<Integer> annotated = phenoGeneNetwork.getPhenotypeName2IndexMap().values();
AMatrix matrix = adjMatrix.copy();
for (int i = 0; i < matrix.rowCount(); i++) {
AVector row = matrix.getRow(i);
double sum = row.elementSum();
row = row.mutable();
if (annotated.contains(i)) {
row.multiply(1.0 - transitionProb);
row.divide(sum);
matrix.replaceRow(i, row);
} else {
row.divide(sum);
matrix.replaceRow(i, row);
}
}
return (matrix);
}
use of mikera.vectorz.AVector in project PhenomeScape by soulj.
the class ProteinNetwork method normalise.
public AMatrix normalise(double transitionProb, PhenoGeneNetwork phenoGeneNetwork) throws IOException {
Collection<Integer> annotated = phenoGeneNetwork.getGeneName2IndexMap().values();
AMatrix matrix = adjMatrix.copy();
for (int i = 0; i < matrix.rowCount(); i++) {
AVector row = matrix.getRow(i);
double sum = row.elementSum();
row = row.mutable();
if (annotated.contains(i)) {
row.multiply(1.0 - transitionProb);
row.divide(sum);
matrix.replaceRow(i, row);
} else {
row.divide(sum);
matrix.replaceRow(i, row);
}
}
return (matrix);
}
use of mikera.vectorz.AVector 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;
}
Aggregations