On 1/28/20 01:37, Laurent Gatto wrote: > Dear all, > > Assume we have a SummarizedExperiment object `se` that contains raw count > data, and a method `doProcess` that processes the data to produce a matrix of > identical dimensions (for example log-transformation, normalisation, > imputation, ...). What are the opinions in favour or against the following > two options > > - `doProcess(se)` returns a new SE object > - `doProcess(se)` adds a new assay to se
Aren't these are the same? SE objects are not reference objects i.e. they follow R standard copy-on-change semantic. This means that they never get modified **in place** (aka they're not "mutable"). So 'doProcess(se)' will always return a new object, whatever you do inside the function, that is, even if the function modifies 'se' internally e.g. with something like: assay(se, "new_assay") <- new_assay Note that the assay() setter itself like all setters also produces a new object. The parser actually replaces the following code assay(se, "new_assay") <- new_assay with se <- `assay<-`(se, "new_assay", value=new_assay) As you can see the previous `se` is replaced with the new one which gives the **illusion** of in-place replacement but it's not. Hope this helps, H. > > If you are interested about the broader context about this question, see > https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_waldronlab_MultiAssayExperiment_issues_266&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=Of3qgEC1ElS9Ji3Iu2vNk93_Fj3m50sTV2zT0dyAKvA&s=qimtz2YygmTlAiYZOWZJrwPMo6eMKy5E5Rew60452TQ&e= > > Thank you in advance for your input. > > Laurent > > > > > _______________________________________________ > Bioc-devel@r-project.org mailing list > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_bioc-2Ddevel&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=Of3qgEC1ElS9Ji3Iu2vNk93_Fj3m50sTV2zT0dyAKvA&s=_aXY7azhIr_1UPl2s3RvX1MJp_9Xcw_73w2KOYbqBVI&e= > -- Hervé Pagès 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: hpa...@fredhutch.org Phone: (206) 667-5791 Fax: (206) 667-1319 _______________________________________________ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel