Analysing and visualising

Dear Graph-Tool Community,

I am interested in analysing the hierarchical partitions generated by the nested blockmodel. Specifically, after I have generated a nested SBM; I would then like to post-process this and calculate measures such as eigenvector centrality for a given hierarchical node; save this as a property, and then in visualisation apply either a size or colormap constraint to said node weighted by its centrality.

Using the collection data;
g = gt.collection.data["celegansneural”]
state = gt.minimize_nested_blockmodel_dl(g)

I can then ascertain what my levels are with;
l1state = state.levels[1].g
l2state = state.levels[2].g
etc.

I can then calculate eigenvector centrality of a given hierarchical partition as follows;
ee1, x1 = gt.eigenvector(l1state)
ee2, x2 = gt.eigenvector(l2state)

1) This presumably then needs to be saved as a hvprops(?!). But, I am unclear how to do this, not least in a way that I know for sure that the correct hierarchical vertices within l1state and l2state are aligning to the generated centrality measures of x1 and x2, respectively.

2) Furthermore, if/when that is achieved, how can I call upon this in drawing, for example to size the level 1 hierarchical vertices according to centrality, or level 2 vertices by another measure, etc.?

Hugely grateful for any solutions!

James

If you call state.draw() (which calls draw_hierarchy()), it returns,
among other things, the hierarchy tree as a graph. The 'hvprops' should
be a dictionary with drawing attributes to that graph. It can contain
property maps, which do not need to be owned by the hierarchy tree but
need to have the same size.

To get the hang of it, you can call state.draw() once to obtain the
hierarchy tree, and then pass values to hvprops to see how that affects
the layout.

Best,
Tiago

Hi Tiago,

Thanks for this.

Unfortunately my machine seems to fail with calling state.draw() for interactive visualisation which makes it difficult to understand exactly how this interacts.
I am running it from the docker image, on macOS 10.14.16.

Following your instructions on installation page;

docker pull tiagopeixoto/graph-tool
xhost +local:
docker run -ti -u user -w /home/user --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix tiagopeixoto/graph-tool ipython

from graph_tool.all import * ; import graph_tool.all as gt ;
Unable to init server: Could not connect: Connection refused
(ipython:1): Gdk-CRITICAL **: 12:54:59.581: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)’ failed
(ipython:1): Gdk-CRITICAL **: 12:54:59.598: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)’ failed

g = gt.collection.data["celegansneural”]
state = gt.minimize_nested_blockmodel_dl(g)
state.draw()
RuntimeError: Gtk couldn't be initialized. Use Gtk.init_check() if you want to handle this case.

Do you have a suggestion how to resolve this?

I can of course make use of the output function to review what changes are being made, but it still leaves me a little confused of how I can assign hvprop weightings and call upon them with state.draw.

Alternatively, could you kindly provide an example how to make use of the hvprops, add a set of parameters as weights (such as the eigenvector centrality of hierarchical nodes) and assign this as a propertymap for the output? I’m not sure if such an example is available on your repository, but do correct me if I’m wrong..

Appreciate your guidance!

James

In MacOS I believe you need to have XQuartz installed:

    https://en.lmgtfy.com/?q=macos+docker+connecting+to+x+server

Best,
Tiago

Thanks for this. Sorted..!

However, I am still struggling to understand how to call and make use of the hierarchical vertexes and edges after running the nSBM.

state=gt.minimize_nested_blockmodel_dl(g)

I can then pull the levels and calculate their centrality with:

l1state = state.levels[1].g

ee1, x1 = gt.eigenvector(l1state)

But what command do I need to initiate to firstly save this into the property map, and then plot it, e.g. with the l1 level vertices sized proportionate to E.C in state.draw?

(Or I guess, consider a different scenario where I want to attribute value to the hierarchical edges, and then plot that accordingly).

I couldn't see any documentation for this on the website other than that hvprop does exist, but if there was such as an example please do point me to it...?

Thanks again!

James

attachment.html (4.47 KB)

Hi James,

I'm wondering how you were able to resolve the error from the X server:

Unable to init server: Could not connect: Connection refused

XQuartz is installed, and I know it works because I have been able to
forward X applications to it previously using ssh -X. I'm on OSX 10.12 using
XQuartz 2.7.11

I followed the instructions running:

xhost +local:
docker run -ti -u user -w /home/user --rm -e DISPLAY=$DISPLAY -v
/tmp/.X11-unix:/tmp/.X11-unix tiagopeixoto/graph-tool ipython

Would you be able to share how you configured your xhost to accept
connections from the docker container?

Thanks for your help.
Peter

Hi Peter,

I don't know the answer to your question about Docker and X11. But just in case it's useful, I'll point out that the easiest way to run graph-tool on Mac is probably to use conda or homebrew. Both of those options provide pre-compiled binaries, so installation should (hopefully) be fairly quick and painless.

https://git.skewed.de/count0/graph-tool/-/wikis/installation-instructions#conda
https://git.skewed.de/count0/graph-tool/-/wikis/installation-instructions#homebrew

If you knew that already and you prefer the Docker container for other reasons, then I'm sorry for this noise.

Best,
Stuart

On 4/23/20, 11:46 PM, "graph-tool on behalf of peterhuson" <graph-tool-bounces(a)skewed.de on behalf of peter(a)huson.com> wrote:

    Hi James,
    
    I'm wondering how you were able to resolve the error from the X server:
    > Unable to init server: Could not connect: Connection refused
    
    XQuartz is installed, and I know it works because I have been able to
    forward X applications to it previously using ssh -X. I'm on OSX 10.12 using
    XQuartz 2.7.11
    
    I followed the instructions running:
    
    xhost +local:
    docker run -ti -u user -w /home/user --rm -e DISPLAY=$DISPLAY -v
    /tmp/.X11-unix:/tmp/.X11-unix tiagopeixoto/graph-tool ipython
    
    Would you be able to share how you configured your xhost to accept
    connections from the docker container?
    
    Thanks for your help.
    Peter

Hi Peter.

Just as Stuart also said - brew was how I got it working on Mac OS successfully.

BW
James