Tuesday, January 13, 2009

Aggregate in R

For data that needs to be collapsed, the aggregate() function works great. For example:



If you need to collapse these so you only have one row per GLEAN, and have the Female and Male columns be the average of the collapsed rows, aggregate() can do this in one line:

collapsed_data<-aggregate(x=original_data, by=file_with_GLEAN_names_only, FUN=mean)

I used this to find the average expression levels of genes from a table that had the expression levels of each exon. Since some genes had one exon while others had many exons, aggregate was perfect for this situation. It did take a few minutes to compute, but I had over 57,000 rows and 8 columns, so that's understandable.

Virtualization with Virtual Box in Ubuntu

I copied some material from these links in doing this (there are one or two errors in them that I correct here):
http://www.ubuntu-unleashed.com/2008/04/howto-install-virtualbox-in-hardy-heron.html
http://www.linuxhaxor.net/2008/05/05/creating-seamless-virtual-machine-with-virtualbox-16/
  1. make sure you have the 'build-essential' package installed:
    sudo apt-get install build-essential
  2. Download your version of virtual box (probably i386 unless you have a 64 bit processor) and install it

    After download, right click the package and install with the GDeb package manager

  3. Add your user to the vboxusers group:
    sudo adduser $USER vboxusers

  4. Follow the Setup VirtualBox USB Support section here for USB support
    I did both of the things recommended. Note that the last step should read:
    sudo /etc/init.d/mountkernfs.sh start

  5. Install Guest Addons and turn on seamless mode
    after firing up the virtual OS, go to the 'Devices' window on the top and 'Install Guest Additions'
  6. Set up shared directories following this.

Wednesday, January 7, 2009

autotest with specs in a normal ruby library

Put this in a '.autotest' file in your project's base directory:

# -*- ruby -*-

# in .autotest file:

Autotest.add_hook :initialize do |at|
at.clear_mappings
end

Autotest.add_hook :initialize do |at|
at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
["spec/#{m[1]}_spec.rb"]
## for both specs and tests:
#["spec/#{m[1]}_spec.rb","test/#{m[1]}_test.rb"]
}
end