Cannot convert the inetgarted seurat object to the cds for monocle 3
0
0
Entering edit mode
2.1 years ago

Hello,

I am receiving the follow error:

cds <- as.cell_data_set(b.seu)
Warning: Monocle 3 trajectories require cluster partitions, which Seurat does not calculate. Please run 'cluster_cells' on your cell_data_set object.
library(Seurat)
library(patchwork)
library(SeuratWrappers)
library(ggplot2)
library(tidyverse)

control = Read10X("C:/Users/TVIT1/Desktop/imtegrationsdj_Tuall/Tu1_099")
inhibitor = Read10X("C:/Users/TVIT1/Desktop/imtegrationsdj_Tuall/Tu2_099")
dnavaccine = Read10X("C:/Users/TVIT1/Desktop/imtegrationsdj_Tuall/Tu3_099")
combitr = Read10X("C:/Users/TVIT1/Desktop/imtegrationsdj_Tuall/Tu4_099")

Created the Seurat Object:
control_seurat = CreateSeuratObject(counts = control$Gene Expression,
project = "control")
inhibitor_seurat = CreateSeuratObject(counts = inhibitor$Gene
Expression, project = "inhibitor")
dnavaccine_seurat = CreateSeuratObject(counts = dnavaccine$Gene
Expression, project = "dnavaccine")
combitr_seurat = CreateSeuratObject(counts = combitr$Gene Expression,
project = "combitr")

Merged the datasets
merge_seurat = merge(x = control_seurat, y = c(inhibitor_seurat,
dnavaccine_seurat, combitr_seurat), add.cell.id = c("control",
"inhibitor","dnavaccine", "combitr"))
head(merge_seurat@meta.data,5)

Filtering the mitochondrial genes
merge_seurat$mitoRatio <- PercentageFeatureSet(object = merge_seurat,
pattern = "^mt-")
metadata <- merge_seurat@meta.data
metadata$cells <- rownames(metadata)
library(dplyr)
metadata <- metadata %>%
dplyr::rename(group = orig.ident,
nUMI = nCount_RNA,
nGene = nFeature_RNA)
library(stringr)
metadata$sample <- NA
metadata$sample[which(str_detect(metadata$cells, "^control_"))] <- "control"
metadata$sample[which(str_detect(metadata$cells, "^inhibitor_"))] <- "inhibitor"
metadata$sample[which(str_detect(metadata$cells, "^dnavaccine_"))] <-
"dnavaccine"
metadata$sample[which(str_detect(metadata$cells, "^combitr_"))] <- "combitr"
merge_seurat@meta.data <- metadata
head(merge_seurat@meta.data,5)
tail(merge_seurat@meta.data,5)
data.list <- SplitObject(merge_seurat, split.by = "sample")

data.list <- lapply(X = data.list, FUN = function(x) {
x <- NormalizeData(x)
x <- FindVariableFeatures(x, selection.method = "vst")
})

Integration of datasets
features <- SelectIntegrationFeatures(object.list = data.list)
immune.anchors <- FindIntegrationAnchors(object.list = data.list,
anchor.features = features)
immune.combined <- IntegrateData(anchorset = immune.anchors)
DefaultAssay(immune.combined) <- "integrated"
immune.combined <- ScaleData(immune.combined, verbose = FALSE)
immune.combined <- RunPCA(immune.combined, npcs = 30, verbose = FALSE)
immune.combined <- RunUMAP(immune.combined, reduction = "pca", dims = 1:10)
immune.combined <- FindNeighbors(immune.combined, reduction = "pca",
dims = 1:30)
immune.combined <- FindClusters(immune.combined, resolution = 0.5)
p1 <- DimPlot(immune.combined, reduction = "umap", group.by = "sample")
p2 <- DimPlot(immune.combined, reduction = "umap", label = TRUE, repel = TRUE)
DimPlot(immune.combined, reduction = "umap", split.by = "sample")

DefaultAssay(immune.combined) <- "RNA"
library(metap)
all.markers084 <- FindAllMarkers(immune.combined, only.pos = TRUE,
min.pct = 0.25, logfc.threshold = 0.25)

