updateObject is a generic function that returns an instance of object updated to its current class definition.

# S4 method for bcbioSingleCell



Object to be updated for updateObject and updateObjectFromSlots.

Object for slot information to be extracted from for getObjectSlots.


updateObject returns a valid instance of object.

updateObjectFromSlots returns an instance of class objclass.

getObjectSlots returns a list of named elements, with each element corresponding to a slot in object.


Updating objects is primarily useful when an object has been serialized (e.g., stored to disk) for some time (e.g., months), and the class definition has in the mean time changed. Because of the changed class definition, the serialized instance is no longer valid.

updateObject requires that the class of the returned object be the same as the class of the argument object, and that the object is valid (see validObject). By default, updateObject has the following behaviors:

updateObject(ANY, ..., verbose=FALSE)

By default, updateObject uses heuristic methods to determine whether the object should be the `new' S4 type (introduced in R 2.4.0), but is not. If the heuristics indicate an update is required, the updateObjectFromSlots function tries to update the object. The default method returns the original S4 object or the successfully updated object, or issues an error if an update is required but not possible. The optional named argument verbose causes a message to be printed describing the action. Arguments ... are passed to updateObjectFromSlots.

updateObject(list, ..., verbose=FALSE)

Visit each element in list, applying updateObject(list[[elt]], ..., verbose=verbose).

updateObject(environment, ..., verbose=FALSE)

Visit each element in environment, applying updateObject(environment[[elt]], ..., verbose=verbose)

updateObject(formula, ..., verbose=FALSE)

Do nothing; the environment of the formula may be too general (e.g., R_GlobalEnv) to attempt an update.

updateObject(envRefClass, ..., verbose=FALSE)

Attempt to update objects from fields using a strategy like updateObjectFromSlots Method 1.

updateObjectFromSlots(object, objclass=class(object), ..., verbose=FALSE) is a utility function that identifies the intersection of slots defined in the object instance and objclass definition. Under Method 1, the corresponding elements in object are then updated (with updateObject(elt, ..., verbose=verbose)) and used as arguments to a call to new(class, ...), with ... replaced by slots from the original object. If this fails, then Method 2 tries new(class) and assigns slots of object to the newly created instance.

getObjectSlots(object) extracts the slot names and contents from object. This is useful when object was created by a class definition that is no longer current, and hence the contents of object cannot be determined by accessing known slots.


Updated 2019-08-12.

See also

  • updateObjectTo in the Biobase package for updating an object to the class definition of a template (might be useful for updating a virtual superclass).

  • validObject for testing the validity of an object.

  • showMethods for displaying a summary of the methods defined for a given generic function.

  • selectMethod for getting the definition of a specific method.

  • BiocGenerics for a summary of all the generics defined in the BiocGenerics package.


data(bcb) updateObject(bcb)
#> Upgrading bcbioSingleCell from version 0.3.19 to 0.4.5.
#> bcbioSingleCell 0.4.5 #> uploadDir: /data00/draco/acidbase/packages/bcbioSingleCell/inst/extdata/indrops #> dates(2): [bcbio] 2018-01-01; [R] 2019-08-12 #> level: genes #> sampleMetadataFile: inst/extdata/indrops/metadata.csv #> organism: Homo sapiens #> interestingGroups: sampleName #> filtered: FALSE #> class: SingleCellExperiment #> dim: 50 100 #> metadata(28): allSamples bcbioCommandsLog ... yaml originalVersion #> assays(1): counts #> rownames(50): ENSG00000071082 ENSG00000100316 ... ENSG00000269028 #> ENSG00000282105 #> rowData names(8): broadClass description ... geneName seqCoordSystem #> colnames(100): AAACACTA_CTTCGATT AAACTACA_CCACATTA ... #> TGGGAATT_ATATAGGA TGTTATCA_ACGCAGAG #> colData names(15): aggregate description ... sampleName sequence #> reducedDimNames(0): #> spikeNames(0):
## Example that depends on remote file. ## > x <- import( ## > file = file.path( ## > bcbioSingleCellTestsURL, ## > "bcbioSingleCell_0.1.0.rds" ## > ) ## > ) ## > x <- updateObject(x) ## > x