ebeshero / DHClass-Hub

a repository to help introduce and orient students to the GitHub collaboration environment, and to support DH classes.
GNU Affero General Public License v3.0
27 stars 27 forks source link

Cytoscape Stuff To Try #298

Closed ebeshero closed 7 years ago

ebeshero commented 7 years ago

@jonhoranic: Want to flesh this out with some explanation based on what we discussed after class today?)

1) Bundle your edges (on the layout menu) 2) Filter your big network into smaller networks. (Select a node, select its adjacent edges, and select their first neighbors (etc)). Then, Make New Network from Selection (icon). @bsf15 @ahunker @RJP43 @ajnewton1 @Samantha-Mcguigan

Samantha-Mcguigan commented 7 years ago

I saved my cytoscape session but when I re-opened it, all the changes I made were gone and it just went back to the way it was when I first put it in and I'm not sure why?

jonhoranic commented 7 years ago

@Samantha-Mcguigan I have not run into this problem yet, though I have lost slight changes due to Cytoscape crashing even if I had saved the session I was working on. Normally it is only the previous step(s) since the last save, but that is manageable. For your case, this is not due to a crash, but just opening the program? Perhaps there is a session reset or something going on, which is unfortunate. I would suggest making working saves that you can place in another folder and see if that helps.

There are a few things I want to elaborate on from class today (or rather our "mess around with stuff in Cytoscape time") that might be of use, I will do a bit of write up and post it here when I can. Ping in if you are still having problems.

jonhoranic commented 7 years ago

From Class 3/31/2017

There are many layout and display options for your network graphs in Cytoscape, but it can be difficult to view large graphs properly without doing a lot of "click and drag" editing.

To avoid spending hours trying to make your graph perfect by hand, these options can help with the viewing and pruning of your networks.

Scaling

When you have a graph loaded, clicking on "Scale" inside the "Layout" tab will toggle a content box in the lower left of the screen (below the "Contol Panel" window)

scale

When scaling, make sure you chose one of the three specific axis types (y, x, or both) you wish to expand/retract. The checkbox for "selected nodes" is checked on by default, as long as you have not clicked on any part of your graph you do not need to worry about this box. Click and drag the arrow on the line and SLOWLY (to avoid unneeded crashes due to the real time scaling) to the left to condense, or the right to expand. If you want to scale higher/lower then is possible, click the "Reset scale bar" box to move the arrow back to center. This will not effect your graph.

scalebox

Edge Bundling

In the same "Layout" tab, the first item on that list is "Bundle Edges" which binds the edge lines into a weighted "branching" tube to make a graph more presentable and readable. A small popup bow will show different values before you can run it with the "ok" button, the only number to focus on is the "Number of handles" set at 3. This should be enough for your graphs but if you edit this number it creates a "tighter" bundle the larger the integer. Experiment with it to see what happens, but you will be fine just clicking "ok" when this box pops up.

Selecting Nodes and their Relations

This section requires these steps to be done in the EXACT order to work properly. As a test, click on a single node on your graph, it will now be highlighted. Without clicking anywhere else in the view window, move up here to the "Select" tab and look for the extended "Edges" menu.

edges

By clicking on "Select adjacent edges", any of the lines stemming off of your highlighted node will now be highlighted too, showing the directions they fan out to. Again, do not click anywhere else in the view window, go back up to the "Select" tab and this time look in the extended "Nodes" menu.

nodes

Hover over the top option, "First Neighbors of Selected Nodes" and choose "Undirected". Notice now that the nodes that were connected to your previously highlighted edge lines are now highlighted as well. What you have done by following these steps is single out a relationship '"map" of the nodes directly associated with your first choice. This can be helpful for debugging purposes, styling, and for this next section:

Creating a "Sub-Network"

After doing all the previous steps, and without clicking on the view window, find this button along the top ribbon.

newnetwork

This will generate a new network solely based off your selection, pruning off the the parts you have not selected. This can greatly improve readability, crop off problematic nodes, or just help pinpoint specific relationships you want to view more closely. As you can see here:

rightclickoptions

From the original graph, there is an indentation noting the new "child" graph that acts somewhat like a layer, where you can make edits and style changes on this new graph without effecting the "parent" graph. Right clicking on the tiles provides drop down lists of options, including the option to delete the "child" graph if necessary.

Hopefully these tools and steps can help. If anything in this post is misleading or broken, please let me know! Feel free to post some of your own experimentation here as well.

@ebeshero @Samantha-Mcguigan @bsf15 @ahunker @ajnewton1 @RJP43

jonhoranic commented 7 years ago

I forgot to mention the options located in the "Edit" tab, two very useful pruning tools whose names are quite self explanatory:

  1. Remove Duplicated Edges - If multiple edges appear more than once and are particularity unnecessary for detail/context of your graph, this will significantly improve the readability by removing them.

  2. Remove Self Loops - Do your edges wrap back around to the same level? Odd mistakes like that can pop up in even the most well formed code, so this removes these pesky things without having to revamp your original code.

RJP43 commented 7 years ago

Beware of bundling edges! @ebeshero @bsf15 @ahunker and I have just realized while working on the Hamilton Project that by bundling the edges we lost several edges that we wanted for filtering the graph based on the edge/interaction column. We suggest that bundling is held off until after filtering in the future.