b.seu <- WhichCells(immune.combined, idents= c("B", "CD21+ B", "Immature B", "Tuft", "Inflammatory mono", "Goblet cell"))
b.seu = subset(immune.combined, cells = b.seu)
pre-processing using seurat

b.seu <- NormalizeData(b.seu)
b.seu <- FindVariableFeatures(b.seu)
b.seu <- ScaleData(b.seu)
b.seu <- RunPCA(b.seu)
b.seu <- FindNeighbors(b.seu, dims = 1:30)
b.seu <- FindClusters(b.seu, resolution = 0.9)
b.seu <- RunUMAP(b.seu, dims = 1:30, n.neighbors = 50)

a1 <- DimPlot(b.seu, reduction = 'umap', group.by = 'seurat_clusters', label = T)

MONOCLE3 WORKFLOW ---------------------
monocle3 requires cell_data_set object
convert seurat object to cell_data_set object for monocle3
...1 Convert to cell_data_set object ------------------------

cds <- as.cell_data_set(b.seu)

Warning: Monocle 3 trajectories require cluster partitions, which Seurat does not calculate. Please run 'cluster_cells' on your cell_data_set object.
monocle3 seurat • 3.3k views
ADD COMMENT
0
Entering edit mode

First of all, it's a warning and not an error. I guess your cell data object has been created.

As suggested in the warning either run cluster_cells function OR you can assign a dummy partition manually.

recreate.partition <- c(rep(1, length(cds@colData@rownames)))
names(recreate.partition) <- cds@colData@rownames
recreate.partition <- as.factor(recreate.partition)
cds@clusters@listData[["UMAP"]][["partitions"]] <- recreate.partition

Regards,

Nitin N.

ADD REPLY
0
Entering edit mode

Hello, Thank you very much for your reply. I did run the recreate partition code and added the following code. Im still receiving an error:

> recreate.partition <- c(rep(1, length(cds@colData@rownames)))
> names(recreate.partition) <- cds@colData@rownames
> recreate.partition <- as.factor(recreate.partition)
> cds@clusters@listData[["UMAP"]][["partitions"]] <- recreate.partition

> list_cluster <- b.seu@meta.data[[sprintf("seurat_clusters")]]
> #list_cluster <- b.seu@meta.data[[sprintf("ClusterNames_%s_%sPC", 0.5, 20)]]
> names(list_cluster) <- b.seu@assays[["RNA"]]@data@Dimnames[[2]]

> list_cluster <- b.seu@meta.data[[sprintf("seurat_clusters")]]
> #list_cluster <- b.seu@meta.data[[sprintf("ClusterNames_%s_%sPC", 0.5, 20)]]
> names(list_cluster) <- b.seu@assays[["RNA"]]@data@Dimnames[[2]]

> cds@clusters@listData[["UMAP"]][["clusters"]] <- list_cluster
> cds@clusters@listData[["UMAP"]][["louvain_res"]] <- "NA"

> cds <- monocle3::preprocess_cds(cds, method = "PCA", norm_method = "none")
> cds <- monocle3::reduce_dimension(cds, reduction_method = "UMAP")
No preprocess_method specified, using preprocess_method = 'PCA'

> reducedDim(cds, "UMAP") <- Embeddings(b.seu, "umap")

> cds@preprocess_aux$gene_loadings <- b.seu@reductions[["pca"]]@feature.loadings
Error in cds@preprocess_aux$gene_loadings <- b.seu@reductions[["pca"]]@feature.loadings : no slot of name "preprocess_aux" for this object of class "cell_data_set"

> cds@preprocess_aux$gene_loadings <- Loadings(seu, "pca")
Error in Loadings(seu, "pca") : object 'seu' not found

> cds@preprocess_aux$gene_loadings <- Loadings(b.seu, "pca")
Error in cds@preprocess_aux$gene_loadings <- Loadings(b.seu, "pca") : no slot of name "preprocess_aux" for this object of class "cell_data_set"

Anything that can be done?

Thank you.

Kind Regards, Shweta Johari

ADD REPLY
0
Entering edit mode

This thread might help to create a monocle3 object using Seurat object.

Using Monocle 3 with Seurat 3 integrated object

ADD REPLY

Login before adding your answer.

Traffic: 2018 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6