It uses nip2 to make the frames for the animation, I thought I'd write it up.
Background
This is an experiment with a line of cultured cells. The cells were split into eight batches and each batch given a different treatment. We used proteomics to find the abundance of the most interesting 1000 proteins in each batch. You get a table with 1000 columns and 8 rows, one row for each of the conditions, with the number at each point representing abundance.
Proteins which are related in some way (perhaps they are part of the same bit of biological machinery) ought to rise and fall together as conditions for the cells vary, so we calculated a correlation coefficient for every column against every other column. This gives you a 1000 by 1000 matrix with numbers between -1 and 1. Proteins which are related should have a large number of high values in common.
Clustering
We wrote a small program in Ruby to search for the closest two proteins (proteins are closer if they share a larger number of highly correlated proteins), join them, and loop until there are no proteins that are close together. The results were interesting but it was hard to get much insight into what the patterns the program had found meant.
Animation
To make the animation, we got the Ruby program to write out an interesting part of the matrix every time it joined two proteins. To make the images, start nip2, click File / Open. click on the first frame0001.csv, shift-click on the last, and click Open. This will make a large group of images and should be almost instant since it will only process the first few elements.
Each pixel will have a value in -1 to 1, no good for false colour which needs pixels in 0 to 255. Enter "255 * A1 ** 2" to square each pixel and multiply by 255. Now select Filter / Enhance / False Colour to turn the frames into RGB heat maps. You can see one of the frames by selecting Object / Group to List to make a plain list out of the group, and then selecting Math / List / Head to get the first element (alternatively, enter "A3.value?0" as I did here).
Right-click on the group of RGB images and select Save. Enter "frame00001.png" for the filename and click OK. This will take a minute or so, since nip2 will actually have to process all the images.
You can use ImageMagick to make a GIF of the clustering like this:
$ convert -delay 20 -loop 1 frame*.png cluster.gif
Or mencoder to make an mpeg4 like this:
$ mencoder "mf://frame*.png" -mf fps=10 -o cluster.avi -ovc lavc -lavcopts vcodec=mpeg4

No comments:
Post a Comment