Search in sources :

Example 11 with HeaderInfo

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.

the class TreeDrawer method setData.

/**
 * Set the data from which to draw the tree
 *
 * @param nodeInfo The headers from the node file.
 * There should be one header row per node.
 * There should be a column named "NODEID", "RIGHT", "LEFT" and one of either
 * "CORRELATION" or "TIME".
 *
 * @param rowInfo This is the header info for the rows which the ends of the tree are supposed to line up with.
 */
public void setData(HeaderInfo nodeInfo, HeaderInfo rowInfo) throws DendroException {
    if (nodeInfo == null) {
        setDefaults();
        return;
    }
    if (this.nodeInfo != null)
        this.nodeInfo.deleteObserver(this);
    this.nodeInfo = nodeInfo;
    nodeInfo.addObserver(this);
    leafList = new TreeDrawerNode[rowInfo.getNumHeaders()];
    id2node = new Hashtable(((nodeInfo.getNumHeaders() * 4) / 3) / 2, .75f);
    int nodeIndex = nodeInfo.getIndex("NODEID");
    if (nodeIndex == -1)
        throw new DendroException("Could not find header NODEID in tree header info");
    for (int j = 0; j < nodeInfo.getNumHeaders(); j++) {
        // extract the things we need from the enumeration
        String newId = nodeInfo.getHeader(j, nodeIndex);
        String leftId = nodeInfo.getHeader(j, "LEFT");
        String rightId = nodeInfo.getHeader(j, "RIGHT");
        // setup the kids
        TreeDrawerNode newn = (TreeDrawerNode) id2node.get(newId);
        TreeDrawerNode leftn = (TreeDrawerNode) id2node.get(leftId);
        TreeDrawerNode rightn = (TreeDrawerNode) id2node.get(rightId);
        if (newn != null) {
            System.out.println("Symbol '" + newn + "' appeared twice, building weird tree");
        }
        if (leftn == null) {
            // this means that the identifier for leftn is a new leaf
            // stores index (y location)
            int val;
            val = rowInfo.getHeaderIndex(leftId);
            if (val == -1) {
                Thread.dumpStack();
                throw new DendroException("Identifier " + leftId + " from tree file not found in CDT.");
            }
            leftn = new TreeDrawerNode(leftId, 1.0, val);
            leafList[val] = leftn;
            id2node.put(leftId, leftn);
        }
        if (rightn == null) {
            // this means that the identifier for rightn is a new leaf
            // System.out.println("Looking up " + rightId);
            // stores index (y location)
            int val;
            val = rowInfo.getHeaderIndex(rightId);
            if (val == -1) {
                Thread.dumpStack();
                throw new DendroException("Identifier " + rightId + " from tree file not found in CDT!");
            }
            rightn = new TreeDrawerNode(rightId, 1.0, val);
            leafList[val] = rightn;
            id2node.put(rightId, rightn);
        }
        if (leftn.getIndex() > rightn.getIndex()) {
            TreeDrawerNode swap = leftn;
            leftn = rightn;
            rightn = swap;
        }
        rootNode = new TreeDrawerNode(newId, 0.0, leftn, rightn);
        leftn.setParent(rootNode);
        rightn.setParent(rootNode);
        // finally, insert in tree
        id2node.put(newId, rootNode);
    }
    setBranchHeights(nodeInfo, rowInfo);
    setChanged();
}
Also used : TreeDrawerNode(edu.ucsf.rbvi.clusterMaker2.internal.treeview.TreeDrawerNode)

Example 12 with HeaderInfo

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.

the class HeatMapView method setEdgeSelection.

private void setEdgeSelection(List<CyEdge> edgeArray, boolean select) {
    HeaderInfo geneInfo = dataModel.getGeneHeaderInfo();
    HeaderInfo arrayInfo = dataModel.getArrayHeaderInfo();
    // Avoid loops -- delete ourselves as observers
    geneSelection.deleteObserver(this);
    arraySelection.deleteObserver(this);
    // Clear everything that's currently selected
    geneSelection.setSelectedNode(null);
    geneSelection.deselectAllIndexes();
    arraySelection.setSelectedNode(null);
    arraySelection.deselectAllIndexes();
    // Do the actual selection
    for (CyEdge cyEdge : edgeArray) {
        if (!myNetwork.containsEdge(cyEdge))
            continue;
        CyNode source = (CyNode) cyEdge.getSource();
        CyNode target = (CyNode) cyEdge.getTarget();
        int geneIndex = geneInfo.getHeaderIndex(ModelUtils.getName(myNetwork, source));
        int arrayIndex = arrayInfo.getHeaderIndex(ModelUtils.getName(myNetwork, target));
        geneSelection.setIndex(geneIndex, select);
        arraySelection.setIndex(arrayIndex, select);
    }
    // Notify all of the observers
    geneSelection.notifyObservers();
    arraySelection.notifyObservers();
    // OK, now we can listen again
    geneSelection.addObserver(this);
    arraySelection.addObserver(this);
}
Also used : HeaderInfo(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge)

