Closed hpages closed 4 years ago
Hi Hervé, @hpages
Thanks for catching this. I did a revdepscheck
on the package changes and this was expected.
I've notified the maintainer https://github.com/alussana/AffiXcan/issues/1 that we are switching
to a 'matrix' type of subsetting for the ExperimentList
class in response to comments in this issue https://github.com/waldronlab/MultiAssayExperiment/issues/276
Marcel,
ExperimentList is a List derivative and should behave like a list-like object. This means that linear subsetting (x[i]
) should subset along the length of the object and satisfy reasonable expectations like "x[4:3]
must have length 2" and "x[[i]]
must be the same as x[i][[1]]
for any 1 <= i
<= length(x)
". Otherwise basic functionalities like bplapply()
(and many others) break on ExperimentList objects.
The 'matrix'-type subsetting as currently implemented for ExperimentList violates these expectations. Note that an x[i, j, k]
subsetting where i
controls the subsetting along the length and j, k
performs the matrix-like subsetting of the individual list elements would have been compatible with the Vectors/List contract. But that's not what you did.
I see that the suggested fix for the AffiXcan package is that they coerce their ExperimentList object to SimpleList to make it behave like a List derivative again. But why would they need to do that? I mean, ExperimentList objects are already List derivatives (is(x, "List")
is TRUE), but because they don't behave like List derivatives people must coerce them to SimpleList to make them behave like List derivatives again... !?
More generally speaking, there is a contract associated with each class in the Vector hierarchy, and extending a class in that hierarchy implicitly means signing the contract and sticking to it. Overriding some methods with more specialized methods is OK as long as the more specialized methods respect the original contract.
If ExperimentList is no longer going to have a list-like semantic, then it should no longer extend List. Unfortunately this also means that it should probably be renamed to drop the "List" sufix (e.g. "Experiments") to avoid misleading the user.
Hope this makes sense.
H.
I had thought of ExperimentList as MultiAssayExperiment-like, but @hpages's rationale makes sense. We should discuss what to do - if we revert ExperimentList's matrix-like subsetting I would want to keep those actions available as verbs.
Thanks Hervé, @hpages
This makes sense to me. I've reverted the changes and kept the subsetBy*
functions.
I can also direct users to use the MultiAssayExperiment
interface for these type of operations.
cc: @lwaldron
-Marcel
Hi Marcel,
The specific commit that breaks it is commit 01363dce4f218337a9e383cf9e9ad56f92da2845.
With a serialized ExperimentList object from the AffiXcan package:
Extracting the first two elements should return an object of length 2 but it returns an object of length 4:
Any other attempt at using 1D-style (a.k.a. linear) subsetting returns an object of the same length as the original object:
Except when I don't select any element (empty selection):
Note that this last warning is spurious and confusing since subsetting by
integer(0)
is semantically equivalent to subsetting by0
.The new behavior of
[
on ExperimentList objects breaksutils::relist()
:and consequently
BiocParallalel:::.splitX()
andBiocParallalel::bplapply()
whereutils::relist()
is used internally to break the object into the pieces that get passed to the workers:This ultimately breaks the
affiXcanTrain()
function in the AffiXcan package and the vignette where it's used: https://bioconductor.org/checkResults/3.12/bioc-LATEST/AffiXcan/... plus possibly other packages (don't know, didn't go thru today's full report yet, only stumbled on this while going thru the letter A)
sessionInfo()