all_times <- list() # store the time for each chunk knitr::knit_hooks$set(time_it = local({ now <- NULL function(before, options) { if (before) { now <<- Sys.time() } else { res <- difftime(Sys.time(), now, units = "secs") all_times[[options$label]] <<- res } } })) knitr::opts_chunk$set( tidy = TRUE, tidy.opts = list(width.cutoff = 95), fig.width = 10, message = FALSE, warning = FALSE, time_it = TRUE, error = TRUE )
library(Seurat) options(Seurat.object.assay.version = "v5") library(SeuratData) library(patchwork)
# install dataset InstallData('pbmcsca')
# load dataset pbmcsca <- LoadData("pbmcsca") pbmcsca <- UpdateSeuratObject(object = pbmcsca) pbmcsca[["RNA"]] <- as(pbmcsca[["RNA"]], Class = "Assay5") # split the dataset into layers pbmcsca[["RNA"]] <- split(pbmcsca[["RNA"]], f = pbmcsca$Method)
pbmcsca <- SCTransform(pbmcsca) pbmcsca <- RunPCA(pbmcsca, npcs = 30, verbose = FALSE)
We then integrate all the layers using the IntegrateLayers()
function.
pbmcsca <- IntegrateLayers(object = pbmcsca, method = RPCAIntegration, normalization.method="SCT", verbose = F)
pbmcsca <- FindNeighbors(pbmcsca, dims = 1:30) pbmcsca <- FindClusters(pbmcsca, resolution = 2) pbmcsca <- RunUMAP(pbmcsca, dims = 1:30)
# Visualization p1 <- DimPlot(pbmcsca, reduction = "umap", group.by = "Method") p2 <- DimPlot(pbmcsca, reduction = "umap", group.by = "CellType", label = TRUE, repel = TRUE) p1 + p2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.