[Bioc-devel] Help with class lost after subsetting.
hp@ge@ @ending from fredhutch@org
Tue Aug 28 20:46:50 CEST 2018
On 08/27/2018 11:01 PM, Martin Morgan wrote:
> On 08/28/2018 12:19 AM, Charles Plessy wrote:
>> Dear Bioconductor developers,
>> In the CAGEr package, I created a "CAGEexp" class that extends
>> "MultiAssayExperiment" without adding new slots, in order to define
>> functions that require CAGEr-specific contents in the colData slot.
>> Unfortunately, when run in the development branch of Bioconductor,
>> the CAGEexp objects lose their class when they are subsetted. Here
>> is an example:
>> A CAGEexp object of 4 listed
>> A MultiAssayExperiment object of 4 listed
>> This breaks examples in the package, as well as existing code.
>> I am lost on how to troubleshoot this. May I ask for your help ?
> I debugged this using first `selectMethod("[", "MultiAssayExperiment")`
> and then `showMethod()` / `selectMethod()` to arrive at
> The problem is that this line
> returns a MultiAssayExperiment; what it should do is probably closer to
> the 'copy constructor' functionality of `initialize()`, along the lines of
> initialize(x, ExperimentList = ..., )
> This could be opened as an issue on the MultiAssayExperiment github
> repository; maybe Herve or Michael or others might comment on the best
Yep. Personally I tend to prefer BiocGenerics:::replaceSlots()
over initialize() because the former can be called with check=FALSE
in order to skip a possibly expensive validation. So:
ExperimentList = harmon[["experiments"]],
colData = harmon[["colData"]],
sampleMap = harmon[["sampleMap"]],
metadata = metadata(x),
check = FALSE)
If you know that the replacement values are valid (because of the way
you prepared them), then validation should not be needed.
Also when only **some** of the slots are updated (which is not the
case in the above example where all the slots are being replaced),
I find that the use of initialize() is misleading from a readability
point of view.
for a discussion about this about 1 year ago.
>> Best regards,
> Bioc-devel using r-project.org mailing list
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024
E-mail: hpages using fredhutch.org
Phone: (206) 667-5791
Fax: (206) 667-1319
More information about the Bioc-devel