Search in sources :

Example 1 with CCInfo

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

the class ProteinNetwork method largestConnectedComponent.

public CCInfo largestConnectedComponent() {
    ConnectedComponentAnalyser ccAnalyser = new ConnectedComponentAnalyser(this.network);
    CCInfo Lcc = ccAnalyser.findLargestComponent();
    return Lcc;
}
Also used : ConnectedComponentAnalyser(org.cytoscape.phenomescape.internal.util.ConnectedComponentAnalyser) CCInfo(org.cytoscape.phenomescape.internal.util.CCInfo)

Example 2 with CCInfo

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

the class ProteinNetwork method filterByExpression.

public void filterByExpression(String foldChangeName, String pvalueName, String geneNameName) throws IOException {
    try {
        Set<CyNode> nodesToBeRemoved = NetworkUtils.getNodeswithFoldChange(this.network, this.nodeTable, foldChangeName, pvalueName, "");
        if (nodesToBeRemoved.size() > 0) {
            filterNetwork(nodesToBeRemoved);
        }
    } catch (Exception e) {
        throw new IOException("fold changes have to be numeric!");
    }
    CCInfo lcc = largestConnectedComponent();
    if (lcc.getSize() < 1)
        throw new IOException("Error filtering expression data - are the gene names correct?");
    Set<CyNode> nodesToKeep = lcc.getNodes();
    List<CyNode> currentNodeSet = network.getNodeList();
    currentNodeSet.removeAll(nodesToKeep);
    if (currentNodeSet.size() > 0) {
        filterNetwork(currentNodeSet);
    }
    nodeTable = network.getDefaultNodeTable();
    // error checking
    if (nodeTable.getColumn(pvalueName).getType() != Double.class) {
        throw new IOException("The p-values to be numeric");
    }
    ;
    if (nodeTable.getColumn(foldChangeName).getType() != Double.class) {
        throw new IOException("The fold change values have to be numeric");
    }
    ;
    if (Collections.min(nodeTable.getColumn(pvalueName).getValues(Double.class)) < 0) {
        throw new IOException("The p-values have to be positive");
    }
    if (nodeTable.getColumn(pvalueName).getValues(Double.class).contains(null)) {
        throw new IOException("The pvalues can't be NA or blank");
    }
    if (nodeTable.getColumn(foldChangeName).getValues(Double.class).contains(null)) {
        throw new IOException("The pvalues can't be NA or blank");
    }
    try {
        nodeTable.getColumn(geneNameName).getValues(String.class).contains(null);
    } catch (Exception e) {
        throw new IOException("Gene Names must be a strings");
    }
    nodeTable.getColumn(foldChangeName).getValues(Double.class);
    nodeTable.getColumn(pvalueName).getValues(Double.class);
    nodeTable.getColumn(geneNameName).getValues(String.class);
    if (nodeTable.getColumn("Pi Value") == null) {
        nodeTable.createColumn("Pi Value", Double.class, false);
    }
    pivalues = new double[network.getNodeList().size()];
    List<CyNode> nodes = network.getNodeList();
    for (int i = 0; i < nodes.size(); i++) {
        CyRow row = nodeTable.getRow(nodes.get(i).getSUID());
        Double fc = row.get(foldChangeName, Double.class);
        Double pvalue = row.get(pvalueName, Double.class);
        double pivalue = Math.abs(fc) * (-1) * Math.log10(pvalue);
        pivalues[i] = pivalue;
        row.set("Pi Value", pivalue);
    }
}
Also used : CCInfo(org.cytoscape.phenomescape.internal.util.CCInfo) CyNode(org.cytoscape.model.CyNode) IOException(java.io.IOException) CyRow(org.cytoscape.model.CyRow) IOException(java.io.IOException)

Aggregations

CCInfo (org.cytoscape.phenomescape.internal.util.CCInfo)2 IOException (java.io.IOException)1 CyNode (org.cytoscape.model.CyNode)1 CyRow (org.cytoscape.model.CyRow)1 ConnectedComponentAnalyser (org.cytoscape.phenomescape.internal.util.ConnectedComponentAnalyser)1