Skip to content
Prev 13665 / 21312 Next

[Bioc-devel] How best to remap S4Vectors::Hits indices?

Hi Pariksheet,
On 05/22/2018 04:57 PM, Pariksheet Nanda wrote:
Exactly. And that is the case for any object in R that is not a
reference object (i.e. that is not an environment, external pointer,
or reference class instance). Modifying it always generates a new
object. For example replacing a column of a data frame with
my_df$foo <- value or a slot of an S4 object with my_object at foo <- value
generates a new object. So adding setter methods for Hits objects
wouldn't change that.

The only reason we don't provide from()/queryHits() or
to()/subjectHits() setters is because we've not been able to identify
use cases that justify having them so far. For those use cases where
the 'from' and 'to' slots both need to be modified (in an atomic way),
calling the Hits() constructor to generate a new object does the job.
No need to cast the object to a data.frame. That would indeed be
wasteful. Just compute the new 'from' and 'to' vectors then do
'Hits(from, to, nLnode=nLnode(hits), nRnode=nRnode(hits))'
to create the modified object ('hits' being the original object).

Hope this helps,
H.