Skip to content

Instantly share code, notes, and snippets.

@lrvdijk
Last active August 29, 2015 14:17
Show Gist options
  • Save lrvdijk/23e3b0f446f80634713c to your computer and use it in GitHub Desktop.
Save lrvdijk/23e3b0f446f80634713c to your computer and use it in GitHub Desktop.

Visualizing static and dynamic networks in Vispy

Abstract

Vispy is a high performance 2D/3D visualization library which uses the GPU intensively through OpenGL. This Google Summer of code project proposes to add an API to Vispy to visualize static and dynamic (boolean, linear and Bayesian) networks. Additionally, I would like to add support for calculating projections onto a given 2D or 3D subspace on the GPU, which helps when you want to visualize higher dimensional data. Possible extensions include support for hive plots, and some high level API's for visualizing biological data.

General Information

Suborganization: Vispy

Personal & Contact

Name:Lucas van Dijk
Email:info@lucasvandijk.nl
Telephone:redacted
Time Zone:Europe/Amsterdam (CET)
IRC:sh4wn@irc.freenode.net
Github:https://github.com/sh4wn
Bitbucket:https://bitbucket.org/sh4wn
CV:Here (pdf)
Twitter:https://twitter.com/lucasvandijk (Dutch)
Homepage:http://return1.net (Will be updated with a Mezzanine based blog)
RSS Feed:http://return1.net/blog/rss

University

University:Delft University of Technology
Major:Bio-informatics
Current Year:First year
Degree:MSc (already completed bachelor electrical engineering)

The Project

Introduction

Python is one of the more popular languages in the scientific world, and a common task for scientists is visualizing a lot of data. This is were Vispy comes in: a high performance 2D/3D scientific visualization library, which intensively uses the GPU through OpenGL to render these interactive visualizations.

I'm currently studying bio-informatics, and a common task is creating an interaction network between genes, transcription factors, proteins and other molecules from measured data of a cell. Visualizing these networks helps a lot in understanding certain biological processes. It would be even better if we could visualize the dynamics of a network when it's modelled as a boolean, linear or Bayesian network.

This is a task I think Vispy would excel at! Plus, networks are of course used in a lot of scientific fields, so there are a lot of potential users.

Components

The idea is to to split this project into three major parts: creating some basic visuals, visualizing networks, and a higher dimensional data viewer.

Basic Visuals

I'm not very experienced with modern OpenGL programming yet, but I'm not completely new to GPU and graphics programming. Still, we start relatively simple by creating a few visuals that would come handy when visualizing networks.

Port Bezier curves from GlumPy
In GlumPy there is already support for drawing curved Bezier lines. I'm going to port this functionality to VisPy.
Port exisiting arrows from GlumPy
GlumPy already has some code for some arrow visuals with several heads. I'm going to port this code, and will also change it so we can separate the body of the arrow from the head. This will allow us to draw Bezier lines with an arrow head.
Add additional arrow heads

When the arrow body and tail are separated, it's probably relatively easy to use the existing marker visuals as arrow heads. I'll make sure this is possible.

I'll also add an "inverse" arrow head, which is often used to visualize nodes where one inhibits the other.

http://return1.net/static/gsoc/gsoc-inhibitor.png

A bezier line with an "inhibitor" head.

The result should be something like this:

http://return1.net/static/gsoc/arrows.png

A collection of bezier curves with different heads.

Network Visualization

The main part of this project. The goal is to design and implement a nice API for visualizing networks. All sorts of networks must be supported: directed and non-directed networks, multiple edges per node, etc.

Requirements
  • Visuals, colors and other appearance properties should be very configurable
    • Visuals for nodes
    • Visuals for edges
    • Colors
    • Node/edge annotations
  • Support for different automatic layouts
    • Force directed
    • Radial
    • Circular
    • Hierarchical
    • Orthogonal
    • yFiles Organic
    • ...
  • Support for dynamic networks
    • Boolean
    • Linear
    • Bayesian
    • With interactivity, for example clicking on a node changes a certain value, which could have effects in the rest of the network.
Possible API

There is of course already the amazing library NetworkX, and I don't think it would be a good idea to reimplement a lot of functionality for representing networks in Vispy when there is NetworkX. But you don't want too tight integration to make sure other choices for network libraries are possible.

class vispy.networks.scene.NetworkSceneGraph

A convenience class for visualizing networks. This class assumes nothing, and just draws the nodes and edges at a given position. It has no knowlegde of any layout, or the underlying network. This also means it has no dependency on NetworkX.

Methods

  • draw_nodes(pos, visual)
    Draw nodes at the given positions with the given visual object
  • draw_edges(pos, visual)
    Draw the edges between the given points and the given visual object.
  • draw_labels(pos, visual)
    Draw the labels at the given positions.
  • draw_annotations(pos, visual_line, visual_box=None)
    Draw annotations to the edges at the given positions with a certain line visual and optionally a box visual around it.
