library(BiocStyle) knitr::opts_chunk$set(error=FALSE, message=FALSE, warning=FALSE)
SingleCellExperiment
For some reason, I saved all of the to-be-alternative experiments as SummarizedExperiment
s instead of SingleCellExperiment
s.
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", "stoeckius-hashing-2018", "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:
for (x in c("pbmc/adt", "pbmc/igg", "pbmc/hto", "mixture/hto")) { update(file.path(tmp, x, "OBJECT")) }
We validate and load each one, just to check that it's all good.
library(alabaster.base) validateObject(file.path(tmp, "pbmc/adt")) out <- readObject(file.path(tmp, "pbmc/adt")) stopifnot(is(out, "SingleCellExperiment")) out validateObject(file.path(tmp, "pbmc/igg")) out <- readObject(file.path(tmp, "pbmc/igg")) stopifnot(is(out, "SingleCellExperiment")) out validateObject(file.path(tmp, "pbmc/hto")) out <- readObject(file.path(tmp, "pbmc/hto")) stopifnot(is(out, "SingleCellExperiment")) out validateObject(file.path(tmp, "mixture/hto")) out <- readObject(file.path(tmp, "mixture/hto")) stopifnot(is(out, "SingleCellExperiment")) out
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.