[BioC] Reading Imagene files with read.imagene in limma

STKH (Steen Krogsgaard) stkh at novozymes.com
Tue Jun 8 10:04:31 CEST 2004

Hi Gordon,

I really don't want to reinvent the wheel (or any other part of the
excellent functionality of limma). What I want to do is to save the flag
columns from the data files in the RGList dataframe as RGList$flags and
then set the weights to either 0 or 1 depending on the values of the
flags. Since the flags say that the spot is either OK or unusable (with
nothing in between) it doesn't really make sense (to me at least) to use
weights between 0 and 1. 

I couldn't figure out how to add the flags "column" to the RGList within
the wt.fun function, so that's why I wrapped read.imagene instead. The
pseudocode is like this:
read.my.imagene=function(bla bla bla, exclude.flags=c(1,2,3))
	obj=read.imagene(bla bla bla, wt.fun=wt.myimagene)
	obj$weigths[obj$flags %in% exclude.flags]=0


so, during read.imagene the Flags column from the datafiles are put in
the weigths list (it's a list, right?), and this is subsequently copied
to a $flags list. Then $weights are set to all 1's, and the $weights
where $flags is in an exclude-list (exclude.flags) is set to 0. This
mimicks the data preparation step used in GeneSight from BioDiscovery
where "bad" flags are filterede out. The reason for not putting the
filtering into wt.myimagene is that I want to let the user specify which
flags to exclude. To exclude only flags 1 and 2, for instance, the call
would be 
RG=read.my.imagene(files=files, exclude.flags=c(1,2))

This is probably not the best way to accomplish this, but it's the one I
could think up! I can see that for instance wtarea is defined by two
function-statements and that this allow for a parameter to be specified
in the call to read.imagene, but I don't really understand this
notation. Besides, I still would like to have the original flag values
stored in the RGList object so that I can re-do the filtering later or
plot the flagges spots or whatever.

Thanks for all the feedback

-----Original Message-----
From: Gordon Smyth [mailto:smyth at wehi.edu.au] 
Sent: 8. juni 2004 00:38
To: STKH (Steen Krogsgaard)
Cc: bioconductor at stat.math.ethz.ch
Subject: Re: [BioC] Reading Imagene files with read.imagene in limma

At 08:14 PM 7/06/2004, STKH (Steen Krogsgaard) wrote:
>I have a bunch of Imagene data files that I want to read into limma 
>using read.imagene. It all works very nicely like this:
>RG<-read.imagene(files), where files is a matrix with two columns and 
>one row for each array. The names of the two dye-files are in the two 
>I want to wrap this call into another function in order to do some 
>processing of the quality flags that Imagene uses (I want to change the

>flags into weights). The idea is:

Why re-invent the wheel? read.maimages() already gives you complete 
facility to do this. The argument wt.fun given to read.maimages() can be

any function you like which takes an imagene file as a data frame and 
converts flags into weights. The help says:

'wt.fun' may be any user-supplied function which accepts
      a data.frame argument and returns a vector of non-negative
      weights. The columns of the data.frame are as in the image
      analysis output files. See 'QualityWeights' for provided weight


>read.my.imagene <-function(files, path = NULL, ext = NULL, names = 
>NULL, columns = NULL,
>     wt.fun = NULL, verbose = TRUE, sep = "      ", quote = "\"",
>exclude.flags=c(1,2,3), ...)
>         obj=read.imagene(files=files, path=path, ext=ext, names=names,

>columns=columns, wt.fun=wt.fun, verbose=verbose, sep=sep, quote=quote,
>         // do some more stuff
>but when I call read.my.imagene I get an error "Error in scan(file = 
>file, what = what, sep = sep, quote = quote, dec = dec,  :
>         line 1 did not have 27 elements". I understand that scan is 
>complaining about the number of columns in the data file, but I'm 
>really puzzled why it works when I call read.imagene directly but not 
>when I call read.my.imagene which then in turn calls read.imagene.
>I also tried to copy the source code for read.imagene into a new 
>function (which I called test.read), and this produced the exact same 
>error. There were no code changes done, just a copy of the source code 
>into Notepad (yes, I'm on a Windows box) preceeded by "test.read = ".
>I use R 1.9.0 and the latest Bioconductor (downloaded last week).
>thanks in advance for any suggestions

More information about the Bioconductor mailing list