Example 13 with HeaderInfo

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.

the class DendroView method updateATRDrawer.

/**
 * Updates the ATRDrawer to reflect changes in the DataMode
 * array order; rebuilds the TreeDrawerNode tree.
 * @param selectedID ID of the node selected before a change in
 *                   tree structure was made. This node is then
 *                   found and reselected after the ATR tree is rebuilt.
 */
private void updateATRDrawer(String selectedID) {
    try {
        TVModel tvmodel = (TVModel) getDataModel();
        invertedTreeDrawer.setData(tvmodel.getAtrHeaderInfo(), tvmodel.getArrayHeaderInfo());
        HeaderInfo trHeaderInfo = tvmodel.getAtrHeaderInfo();
        if (trHeaderInfo.getIndex("NODECOLOR") >= 0) {
            TreeColorer.colorUsingHeader(invertedTreeDrawer.getRootNode(), trHeaderInfo, trHeaderInfo.getIndex("NODECOLOR"));
        }
    } catch (DendroException e) {
        // LogPanel.println("Had problem setting up the array tree : " + e.getMessage());
        // e.printStackTrace();
        Box mismatch = new Box(BoxLayout.Y_AXIS);
        mismatch.add(new JLabel(e.getMessage()));
        mismatch.add(new JLabel("Perhaps there is a mismatch between your ATR and CDT files?"));
        mismatch.add(new JLabel("Ditching Array Tree, since it's lame."));
        JOptionPane.showMessageDialog(viewFrame, mismatch, "Tree Construction Error", JOptionPane.ERROR_MESSAGE);
        atrview.setEnabled(false);
        atrzview.setEnabled(false);
        try {
            invertedTreeDrawer.setData(null, null);
        } catch (DendroException ex) {
        }
    }
    TreeDrawerNode arrayNode = invertedTreeDrawer.getRootNode().findNode(selectedID);
    arraySelection.setSelectedNode(arrayNode.getId());
    atrzview.setSelectedNode(arrayNode);
    atrview.setSelectedNode(arrayNode);
    arraySelection.notifyObservers();
    invertedTreeDrawer.notifyObservers();
}
Also used : HeaderInfo(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo) TreeDrawerNode(edu.ucsf.rbvi.clusterMaker2.internal.treeview.TreeDrawerNode) TVModel(edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TVModel) AtrTVModel(edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.AtrTVModel)

Example 14 with HeaderInfo

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo in project clusterMaker2 by RBVI.

the class GTRView method getStatus.

// method from ModelView
public String[] getStatus() {
    String[] status;
    if (selectedNode != null) {
        if (selectedNode.isLeaf()) {
            status = new String[2];
            status[0] = "Leaf Node " + selectedNode.getId();
            status[1] = "Pos " + selectedNode.getCorr();
        } else {
            int[] nameIndex = getHeaderSummary().getIncluded();
            status = new String[nameIndex.length * 2];
            HeaderInfo gtrInfo = getViewFrame().getDataModel().getGtrHeaderInfo();
            String[] names = gtrInfo.getNames();
            for (int i = 0; i < nameIndex.length; i++) {
                status[2 * i] = names[nameIndex[i]] + ":";
                status[2 * i + 1] = " " + gtrInfo.getHeader(gtrInfo.getHeaderIndex(selectedNode.getId()))[nameIndex[i]];
            }
        }
    } else {
        status = new String[2];
        status[0] = "Select Node to ";
        status[1] = "view annotation.";
    }
    return status;
}
Also used : HeaderInfo(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo)

Aggregations

HeaderInfo (edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderInfo)12 CyNode (org.cytoscape.model.CyNode)6 CyEdge (org.cytoscape.model.CyEdge)4 TreeDrawerNode (edu.ucsf.rbvi.clusterMaker2.internal.treeview.TreeDrawerNode)3 HashMap (java.util.HashMap)2 CyEventHelper (org.cytoscape.event.CyEventHelper)2 CyNetwork (org.cytoscape.model.CyNetwork)2 CyNetworkView (org.cytoscape.view.model.CyNetworkView)2 ClusterManager (edu.ucsf.rbvi.clusterMaker2.internal.api.ClusterManager)1 DataModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataModel)1 LoadException (edu.ucsf.rbvi.clusterMaker2.internal.treeview.LoadException)1 ModelessSettingsDialog (edu.ucsf.rbvi.clusterMaker2.internal.treeview.ModelessSettingsDialog)1 AtrTVModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.AtrTVModel)1 DataModelWriter (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.DataModelWriter)1 ReorderedDataModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.ReorderedDataModel)1 TVModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TVModel)1 TreeViewModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.model.TreeViewModel)1 NetworkColorDialog (edu.ucsf.rbvi.clusterMaker2.internal.ui.NetworkColorDialog)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1