Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[monocle3] Error in converting cell_data_set to Seurat object with function "as.Seurat()" #207

Open
jcshuy opened this issue Nov 26, 2024 · 0 comments

Comments

@jcshuy
Copy link

jcshuy commented Nov 26, 2024

Hi everyone. Apologies if this has been answered already but I haven't been able to find a working solution yet. I am trying to run a pseudotime analysis with a v3 Seurat object which was integrated using harmony. The analysis runs fine until I try to convert the cell_data_set object back into a Seurat object using the "as.Seurat()" function. Upon running this code code:

library(SeuratWrappers)
library(monocle3)
options(Seurat.object.assay.version = "v3")
cds <- as.cell_data_set(seuratObject)
gc(full = T)
cds <- cluster_cells(cds)
p1 <- plot_cells(cds, color_cells_by = "cluster", show_trajectory_graph = FALSE)
p2 <- plot_cells(cds, color_cells_by = "seurat_clusters", show_trajectory_graph = FALSE, label_groups_by_cluster = TRUE)
wrap_plots(p1, p2)
cds <- learn_graph(cds)
cds <- order_cells(cds, root_cells = colnames(cds[,clusters(cds) == c("10")]))
plot_cells(cds,
           color_cells_by = "pseudotime",
           group_cells_by = "seurat_clusters",
           label_cell_groups = FALSE,
           label_groups_by_cluster=FALSE,
           label_leaves=TRUE,
           label_branch_points=FALSE,
           label_roots = FALSE,
           cell_size = 0.6,
           trajectory_graph_color = "BLACK")
pseudotime <- as.Seurat(cds, assay = NULL)

I get the result:
Error in validObject(object = value) : invalid class "DimReduc" object: colnames for 'feature.loadings' must start with reduction key (PC_)

I confirmed that the Seurat object has colnames starting with "PC_", but when looking at the feature loadings from the cell_data_set object the colnames are all from the harmony reduction ("harmony_1", "harmony_2", ..., "harmony_50")

Trying to convert to a Seurat object manually ends up with no reductions at all (including the monocle3_pseudotime reduction). The results don't change upon updating the Seurat Object to v5 either.

Has anyone else been able to work around this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant