The R tidyverse

Most regular R users will have felt the influence of Hadley Wickham, whether through the widely-used ggplot2 package that implements the “grammar of graphics”, devtools, plyr, … the list goes on. I was astounded when I first realized that the same person was responsible for all these really useful things.

Most software packages aim at providing tools to make particular tasks easier in a certain language. In comparison, many of the tools that he has developed are in effect streamlining the grammar of the language itself. Once you use ggplot2 and see how intuitive it is to deal with statistical graphics in that way, then the base R plot commands feel impossibly clunky. Similarly, his paper on tidy data and the accompanying tidyr and plyr packages articulate basic ideas about data should be organized in tables. These are ideas that sound very simple, and most of us have probably had some similar thoughts cross our minds as we struggled to reshape raw data into analyzable form, but I certainly would not have been able to formulate the concepts so clearly or implement solutions to change our relationship to data wrangling.

The various packages have seemed to evolve towards a common style and design philosophy, and late last year most of them have been bundled together in a ‘super-package’ called tidyverse. It makes installation much easier, because now you can make sure all these inter-dependent packages are up-to-date with a single command, and probably makes development easier for him and his team. It also goes together with a book titled R for Data Science that he and a coauthor have just released, which is also available online. Noted here for future reference!

3D vision with the Pulfrich Effect

The Pulfrich Effect is an optical phenomenon where objects (or images) moving in a single plane can appear to be in 3D when the light reaching one eye is dimmed, e.g. with a filter. It also has a curious history – Carl Pulfrich (biography – pdf), who discovered the phenomenon, was blind in one eye and never observed it for himself, but nonetheless made many contributions to stereoscopy (the study of 3D vision) in both theory and the construction of apparatus.

Unlike other forms of stereoscopy, this only works with moving objects or animations; it does not work with still images! But what’s really cool is that you don’t need any special equipment to view it, beyond a piece of darkened glass or plastic to act as a filter. Videos exhibiting the Pulfrich effect can be viewed on a normal monitor or TV screen.

I’ve made my own Javascript animations as demos for the Pulfrich effect (posted as GitHub Gists and rendered by

Screen Shot 2017-01-10 at 00.57.42.png

Screenshot from my animated explanation of the Pulfrich Effect

Continue reading

Visualize metagenomes in a web browser

In my day job I work with metagenomes from animals and protists that have bacterial symbionts, and I’ve blogged here before about why visualizations are so useful to metagenomics (mostly to flog my own R package). However most existing tools, including my own, require that you install additional software and all the libraries that come with them, and also be familiar with the command line. That’s pretty standard these days for anyone who wants to do serious work with such data, but it can be a big hurdle for teaching. Time in the classroom is limited, and ideally we want to spend more time teaching biology than debugging package installation in R.

I’ve therefore written up a simple browser-based visualization for rendering coverage-GC% plots, called gbtlite. There’s no need to mess around with data structures in R, or worrying about how to install required packages for your operating system. The visualization uses the D3.js Javascript library, which is popular for web applications. If you’ve played with infographics on the New York Times website, then you’ve probably seen something built with D3.

Continue reading

Hosting a website with GitHub Pages

My website is a labor of love for me – it is a work of family history and biography that I researched and started to write up in 2007, but only some months ago did I publish it online as a website.


Web-publishing is the poor(er) man’s self-publishing, but it does offer some advantages over paper. I can easily update the site with new features, such as photographs and transcriptions of original documents, and also incorporate interactive features like maps and timelines. It’s perfect for a serial procrastinator like me, because I can make something that is mostly done but not yet perfect available as a working version. For example, I’m still working on text boxes to explain the historical background for something mentioned in the main text of the biography – many of them are already up, but for some I have only an outline of what I would like to write.

In this blog post I’ll explain what free tools (“free” in the sense of not paying money for it, not the “free” in Free Software Foundation) I’ve used to build and host the website. I want to show how a hobbyist with modest web skills, like me, can still get things online quickly and painlessly.

Continue reading

Blast from the past – C-Dogs

When I was a kid back in the late 90s and early 00s I spent a LOT of time on these computer games: SimCity 2000, TetraBlocks (a Tetris clone), and C-Dogs.

C-Dogs was something special – a freeware MS-DOS-based game where blocky cartoon figures ran around a 2D map shooting things up. That sounds pretty primitive, but there were some great things about it: the graphics/artwork were awesome classics of the pixel-art genre, you could customize your characters and build custom maps, and the EXPLOSIONS. The best way to combine all that was great about this game was to build a custom map with lots of barrels of explosives lying around, throw in some grenades, and watch the whole map blow up. Very satisfying.

Screen Shot 2016-11-24 at 23.28.27.png

Exploding fuel barrel

Continue reading

Dropbox no longer serving websites

Update 17 Nov 2016: I’ve now migrated to a GitHub-hosted repository. More details on how I set it up in my next post!

It was fun while it lasted. My project website was doing something odd when I visited it last week to look something up: instead of rendering the index.html page like it did before, the browser started to download it.

Turns out that Dropbox has stopped supporting this feature. My site is/was simply a shared public link in my Dropbox Public folder, to which I pointed a custom domain name. Previously it was possible to host small websites this way, and they would serve up the HTML properly rendered. However this was ended for Basic accounts last month, and will also end for Pro accounts next year.

So what next? I was planning on migrating to Github Pages anyway, because I wanted to have better tracking of versions and edits. That is planned for my next free weekend, so watch this space! If for any reason you urgently want to read about Seah Eu Chin, just drop me a message by leaving a comment here or emailing me.

New gbtools release (v2.5.2)

Instead of working I’m procrastinating by fixing bugs in my software. The new version of gbtools includes two new features that improve the plotting of taxonomic markers, and some fixes to long-standing bugs. You can now adjust how many taxa are colored and included in the plot legend (thereby avoiding cluttered plots with too many colors to interpret), and also highlight individual taxa.

Wondering what gbtools is? Read my previous blog post, or the paper published last December.