hansenlab / minfi

Devel repository for minfi
58 stars 68 forks source link

read.metharray with extended=TRUE is broken #109

Closed kasperdanielhansen closed 7 years ago

kasperdanielhansen commented 7 years ago

From Stewart Morris swmorris@exseed.ed.ac.uk

I'm getting an error from read.metharray.exp() and wonder if you can check this out please.

The script I'm running is as follows:

library(minfi)
targets <-read.metharray.sheet('idats', pattern="02032017_RW.csv$")
RGset <- read.metharray.exp(targets=targets, extended=TRUE, verbose=TRUE)

The error is:

...
[read.metharray] Reading201004900067_R05C02_Red.idat
[read.metharray] Reading201004900067_R06C02_Red.idat
[read.metharray] Read idat files in 57.392seconds
[read.metharray] Creating data matrices ...
done in42.3seconds
[read.metharray] Instantiating final object ...
Error: cannot subset by character when names are NULL
kasperdanielhansen commented 7 years ago

This was traced to using extended=TRUE in the call to read.matharray().

The issue is in RChannelSetExtended() where the call

new("RGChannelSetExtended", SummarizedExperiment(assays = assays,
       ...), annotation = annotation)

fails. This seems to be due to RGChannelSetExtended extending RGChannelSet and the call to new() using an unnamed argument which (according to documentation) means it is taken as an element of a superclass, see ?initialize. But in this case it is a superclass 2 steps removed, not 1 step and it it not clear how initialize() deals with this.

kasperdanielhansen commented 7 years ago

This was caused by a custom as() for coercion from RGChannelSetExtended to RGChannelSet. This failed when run on the output of new("RChannelSetExtended") because this output is invalid (!) because the elements the assay slot has not been names (currently @assays is empty, instead it was assumed it would be a list of matrices with 0x0 dimension.

To avoid getting stuck in the hell of initialize and superclasses, I modified as() to check for an object of 0x0 dimension and special casing this. This fixes the original problem. (note that currently for example DEseq has the same problem with invalid outputs of new().).

Fixed in minfi 1.23.2 and backported to 1.22.1 (release).