R has a JSON package
Named rjson, appropriately. It’s quite basic just now, but contains methods for interconversion between R objects and JSON. Something like this:
> library(rjson)
> data <- list(a=1,b=2,c=3)
> json <- toJSON(data)
> json
[1] "{\"a\":1,\"b\":2,\"c\":3}"
> cat(json, file="data.json")
Use cases? I wonder if RApache could be used to build an API that serves R data in JSON format?
Brief notes on Ubuntu 9.04 (jaunty) -> 9.10 (karmic)
Recording my Ubuntu upgrade experience has become something of a tradition, so here goes.
- Machine 1 (laptop, LG T1 Express Duo). Largely trouble-free. On-board soundcard not seen on reboot. Fixed (temporarily, lost on reboot) using “sudo alsa force-reload”.
- Machine 2 (various generic hardware, cobbled together over many years). Upgrade smooth until final restart, when machine froze. Rebooted to a blank screen. Fixed by swapping out ATI video card for old NVidia FX5200. Discovered that rsyslog is running riot due to a hot CPU and is trying to fill up /var/log.
- Machine 3 (Dell Optiplex GX550). Install froze at “stopping winbind server”. Rebooted with rescue CD, mounted and chroot-ed into Linux partition, tried “dpkg –force-all –configure -a”, but to no avail. Reinstalled in same partition, all is working well.
All in all, not very impressed. Canonical, could do better.
Fix Kile for Ubuntu 9.04
Ubuntu/jaunty rocks, on the whole. However, to prove that newer does not always equal better, they threw in a couple of shockers. The first is the upgrade from the excellent Amarok 1.4 to the completely-broken 2.0. Head here to repair the damage.
Kile is by far my favourite LaTeX editor and suffered, though not as badly, in the upgrade from 2.0 to 2.1. Reports of various problems litter the web; in my case I see broken toolbar buttons that do nothing when clicked. This fix is much simpler. Just “sudo apt-get remove kile”, scroll to the bottom of the intrepid package page, choose your architecture, download the deb file and “sudo dpkg -i kile_2.0.1-1ubuntu1_i386.deb”. I had no dependency problems and it works just fine.
Finally – open up Synaptic, find kile and from the Package menu item select “lock package”, to prevent future upgrades.
Update: a few days after writing this, an apt-get dist-upgrade upgraded my Kile to 2.1 (despite the “lock package”). However, the broken buttons issue is now fixed for me. Go figure…
FriendFeed Life Scientists: 14-day summary
Since I haven’t posted for 14 days, what better (and lazier) way to post something than to surf over to a 14-day summary from the Life Scientists Group and link to the top ten items!
- Review process files in the EMBO Journal – but why only for “the majority of papers”?
- How XML threatens Big Data. Or not. How JSON might be an alternative – or not.
- Solve any computer problem – with this classic XKCD flowchart.
- Science reviews the revolution in ’strategic scientific reading’ – are they way behind the curve, or providing a useful summary for the uninitiated?
- Best practice in microbial genome annotation – spirited discussion on the nature of best bioinformatics practice.
- FriendFeed Life Scientists user survey – no further word on whether this will happen.
- 50 Years of Structure – link to a JMB review on the early days of structural biology.
- Reflections on Science Online London 2009
- Workflow tools that speak SOAP?
- Advice on cleaning up a protein sample – a nice example of useful discussion from the group.
Who knows, this could become a semi-regular feature.
Improvements to the reference management workflow
I use Google Reader to subscribe to the RSS feeds from journals that interest me (see my public page). I’m also a big fan of CiteULike as a reference management system.
For a long time I’ve thought: it would be great if GReader handled journal articles more efficiently. Rather than going from link in GReader -> article at journal -> CiteULike bookmark -> back to GReader, how about “post directly from GReader?”
With Google Reader’s new send-to feature, you can do just that. See this forum post for the details. Also, take a look at this how-to for a quick way to post to CiteULike by entering a PubMed PMID, DOI or ISBN identifier in the address bar.
RSRuby in the IRB console

R is terrific, of course, for all your statistical needs. But those data structures! “Everything is a list.” Leading to such wondrous ways to access variables as “p <- Meta(gds)$platform", or "last <- mylist[[1]][length(mylist[[1]])]".
Sometimes, you want something more familiar. An array, a hash, a hash of arrays. Or, you may need to access R data in the language of your choice – e.g. as part of a Rails project.
In Ruby, IRB is your friend. On the right, an IRB session in which we invoke RSRuby, load the GEOquery library from Bioconductor, fetch a dataset from the GEO database and examine the metadata that describes the experiment. Result: a ruby hash of arrays, where the keys are covariate types (“sample, disease.state, description”) and the values covariate names for each column (sample) in the dataset. Now easy to access using:
columns.each_pair do |key,val|
# do something with keys
val.each do |element|
# do something with values
end
end
How-to: combinations of covariates using Ruby
I work with people who generate a lot of microarray data. One question that they often ask is: can we find those genes with a two-fold or more change in median expression under two or more different conditions?
For example, let’s say that we have 3 conditions: “normal”, “adenoma” and “cancer”. That gives us 3 pairwise comparisons: normal-adenoma, normal-cancer and adenoma-cancer. Here’s a Ruby solution to the problem.
Read the rest…
RSRuby and Rails revisited
A couple of months ago, I wrote a brief guide to displaying R plots in a Rails application using RSRuby.
It worked at the time – really it did – but since then, I’ve encountered problems. One is that despite sending the plot output to a PNG file, R X11 windows started to pop up on loading the web page containing the plot. Another is the appearance of long error messages related to “stack smashing” on terminating Mongrel server.
Fortunately, I read an excellent guide by Ana Nelson, R on Rails with RSRuby, which convinced me that I was doing things all wrong. So here is an amended version of my R + RSRuby + Rails “Hello World” application.
Read the rest…






