Run Canek on Seurat objects

knitr::opts_chunk$set(
  fig.width = 6,
  fig.align = "center",
  collapse = TRUE,
  comment = "#>"
)
library(Canek)
library(Seurat)

Create Seurat object

x <- lapply(names(SimBatches$batches), function(batch) {
  CreateSeuratObject(SimBatches$batches[[batch]], project = batch) 
})
x <- merge(x[[1]], x[[2]])
x[["cell_type"]] <- SimBatches$cell_types
x
table(x$orig.ident)
x <- NormalizeData(x)
x <- FindVariableFeatures(x, nfeatures=100)
VariableFeaturePlot(x)
x <- ScaleData(x)
x <- RunPCA(x)

PCA plot before correction

DimPlot(x, group.by = "orig.ident")
DimPlot(x, group.by = "cell_type")

Run Canek

We pass the column containing the batch information.

x <- RunCanek(x, "orig.ident")

The features selected during integration are assigned as variable features.

head(VariableFeatures(x, assay="Canek"))

We scale features and run PCA.

x <- ScaleData(x)
x <- RunPCA(x)

PCA plot after correction

DimPlot(x, group.by = "orig.ident")
DimPlot(x, group.by = "cell_type")


Try the Canek package in your browser

Any scripts or data that you put into this service are public.

Canek documentation built on Nov. 6, 2023, 1:06 a.m.