All of cytomappers functions support images stored as DelayedArray by simply calling as.array before e.g. visualization or quantification. In the past I have also used terra::aggregate to merge pixels/decrease resolution of images before converting them into an Image object for visualization.
Extending an existing class means inheriting its internal representation. This does not work for the DelayedArray and array classes because they use completely different internal representations of the array data: the former uses an on-disk representation while the latter uses an in-memory representation.
Assuming DelayedArray objects are typically too big to fit in memory (otherwise one would just turn the object into an ordinary array with as.array() before calling display() on it), one way to make display() work on these objects is to implement a downsampling function. This is a function that would: (a) take a DelayedArray, (b) load a downsampled version of its data into memory, and (c) return that in an ordinary array. Such function would typically use a block-processing approach. Once such function is available, one could do:
a <- downsample(dataset[[1]])
display(a)
Note that, for additional convenience, the display() function could be turned into a generic. This would allow to define a method for DelayedArray objects that does something like callGeneric(downsample(x)).
These changes would need to happen in the EBImage package.
Thanks, Hervé.
Are you suggesting to make display a generic in BiocGenerics, and that EBImage defines method(s) for it, for regular array and Image objects, and that DelayedArray defines a method for its class(es)?
Happy to support / coordinate such changes.
and displayRaster is one of the two methods implementing EBImage::display (the other one opens an interactive browser widget). I wonder whether a (better) alternative would be to use plot as the generic function, for DelayedArray as well as for regular array and Image objects... to unclutter terminology and not have needlessly ideosyncratic function names?
All of
cytomapper
s functions support images stored asDelayedArray
by simply callingas.array
before e.g. visualization or quantification. In the past I have also usedterra::aggregate
to merge pixels/decrease resolution of images before converting them into anImage
object for visualization.