Analysing and visualising

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Analysing and visualising

Ruffle, James
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
_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|

Re: Analysing and visualising

Tiago Peixoto
Administrator
Am 05.08.19 um 15:09 schrieb Ruffle, James:
> 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.?

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

--
Tiago de Paula Peixoto <[hidden email]>


_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (849 bytes) Download Attachment
--
Tiago de Paula Peixoto <tiago@skewed.de>
Reply | Threaded
Open this post in threaded view
|

Re: Analysing and visualising

James Ruffle
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

> On 6 Aug 2019, at 10:42, Tiago de Paula Peixoto <[hidden email]> wrote:
>
> Am 05.08.19 um 15:09 schrieb Ruffle, James:
>> 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.?
>
> 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
>
> --
> Tiago de Paula Peixoto <[hidden email]>
>
> _______________________________________________
> graph-tool mailing list
> [hidden email]
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.skewed.de%2Fmailman%2Flistinfo%2Fgraph-tool&amp;data=02%7C01%7Cj.ruffle%40qmul.ac.uk%7C0ea3a8c03e9b4f7062aa08d71a5291b0%7C569df091b01340e386eebd9cb9e25814%7C0%7C0%7C637006814256695922&amp;sdata=G7g05DXD5IFj4T%2Fov3AsXbdweKdkAabUfBfwqGwMii4%3D&amp;reserved=0

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|

Re: Analysing and visualising

Tiago Peixoto
Administrator
Am 07.08.19 um 14:20 schrieb James Ruffle:

> 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?

In MacOS I believe you need to have XQuartz installed:

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

Best,
Tiago

--
Tiago de Paula Peixoto <[hidden email]>


_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (849 bytes) Download Attachment
--
Tiago de Paula Peixoto <tiago@skewed.de>
Reply | Threaded
Open this post in threaded view
|

Re: Analysing and visualising

James Ruffle

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


On 15/08/2019 10:31, Tiago de Paula Peixoto wrote:
Am 07.08.19 um 14:20 schrieb James Ruffle:
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?

In MacOS I believe you need to have XQuartz installed:

    https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fen.lmgtfy.com%2F%3Fq%3Dmacos%2Bdocker%2Bconnecting%2Bto%2Bx%2Bserver&amp;data=02%7C01%7Cj.ruffle%40qmul.ac.uk%7C5866439148a441907c9d08d721635a08%7C569df091b01340e386eebd9cb9e25814%7C0%7C0%7C637014582917811452&amp;sdata=B3VgUw7w1j%2FSKbVppFXmxcoaTRzThxSG9czWNO%2B7Nmc%3D&amp;reserved=0

Best,
Tiago


_______________________________________________
graph-tool mailing list
[hidden email]
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.skewed.de%2Fmailman%2Flistinfo%2Fgraph-tool&amp;data=02%7C01%7Cj.ruffle%40qmul.ac.uk%7C5866439148a441907c9d08d721635a08%7C569df091b01340e386eebd9cb9e25814%7C0%7C0%7C637014582917831440&amp;sdata=MYxKehagVI6p0AE%2FDY%2BjwzIU5AsV9cZ%2FxPALfZwur4w%3D&amp;reserved=0

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|

Re: Analysing and visualising

peterhuson
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



--
Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|

Re: Analysing and visualising

Stuart Berg
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" <[hidden email] on behalf of [hidden email]> 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
   
   
   
    --
    Sent from: https://urldefense.com/v3/__http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/__;!!Eh6p8Q!QNg_LqaS-z2hYMT0iuGXgZsbLkcdR1fIjvaWq5bEfaUhRuvwKT7J54lwFxK-2q7YZA$ 
    _______________________________________________
    graph-tool mailing list
    [hidden email]
    https://urldefense.com/v3/__https://lists.skewed.de/mailman/listinfo/graph-tool__;!!Eh6p8Q!QNg_LqaS-z2hYMT0iuGXgZsbLkcdR1fIjvaWq5bEfaUhRuvwKT7J54lwFxLgVwIT4w$ 
   

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|

Re: Analysing and visualising

James Ruffle
Hi Peter.

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

BW
James

> On 24 Apr 2020, at 06:00, Berg, Stuart <[hidden email]> wrote:
>
> 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://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.skewed.de%2Fcount0%2Fgraph-tool%2F-%2Fwikis%2Finstallation-instructions%23conda&amp;data=02%7C01%7C%7Cd3e6f70f887e433efca108d7e80c6062%7C569df091b01340e386eebd9cb9e25814%7C0%7C1%7C637233012181569674&amp;sdata=6hpJL7AGTqBIFd6qcn%2FD%2B%2Fr0zn4nhFhieD9yv5igkqI%3D&amp;reserved=0
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.skewed.de%2Fcount0%2Fgraph-tool%2F-%2Fwikis%2Finstallation-instructions%23homebrew&amp;data=02%7C01%7C%7Cd3e6f70f887e433efca108d7e80c6062%7C569df091b01340e386eebd9cb9e25814%7C0%7C1%7C637233012181569674&amp;sdata=GSLrFGSGpDGiX0yz6MRB9mELiXO22TlB4mzU1U539Tc%3D&amp;reserved=0
>
> 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" <[hidden email] on behalf of [hidden email]> 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
>
>
>
>    --
>    Sent from: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__http%3A%2F%2Fmain-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com%2F__%3B!!Eh6p8Q!QNg_LqaS-z2hYMT0iuGXgZsbLkcdR1fIjvaWq5bEfaUhRuvwKT7J54lwFxK-2q7YZA%24&amp;data=02%7C01%7C%7Cd3e6f70f887e433efca108d7e80c6062%7C569df091b01340e386eebd9cb9e25814%7C0%7C0%7C637233012181569674&amp;sdata=dSd0C5NRmb9rthviso%2FDKvjCDYW1m8vFtivvjZve6f8%3D&amp;reserved=0 
>    _______________________________________________
>    graph-tool mailing list
>    [hidden email]
>    https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Flists.skewed.de%2Fmailman%2Flistinfo%2Fgraph-tool__%3B!!Eh6p8Q!QNg_LqaS-z2hYMT0iuGXgZsbLkcdR1fIjvaWq5bEfaUhRuvwKT7J54lwFxLgVwIT4w%24&amp;data=02%7C01%7C%7Cd3e6f70f887e433efca108d7e80c6062%7C569df091b01340e386eebd9cb9e25814%7C0%7C0%7C637233012181569674&amp;sdata=MsEwb%2F5VJ3T0ewhh6W3xRbZsuAkQIqyrIOUu3YECOXk%3D&amp;reserved=0 
>
>
> _______________________________________________
> graph-tool mailing list
> [hidden email]
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.skewed.de%2Fmailman%2Flistinfo%2Fgraph-tool&amp;data=02%7C01%7C%7Cd3e6f70f887e433efca108d7e80c6062%7C569df091b01340e386eebd9cb9e25814%7C0%7C1%7C637233012181569674&amp;sdata=VhSIabC8khYQm3QK62SYu4qWOxtOBkVxWgFwSUbxcp8%3D&amp;reserved=0
_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool