updateObject 1.8.0
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 (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
.
updateObject()
is the core function used in Bioconductor for updating
old R objects. The function is an S4 generic currently defined in the
BiocGenerics package and with dozens of methods defined
across many Bioconductor packages. For example, the S4Vectors
package defines updateObject()
methods for Vector, SimpleList, DataFrame,
and Hits objects, the SummarizedExperiment package defines
methods for SummarizedExperiment, RangedSummarizedExperiment, and Assays
objects, the MultiAssayExperiment package defines a method
for MultiAssayExperiment objects, the QFeatures package a
method for QFeatures objects, etc…
See ?BiocGenerics::updateObject
in the BiocGenerics
package for more information.
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:
Identify all the files in the package that contain serialized R objects.
Serialized R objects are normally written to RDS or RDA files. These
files typically use file extensions .rds
(for RDS files), and .rda
or .RData
(for RDA files).
Load each serialized object into R. This is usually done by calling
readRDS()
on each RDS file, and load()
on each RDA file. Note that
unlike RDS files which can only contain a single object per file, RDA
files can contain an arbitrary number of objects per file.
Pass each object thru updateObject()
:
x <- updateObject(x)
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.
Write each object back to its original file. This is done with saveRDS()
or save()
, depending on whether the object came from an RDS or RDA file.
Note that this only needs to be done for objects that actually contained
out-of-sync parts i.e. for objects on which updateObject()
did not act
as a no-op.
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:
Bump the package version.
Set its Date
field (if present) to the current date.
Commit the changes.
Push the changes to git.bioconductor.org
.
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 updateObject package provides a set of tools that intend to make this much easier.
updateBiocPackageRepoObjects()
is the central function in the
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 updateObject:
library(updateObject)
and try updateBiocPackageRepoObjects()
on the RELEASE_3_13
branch
of the TimiRGeN package:
repopath <- file.path(tempdir(), "TimiRGeN")
updateBiocPackageRepoObjects(repopath, branch="RELEASE_3_13", use.https=TRUE)
## Cloning into '/tmp/RtmpQsj8fu/TimiRGeN'...
##
## RUNNING 'updatePackageObjects("/tmp/RtmpQsj8fu/TimiRGeN", bump.Version=TRUE)'...
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/Clusters.rds: readRDS().. ok; updateObject(MultiAssayExperiment, check=FALSE).. object updated; saving file.. OK ==> 1
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/corrmat.rds: readRDS().. ok; updateObject(data.frame, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/EnrichWiki.rds: readRDS().. ok; updateObject(list, check=FALSE).. object updated; saving file.. OK ==> 1
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/filt_df.rds: readRDS().. ok; updateObject(data.frame, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/filtered_genelist_c.rds: readRDS().. ok; updateObject(list, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/filtered_genelist_s.rds: readRDS().. ok; updateObject(list, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/gene_entrez_c.rds: readRDS().. ok; updateObject(list, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/genelist_s.rds: readRDS().. ok; updateObject(list, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/geneslist_c.rds: readRDS().. ok; updateObject(list, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/GenesofInterest.rds: readRDS().. ok; updateObject(data.frame, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/genetic_data.rds: readRDS().. ok; updateObject(data.frame, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/IDs_mouse_miR.rds: readRDS().. ok; updateObject(MultiAssayExperiment, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/IDs_mouse_mRNA.rds: readRDS().. ok; updateObject(MultiAssayExperiment, check=FALSE).. object updated; saving file.. OK ==> 1
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/interactions.rds: readRDS().. ok; updateObject(data.frame, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/log2fc.rds: readRDS().. ok; updateObject(MultiAssayExperiment, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/MAE_mm.rds: readRDS().. ok; updateObject(MultiAssayExperiment, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/MAE_Prefix.rds: readRDS().. ok; updateObject(MultiAssayExperiment, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/MiningMatrix.rds: readRDS().. ok; updateObject(data.frame, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/miRDB_resuts.rds: readRDS().. ok; updateObject(matrix, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/miRTarBase_results.rds: readRDS().. ok; updateObject(matrix, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/net.rds: readRDS().. ok; updateObject(MultiAssayExperiment, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/TargetScans_results.rds: readRDS().. ok; updateObject(matrix, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/wikimatrix.rds: readRDS().. ok; updateObject(data.frame, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/tests/testthat/wpdata.rds: readRDS().. ok; updateObject(MultiAssayExperiment, check=FALSE).. no-op ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/e_list_mouse.rda: load().. ok [1 object(s)]; updateObject(list, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/hs_miR.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/hs_mRNA.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/hs_probes.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/long_data.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/miRTarBase.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/mm_miR.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/mm_mRNA.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/UUO_data.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/data/w_list_mouse.rda: load().. ok [1 object(s)]; updateObject(list, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/inst/extdata/clusterdata.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/inst/extdata/clusters.rda: load().. ok [1 object(s)]; updateObject(fclust, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/inst/extdata/hs_gmt.rda: load().. ok [1 object(s)]; updateObject(MultiAssayExperiment, check=FALSE).. object updated; saving file.. OK ==> 1
## File /tmp/RtmpQsj8fu/TimiRGeN/inst/extdata/Int_data.rda: load().. ok [1 object(s)]; updateObject(data.frame, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/inst/extdata/mfuzzdata.rda: load().. ok [1 object(s)]; updateObject(matrix, check=FALSE).. no-op; nothing to update ==> 0
## File /tmp/RtmpQsj8fu/TimiRGeN/inst/extdata/mm_gmt.rda: load().. ok [1 object(s)]; updateObject(MultiAssayExperiment, check=FALSE).. object updated; saving file.. OK ==> 1
## File /tmp/RtmpQsj8fu/TimiRGeN/inst/extdata/w_list_human.rda: load().. ok [1 object(s)]; updateObject(list, check=FALSE).. no-op; nothing to update ==> 0
## diff --git a/DESCRIPTION b/DESCRIPTION
## index 6d23fae..0ad637d 100644
## --- a/DESCRIPTION
## +++ b/DESCRIPTION
## @@ -1,7 +1,7 @@
## Package: TimiRGeN
## Type: Package
## Title: Time sensitive microRNA-mRNA integration, analysis and network generation tool
## -Version: 1.2.0
## +Version: 1.2.1
## Authors@R: person(given = "Krutik", family = "Patel", role = c("aut", "cre"), email = "K.Patel5@newcastle.ac.uk")
## Description: TimiRGeN (Time Incorporated miR-mRNA Generation of Networks) is a novel R package which functionally analyses and integrates time course miRNA-mRNA differential expression data. This tool can generate small networks within R or export results into cytoscape or pathvisio for more detailed network construction and hypothesis generation.
## This tool is created for researchers that wish to dive deep into time series multi-omic datasets. TimiRGeN goes further than many other tools in terms of data reduction. Here, potentially hundreds of thousands of potential miRNA-mRNA interactions can be whittled down into a handful of high confidence miRNA-mRNA interactions effecting a signalling pathway, across a time course.
## diff --git a/inst/extdata/hs_gmt.rda b/inst/extdata/hs_gmt.rda
## index 2bad1b8..53cefc0 100644
## Binary files a/inst/extdata/hs_gmt.rda and b/inst/extdata/hs_gmt.rda differ
## diff --git a/inst/extdata/mm_gmt.rda b/inst/extdata/mm_gmt.rda
## index 653fb4c..8a692ad 100644
## Binary files a/inst/extdata/mm_gmt.rda and b/inst/extdata/mm_gmt.rda differ
## diff --git a/tests/testthat/Clusters.rds b/tests/testthat/Clusters.rds
## index 51c0113..8c5e0d8 100644
## Binary files a/tests/testthat/Clusters.rds and b/tests/testthat/Clusters.rds differ
## diff --git a/tests/testthat/EnrichWiki.rds b/tests/testthat/EnrichWiki.rds
## index c936d04..190dba1 100644
## Binary files a/tests/testthat/EnrichWiki.rds and b/tests/testthat/EnrichWiki.rds differ
## diff --git a/tests/testthat/IDs_mouse_mRNA.rds b/tests/testthat/IDs_mouse_mRNA.rds
## index 9c88659..d720b8c 100644
## Binary files a/tests/testthat/IDs_mouse_mRNA.rds and b/tests/testthat/IDs_mouse_mRNA.rds differ
##
## [RELEASE_3_13 5396688] Pass serialized S4 instances thru updateObject()
## 6 files changed, 1 insertion(+), 1 deletion(-)
## rewrite inst/extdata/hs_gmt.rda (96%)
## rewrite inst/extdata/mm_gmt.rda (99%)
## rewrite tests/testthat/Clusters.rds (100%)
## rewrite tests/testthat/EnrichWiki.rds (100%)
## rewrite tests/testthat/IDs_mouse_mRNA.rds (100%)
##
## UPDATE OBJECTS >> UPDATE DESCRIPTION FILE >> COMMIT SUCCESSFUL.
Important notes:
By default updateBiocPackageRepoObjects()
does not try to push the
changes to git.bioconductor.org
. Only the authorized maintainers of
the TimiRGeN package can do that. If you are using
updateBiocPackageRepoObjects()
on a package that you maintain and
you wish to push the changes to git.bioconductor.org
, then do NOT use
HTTPS access (i.e. don’t use use.https=TRUE
) and use push=TRUE
.
The RELEASE_3_13
branch of all Bioconductor packages got frozen in
October 2021. The above example is for illustrative purpose only.
A more realistic situation would be to use updateBiocPackageRepoObjects()
on the development version (i.e. the master
branch) of a package
that you maintain, and to push the changes by calling the function
with push=TRUE
:
updateBiocPackageRepoObjects(repopath, push=TRUE)
See ?updateBiocPackageRepoObjects
for more information and more
examples.
The package provides the following tools:
updateBiocPackageRepoObjects()
: See above.
updatePackageObjects()
: A simpler version of
updateBiocPackageRepoObjects()
that doesn’t know anything about
Git. That is, updatePackageObjects()
will do the same thing
as updateBiocPackageRepoObjects()
except that it won’t commit
or push the changes. This means that the function can be used on
any local package source tree, whether it’s a Git clone or not,
and whether it’s a Bioconductor package or not.
updateAllBiocPackageRepoObjects()
and updateAllPackageObjects()
:
Similar to updateBiocPackageRepoObjects()
and updatePackageObjects()
but for processing a set of Bioconductor package Git repositories (for
updateAllBiocPackageRepoObjects()
) and a set of packages (for
updateAllPackageObjects()
).
updateSerializedObjects()
: The workhorse behind the above functions.
See individual man pages in the package for more information e.g.
?updatePackageObjects
.
sessionInfo()
## R version 4.4.0 beta (2024-04-15 r86425)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.4 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: America/New_York
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] DOSE_3.30.0 MultiAssayExperiment_1.30.0
## [3] updateObject_1.8.0 S4Vectors_0.42.0
## [5] BiocGenerics_0.50.0 BiocStyle_2.32.0
##
## loaded via a namespace (and not attached):
## [1] tidyselect_1.2.1 dplyr_1.1.4
## [3] HDO.db_0.99.1 blob_1.2.4
## [5] Biostrings_2.72.0 fastmap_1.1.1
## [7] digest_0.6.35 lifecycle_1.0.4
## [9] KEGGREST_1.44.0 RSQLite_2.3.6
## [11] magrittr_2.0.3 compiler_4.4.0
## [13] rlang_1.1.3 sass_0.4.9
## [15] tools_4.4.0 utf8_1.2.4
## [17] yaml_2.3.8 data.table_1.15.4
## [19] knitr_1.46 S4Arrays_1.4.0
## [21] bit_4.0.5 DelayedArray_0.30.0
## [23] plyr_1.8.9 abind_1.4-5
## [25] BiocParallel_1.38.0 grid_4.4.0
## [27] fansi_1.0.6 GOSemSim_2.30.0
## [29] colorspace_2.1-0 GO.db_3.19.1
## [31] ggplot2_3.5.1 scales_1.3.0
## [33] SummarizedExperiment_1.34.0 cli_3.6.2
## [35] rmarkdown_2.26 crayon_1.5.2
## [37] generics_0.1.3 reshape2_1.4.4
## [39] httr_1.4.7 BiocBaseUtils_1.6.0
## [41] qvalue_2.36.0 DBI_1.2.2
## [43] cachem_1.0.8 stringr_1.5.1
## [45] splines_4.4.0 zlibbioc_1.50.0
## [47] parallel_4.4.0 AnnotationDbi_1.66.0
## [49] BiocManager_1.30.22 XVector_0.44.0
## [51] matrixStats_1.3.0 yulab.utils_0.1.4
## [53] vctrs_0.6.5 Matrix_1.7-0
## [55] jsonlite_1.8.8 bookdown_0.39
## [57] IRanges_2.38.0 bit64_4.0.5
## [59] jquerylib_0.1.4 glue_1.7.0
## [61] codetools_0.2-20 cowplot_1.1.3
## [63] stringi_1.8.3 gtable_0.3.5
## [65] GenomeInfoDb_1.40.0 GenomicRanges_1.56.0
## [67] UCSC.utils_1.0.0 munsell_0.5.1
## [69] tibble_3.2.1 pillar_1.9.0
## [71] htmltools_0.5.8.1 fgsea_1.30.0
## [73] GenomeInfoDbData_1.2.12 R6_2.5.1
## [75] evaluate_0.23 lattice_0.22-6
## [77] Biobase_2.64.0 png_0.1-8
## [79] memoise_2.0.1 bslib_0.7.0
## [81] Rcpp_1.0.12 fastmatch_1.1-4
## [83] SparseArray_1.4.0 xfun_0.43
## [85] fs_1.6.4 MatrixGenerics_1.16.0
## [87] pkgconfig_2.0.3