Check out the Bioconductor case studies book (By Florian Hahne, Wolfgang Huber, Robert Gentleman, Seth Falcon). There's a whole chapter about this. The code is also available online. It will save you lots of time...