Drawing sequence logos

A very simple script to do a simple but tedious task.

Sequence logos are a common way of representing SNPs and diversity in groups of sequences. This script automates the task. It's a bit rough around the edges and serves mainly as a base for further hacking.

Usage is:

drawlogo.rb [options] FILE1 [FILE2 ...]

where options are:

-h, --help Display this screen
--columns INT How many sites to draw in every row
--relative-cell-height FLOAT
 How high to make a site relative to its width
--palette STR Which palette to use
--add-to-palette STR
 Add these colors to the palette
--format STR Save output in this format
--save STR Name output files according this template
-o, --overwrite
 Overwrite pre-existing files

The input is a CSV file with one row for each different residue at each site, of the form:

<site index>, <residue>, <proportion>

The output is an image file, by default a PNG, although any format supported by RMagick is possible. Caveat: SVG output is pathological, due to Rmagick's poor support of the format.

Requirements

  • Ruby v1.8.x. 1.9.x will work but require a simple change in the CSV reading code, thanks to Ruby changing the way the CSV standard library works. (Thanks guys!)
  • The RMagick library.

Files

  • {attach}