Affymetrix microarray file format parser (CEL/CDF) for Ruby.
Are you tired waiting for R/Bioconductor to download and install? Are you weary of R’s slowness and memory consumption? Do you want Ruby’s convenience? Try creating a biogem, and use bio-affy’s foreign function interface (FFI) strategy for linking against R’s C libraries.
This is a port of the Biolib-1.0 Affy parser, which in turn is an adaptation of Ben Bolstad’s Affyio library for R/Bioconductor.
You can query CDF files for feature names of probesets, the number of probesets and probe types, and the indices of probes on the array.
You can query CEL files for raw expression values of PM probes and MM probes.
This implementation allows processing one or more microarrays at a time. It is not necessary to load all microarrays in RAM.
To use the command line tool you do not need to know Ruby (note, the command line interface is not ready).
Requirements: to install this software you need an installation of R and Ruby 1.9, e.g on Debian
apt-get install r-base-core ruby1.9
Make sure Rlib is built as a shared library, e.g.
ls -l /usr/lib/R/lib /usr/lib64/R/lib -rw-r--r-- 1 root root 2957216 Oct 31 11:59 libR.so
After installing ruby 1.9, you can use rubygems
gem install bio-affy
Next run the tool with
bio-affy --help
This module was written with
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] Using rake (0.9.2.2) Using bundler (1.0.21) Using diff-lcs (1.1.3) Using ffi (1.0.11) Using git (1.2.5) Using jeweler (1.6.4) Using mkrf (0.2.3) Using rcov (0.9.11) Using rspec-core (2.7.1) Using rspec-expectations (2.7.0) Using rspec-mocks (2.7.0) Using rspec (2.7.0)
require 'bio-affy'
Start the R environment, so the embedded Affyio library can use R’s functions directly
Bio::Affy::Ext.BioLib_R_Init()
Open the mouse CDF file, and query it
@cdf = Bio::Affy::Ext.open_cdffile("MG_U74Av2.CDF") num_probesets = Bio::Affy::Ext.cdf_num_probesets(@cdf)
Open an Affymetrix mouse CEL microrray file (gzipped)
@cel = Bio::Affy::Ext.open_celfile("GSM103328.CEL.gz") num = Bio::Affy::Ext.cel_num_intensities(@cel)
We’ll query the CDF for probeset 1510 (feature name 98910_at)
probeset_index = Bio::Affy::Find.probeset_by_feature_name(@cdf,"98910_at") p probeset_index # == 1510 probeset_ptr = Bio::Affy::Ext.cdf_probeset_info(@cdf,1510) probeset = Bio::Affy::CDFProbeSet.new(probeset_ptr) p probeset[:isQC] # == 0 p probeset[:pm_num] # == 16 p probeset[:mm_num] # == 16 p probeset[:name].to_ptr.read_string p probeset.name # == "98910_at" intensity = Bio::Affy::Ext.cel_intensity(@cel,1510) # == 10850.8
get the first perfect match (PM) probe
probes_ptr = Bio::Affy::Ext.cdf_pmprobe_info(@cdf,1510,0) probe = Bio::Affy::CDFProbeInfo.new(probe_ptr)
using the probe we can calculate the PM index
pm_probe_index1 = probe.x + probe.y*cdf_cols + 1
Now, the interesting bit. We want the PM expression values of this probeset
(0..pm_num).each do | i | print Bio::Affy::Ext.cel_pm(@cel,@cdf,1510,i) end
prints the 16 values for the perfect match probes
120,768,1046,1220.3,345.3,171.3,138,171.3,189,343.3,605.3,1064.5,4429.3,854.3,2675,886.3
For more on the API see github.com/pjotrp/bioruby-affy/blob/master/spec/bio-affy_spec.rb
Copyright © 2011 Pjotr Prins <[email protected]>
See LICENSE.txt for further details.