class vispy.networks.scene.DynamicNetworkSceneGraph
The same as above, but will also contain code to manage the dynamic behaviour of the network.
module vispy.networks.layouts
This module contains functions which calculate the several layouts. This is where I'm inclined to depend on NetworkX, because it already has several network layouts, and for the layouts that aren't available we would need some representation for the networks. The functions will use "duck typing", so other objects using the same API for nodes and edges should also work with this.
module vispy.networks.visualization
Helper functions and classes to construct a NetworkSceneGraph from a given NetworkX network.
module vispy.networks.dynamic

Classes to represent the dynamic models for a network.

Classes

  • BaseNetworkModel
    • step(): A method which calculates the next time step in a network.
  • BooleanNetwork
  • LinearNetwork
  • BayesianNetwork

Higher Dimensional Data Viewer

In a lot of scientific fields you often have higher dimensional data which is not easily visualized in 2D or 3D. Still, it's often very convenient to visualize this data. So this part of the project aims to provide some tools to help with this task.

Scenario:

  1. The user has a dataset which is a matrix of size (N, D). Here N is the number of data points, and D is the dimension (which is supposed to be high).
  2. The user supplies the vectors of size (3, D) which spans a 3D subspace within R^D
  3. The user applies some dimension reduction techniques on his data.
  4. Vispy calculates the projections of this data on the given subspace
  5. Visualize it!

For this project I will mainly focus on calculating the linear projections on the GPU.

Project Extensions

If there is still some time left after above projects are finished because things were easier than expected, I have some extra ideas which would be nice to implement.

  1. Add support for hive plots, an alternative way for visualizing networks.
  2. Add support for visualizing genomes and sequence alignment results.

Schedule

Date Description
April 27th Community bonding, read Vispy documentation and code, already start playing with the visuals I want to create.
May 25th GSoC official start. Definitely start with the simple visuals.
June 8th Visuals finished. Start with rendering of nodes and edges for static networks. No automatic layouts yet.
June 22th Start with the several automatic layouts.
July 6th Automatic layouts should work. Start with the API for dynamic networks, for simulating boolean, linear and Bayesian networks. Also add interactivity.
August 3rd Dynamic networks finished. Start with calculating projections on 3D subspace on the GPU for higher dimensional data.
August 17th Soft pencils down date. Make sure documentation looks nice, write some last tests, finish up the code.
August 21th Firm pencils down date.

Relevant information for schedule

  • I have a part time (8 hours/week) job as Python developer. The hours are flexible so this should not be a problem for the summer.
  • I'm not planning to go on a vacation this summer if I get accepted.
  • I do have some deadlines for some study assignments in the beginning of june.
  • I have a deadline for a research proposal on june 19th.
  • I have not applied with any other mentoring organisations.
  • I'm planning to work 40 hours per week on this project.

Other resources

Patch
I've implemented several extra colormaps, and the code lives in this branch on Github. More information can be found on the corresponding pull request.
Mailing list discussion
This idea has been discussed on the vispy-dev mailinglist.

A few past projects

Ray collision and reflection detector internship
As part of a three month internship, I wrote a program which could load a 3D model, and analyze the reflection behaviour of the model. This program was build using the nVidia Optix ray tracing library, which is built on top of CUDA. For this program I wrote some simple shaders and other GPU's programs to calculate and visualize the results.
"Jonge Democraten" website
The "Jonge Democraten" are a political youth party in the Netherlands. I'm part of the IT-team there, and we're currently recreating the website [1] again using the Python CMS system Mezzanine. The code is available on Github [2].
Helios 3D
Together with some other students from the TU Delft we've created a large RGB 3D LED display. I was responsible for the embedded software on the several Raspberry Pi's. Not all code is publicly available, but some of can be seen in this repository. The website of the project (which is also based on Mezzanine) can be found on http://helios3d.nl.
GIS related tools for my current employer
I currently work as a part time Python developer for a traffic engineering consultancy, where I've developed several tools for managing and visualizing a lot of data for traffic analysis. Tools used: QGIS and our own Python plugins, PostgreSQL with PostGIS, NumPy, Django REST framework.
Google Summer of Code 2011
I was also part of the GSoC for GNOME in 2011. The idea was to create plugins for Anjuta (a GNOME IDE) which would transform it in an IDE for AVR microcontrollers. But although I passed for all evaluations I would not consider this a really successful project due to rough communication with my mentor at that time (I've got more help from other developers of the project), and I overestimated my C skills a bit (the gap between C on a microcontroller and C for a complex GUI application is quite big).
Several other projects
There are several other projects available on my Github [3], some in more complete state than the other. Examples include a quite complete IRC bot, a tool to categorize your expenses, and tries to automatically guess the category using the Python Natural Language Toolkit, or a small game where one needs to "hack" into a "digital lock" to find the code the open the lock.
[1]http://jd.nl
[2]https://github.com/jonge-democraten/website
[3]https://github.com/sh4wn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment