In the the previous post I discussed the integration of OpenCL into Processing by means of its library mechanism. An early version of a new OpenCL-physics library, based on traer.physics, was used to simulate a couple of particle systems in real-time (N-Body and Springs). An interesting application of these new methodologies is to carry out GPU-acceleration of compute operations in Cytoscape. Networks of protein-protein interactions handled in Cytoscape usually involve thousands of nodes and edges. The visualization and analysis of such networks is computationally demanding, and the use of parallel processing on GPUs provides a way to cope with this complexity. So what I did as a new experiment with OpenCL and OpenGL was to use CLPhysics to simulate a force-directed network layout in Cytoscape.
This simulation works as a Cytoscape plugin, and in order to put this plugin together I relied on a small template I wrote a while ago to facilitate the creation of Cytoscape plugins using Processing (for the convenience of other developers, this template is available in a Google code repository).
The plugin relies on the Cytoscape API to access the nodes and edges currently selected. This data is then used to construct a particle system that includes spring forces between connected nodes and repulsive forces between all node pairs.
The simulation then runs on the GPU using the CLPhysics library I mentioned earlier. Most of the calculations required for the simulation (force evaluation, time integration) are well suited for parallelization on the GPU, so they can run substantially faster than equivalent code on the CPU. In this particular case, where I loaded the network from the sample file yeastHighQuality included in Cytoscape 2.8, there are around 3,000 nodes and 7,000 edges, and the simulation can be visualized in real-time as it is generated:
The CLPhysics library is highly experimental at this point, so the OpenCL code used in the simulations is preliminary and not optimized at all. But based on results like this one, I’d expect much larger networks to be also amenable of visualization (and analysis) in real-time.