Introduction

r Biocpkg("updateObject") is an R package that provides a set of tools built around the updateObject() generic function to make it easy to work with old serialized S4 instances.

The package is primarily useful to package maintainers who want to update the serialized S4 instances included in their package.

Out-of-sync objects

Out-of-sync objects (a.k.a. outdated or old objects) are R objects that got serialized at some point and became out-of-sync later on when the authors/maintainers of an S4 class made some changes to the internals of the class.

A typical example of this situation is when some slots of an S4 class A get added, removed, or renamed. When this happens, any object of class A (a.k.a. A instance) that got serialized before this change (i.e. written to disk with saveRDS(), save(), or serialize()) becomes out-of-sync with the new class definition.

Note that this is also the case of any A derivative (i.e. any object that belongs to a class that extends A), as well as any object that contains an A instance or derivative. For example, if B extends A, then any serialized list of A or B objects is now an old object, and any S4 object of class C that has A or B objects in some of its slots now is also an old object.

An important thing to keep in mind is that, in fact, the exact parts of a serialized object x that are out-of-sync with their class definition can be deeply nested inside x.

The updateObject() generic function

updateObject() is the core function used in Bioconductor for updating old R objects. The function is an S4 generic currently defined in the r Biocpkg("BiocGenerics") package and with dozens of methods defined across many Bioconductor packages. For example, the r Biocpkg("S4Vectors") package defines updateObject() methods for Vector, SimpleList, DataFrame, and Hits objects, the r Biocpkg("SummarizedExperiment") package defines methods for SummarizedExperiment, RangedSummarizedExperiment, and Assays objects, the r Biocpkg("MultiAssayExperiment") package defines a method for MultiAssayExperiment objects, the r Biocpkg("QFeatures") package a method for QFeatures objects, etc...

See ?BiocGenerics::updateObject in the r Biocpkg("BiocGenerics") package for more information.

A tedious process

Serialized objects are typically (but not exclusively) found in R packages. To update all the serialized objects contained in a given package, one usually needs to perform the following steps:

Note that if x doesn't contain any out-of-sync parts then updateObject() will act as a no-op, that is, it will return an object that is strictly identical to the original object.

In addition to the above steps, the package maintainer also needs to perform the usual steps required for updating a package and publishing its new version. In the case of a Bioconductor package, these steps are:

Performing all the above steps manually can be tedious and error prone, especially if the package contains many serialized objects, or if the entire procedure needs to be performed on a big collection of packages. The r Biocpkg("updateObject") package provides a set of tools that intend to make this much easier.

updateBiocPackageRepoObjects()

updateBiocPackageRepoObjects() is the central function in the r Biocpkg("updateObject") package. It takes care of updating the serialized objects contained in a given Bioconductor package by performing all the steps described in the previous section.

Let's load r Biocpkg("updateObject"):

library(updateObject)
## Set fake git user to make git_commit() happy:
set_git_user_name("titi")
set_git_user_email("titi@gmail.com")

and try updateBiocPackageRepoObjects() on the RELEASE_3_13 branch of the r Biocpkg("TimiRGeN") package:

repopath <- file.path(tempdir(), "TimiRGeN")
updateBiocPackageRepoObjects(repopath, branch="RELEASE_3_13", use.https=TRUE)

Important notes:

See ?updateBiocPackageRepoObjects for more information and more examples.

List of tools provided by the updateObject package

The package provides the following tools:

See individual man pages in the package for more information e.g. ?updatePackageObjects.

Session information

sessionInfo()


Bioconductor/updateObject documentation built on May 1, 2024, 9:29 p.m.