I have defined a class `CoMeth` that is basically a `SummarizedExperiment`. However, one difference is that I store some important information in the metadata columns of the rowData, i.e. in `mcols(rowData(x))`, where `x` is a CoMeth object. I don't want the user to accidentally overwrite/remove this information if they update the `mcols` so I defined the following replacement method:

```
setReplaceMethod("mcols", signature = "CoMeth", function(x, ..., value){
  if (any(grepl(pattern = "^pos", colnames(value)))){ # The columns I don't want overwritten/removed all begin with "pos"
    stop("Column names of user-specified 'mcols' must not begin with 'pos'")
  }
  
  GenomicRanges:::clone(x, rowData = local({
    r <- rowData(x)
    mcols(r) <- cbind(mcols(rowData(x)), value) # The new mcols are added to the existing mcols.
    r
  }))
})
```

This method is based on the `mcols<-` method defined for the `SummarizedExperiment` class and relies on the non-exported `clone` function from the GenomicRanges package 

So my questions are:
1. Is it okay to rely on `clone`?
2. If not, can someone suggest an alternative way to achieve the same idea?
3. Is this the correct way to call `clone` in my package (which already depends on the GenomicRanges package)?

Thanks,
Pete


--------------------------------
Peter Hickey,
PhD Student/Research Assistant,
Bioinformatics Division,
Walter and Eliza Hall Institute of Medical Research,
1G Royal Parade, Parkville, Vic 3052, Australia.
Ph: +613 9345 2324

hickey@wehi.edu.au
http://www.wehi.edu.au


______________________________________________________________________
The information in this email is confidential and intend...{{dropped:8}}

