[BioC] Subsetting limma TestResults

Gordon K Smyth smyth at wehi.EDU.AU
Fri Jun 9 15:00:25 CEST 2006


> Date: Thu, 8 Jun 2006 14:47:09 +0200
> From: Michael Strehle <mstrehle at mdc-berlin.de>
> Subject: [BioC] Subsetting limma TestResults
> To: bioconductor at stat.math.ethz.ch
>
> Dear all,
>
> I recently encountered a problem subsetting limma TestResults on a
> new Bioconductor install. If I do
>
>  > results<-decideTests(fit3,adjust="holm")
>  > results[results<0]
>
> to extract differentially expressed genes from a MOE4302 fit I will
> get a matrix with results and Affy ID
>
>  > results[results<0]
>    1427262_at   1427263_at 1436717_x_at ...
>            -1           -1           -1 ...

Did limma ever work like this?  I don't think it did.  I think it's more likely that you've
actually done slightly different things in the two limma versions.  There are some subtleties in
the way that subsetting works in R, which I explain below.

> in R 2.1.1, limma 2.0.8 on OSX 10.4.6/PPC, but
>
>  > results[results<0]
>    [1] -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
>
> in R 2.3.0, limma 2.7.3 on OSX 10.4.6/PPC, that is, the results
> without Affy ID .

In limma, the output from decideTests() is an object of class "TestResults", and this is
matrix-like. The method of subsetting you are using (dimensionless subsetting) coerces the result
to be an ordinary vector.  Hence any attributes such as rownames must be lost because vectors
don't have rows or columns.  This is how R works, and it has nothing particularly to do with
limma.

If you want to preserve rownames, you must treat the object as a matrix, i.e., you must treat it
as having two dimensions.  If 'results' has only one column, you could use

   results[results<0,]

If there are more columns, you would need

   results[results[,1]<0,1]

to get the first column subsetted.

Alternatively,

   results <- results[,1]
   results[results<0]

would also preserve rownames, because the results[,1] drops the matrix down to a vector with the
former rownames becoming ordinary names.

Best wishes
Gordon

> Same if I use subset(results, results<0). Since I really would like
> to retain the Affy IDs in the subset for further annotation - am I
> missing something here, and is there a way to make this work again ?
>
>
> Thanks,
>
> Michael



More information about the Bioconductor mailing list