library(BiocStyle) knitr::opts_chunk$set(error=FALSE, message=FALSE, warning=FALSE)
SingleCellExperiment
For some reason, I saved the alternative experiment as a SummarizedExperiment
instead of a SingleCellExperiment
.
I was probably hoping to eliminate the potential for unnecessary recursion of alternative experiments, but in doing so,
got rid of useful features for SingleCellExperiments
like reduced dimensions and size factors.
So let's put that stuff back. First we clone the project:
tmp <- "update_20240418" unlink(tmp, recursive=TRUE) # get rid of any previous directory. gypsum::cloneVersion("scRNAseq", "mair-pbmc-2020", "2023-12-20", destination=tmp)
Now we go in and promote the OBJECT
file to a SingleCellExperiment
,
following the specification here.
There's no need to do anything else as the new SCE just differs from the old SE by the class definition, not any of its contents.
update <- function(obj.path) { obj <- jsonlite::fromJSON(obj.path, simplifyVector=FALSE) obj$type <- "single_cell_experiment" obj$ranged_summarized_experiment <- list(version="1.0") obj$single_cell_experiment <- list(version="1.0") # Replacing the link with the new content; it's important to delete the link # before doing so, otherwise we would accidentally modify the cache! unlink(obj.path) write(jsonlite::toJSON(obj, auto_unbox=TRUE, pretty=4), file=obj.path) }
Running our update script on all of the alternative experiments:
update(file.path(tmp, "alternative_experiments/0", "OBJECT"))
We validate and load the entire object, just to check that it's all good.
library(alabaster.base) validateObject(file.path(tmp)) out <- readObject(tmp) ae <- SingleCellExperiment::altExp(out) stopifnot(is(ae, "SingleCellExperiment")) ae
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.