Search in sources :

Example 1 with AVector

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);
}
Also used : AMatrix(mikera.matrixx.AMatrix) AVector(mikera.vectorz.AVector)

Example 2 with AVector

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);
            }
        }
    }
}
Also used : Phenotype(org.cytoscape.phenomescape.internal.util.Phenotype) AVector(mikera.vectorz.AVector) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge)

Example 3 with AVector

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);
}
Also used : AMatrix(mikera.matrixx.AMatrix) AVector(mikera.vectorz.AVector)

Example 4 with AVector

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);
}
Also used : AMatrix(mikera.matrixx.AMatrix) AVector(mikera.vectorz.AVector)

Example 5 with AVector

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;
}
Also used : AVector(mikera.vectorz.AVector) LinkedList(java.util.LinkedList) PhenomeExpressSubnetwork(org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork) Protein(org.cytoscape.phenomescape.internal.Protein)

Aggregations

AVector (mikera.vectorz.AVector)10 AMatrix (mikera.matrixx.AMatrix)6 CyEdge (org.cytoscape.model.CyEdge)2 CyNode (org.cytoscape.model.CyNode)2 Phenotype (org.cytoscape.phenomescape.internal.util.Phenotype)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Index (mikera.indexz.Index)1 SparseRowMatrix (mikera.matrixx.impl.SparseRowMatrix)1 CyApplicationManager (org.cytoscape.application.CyApplicationManager)1 CyEventHelper (org.cytoscape.event.CyEventHelper)1 CyNetworkManager (org.cytoscape.model.CyNetworkManager)1 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)1 PhenomeExpressSubnetwork (org.cytoscape.phenomescape.internal.PhenomeExpressSubnetwork)1 Protein (org.cytoscape.phenomescape.internal.Protein)1 DescendingScoreComparator (org.cytoscape.phenomescape.internal.Protein.DescendingScoreComparator)1 ConnectedComponentAnalyser (org.cytoscape.phenomescape.internal.util.ConnectedComponentAnalyser)1 GOTermAnalyser2 (org.cytoscape.phenomescape.internal.util.GOTermAnalyser2)1 VizStyle (org.cytoscape.phenomescape.internal.util.VizStyle)1