cole-trapnell-lab / monocle-release

272 stars 115 forks source link

Is it possible to use Scanpy Generated UMAP for Monocle3 trajectory analysis? #444

Open MariaRosariaNucera opened 3 years ago

MariaRosariaNucera commented 3 years ago

Hello @ctrapnell, thank you for the useful toolkit, I saw in previous issues that some people asked how to use their Seurat UMAP for the analysis since Monocle3 generates a completetly different figure. I have the same problem but I wanted to use the UMAP I generated using Scanpy. Do you have any suggestions? Thank :)

AY-LIANG commented 2 years ago

Hi, I have the same problem,have you solved it? Thanks

caroatria commented 1 year ago

Hi, did any of you find a solution to this problem? Thanks

MariaRosariaNucera commented 1 year ago

yes I just copied info from the seurat obj like this: (where cds_seur is the output of new_cell_data_set(matrix,cell_metadata = cell_metadata, gene_metadata = gene_annotation))

reducedDim(cds_seur, type = "PCA") <- your_seurat_ob@reductions$pca@cell.embeddings cds_seur@preprocess_aux$prop_var_expl <- your_seurat_ob@reductions$pca@stdev cds_seur@int_colData@listData$reducedDims$UMAP <- your_seurat_ob@reductions$umap@cell.embeddings cds_seur@reduce_dim_aux@listData[["UMAP"]] <-your_seurat_ob@reductions[["umap"]]@cell.embeddings cds_seur@preprocess_aux$gene_loadings <- your_seurat_ob@reductions[["pca"]]@feature.loadings cds_seur@clusters$UMAP_so$clusters <- your_seurat_ob@meta.data$your_clusters

micosacak commented 9 months ago

Hi,

when I try this: "cds_seur@preprocess_aux$prop_var_expl <- your_seurat_ob@reductions$pca@stdev", it raises error for "preprocess_aux".

I could not find a slot for "preprocess_aux" in monocle3 cds object.

micosacak commented 9 months ago

and by the way; I am trying to use it from Seurat not Scanpy.

basically as bellow:

# monocle3 function
gene_annotation = as.data.frame(rownames(my.seurat.obj@assays$RNA@counts))
colnames(gene_annotation) = "gene_short_name"
rownames(gene_annotation) = gene_annotation$gene_short_name

cds <- new_cell_data_set(
  my.seurat.obj@assays$RNA@counts,
  cell_metadata = my.seurat.obj@meta.data,
  gene_metadata = gene_annotation
  )

cds <- preprocess_cds(cds, num_dim = 30)
cds <- reduce_dimension(cds)
cds <- cluster_cells(cds)
cds <- learn_graph(cds)
cds <- order_cells(cds) # this step requires interactive selection for ordering the cells.

now if I try the following: `

cds_from_seurat = cds
#cds_from_seurat@reduce_dim_aux@listData$seuUMAP = my.seurat.obj@reductions$umap@cell.embeddings
cds_from_seurat@reduce_dim_aux@listData[["UMAP"]] <- my.seurat.obj@reductions$umap@cell.embeddings #seurat@reductions[["umap"]]@cell.embeddings

### Assign feature loading for downstream module analysis

cds_from_seurat@preprocess_aux$gene_loadings <- my.seurat.obj@reductions[["pca"]]@feature.loadings

the error is as following:

Error in cds_from_seurat@preprocess_aux$gene_loadings <- my.seurat.obj@reductions[["pca"]]@feature.loadings:
   no slot of the name "preprocess_aux" for this object of the class "cell_data_set"

if I try the above:

reducedDim(cds_from_seurat, type = "PCA") <- my.seurat.obj@reductions$pca@cell.embeddings
cds_from_seurat@int_colData@listData$reducedDims$UMAP <- my.seurat.obj@reductions$umap@cell.embeddings
cds_from_seurat@reduce_dim_aux@listData[["UMAP"]] <-my.seurat.obj@reductions[["umap"]]@cell.embeddings
cds_from_seurat@clusters$UMAP_so$clusters <- my.seurat.obj@meta.data$your_clusters

cds_from_seurat@preprocess_aux$gene_loadings <- my.seurat.obj@reductions[["pca"]]@feature.loadings
cds_from_seurat@preprocess_aux$prop_var_expl <- my.seurat.obj@reductions$pca@stdev

I only get error from: cds_from_seurat@preprocess_aux

MariaRosariaNucera commented 9 months ago

and by the way; I am trying to use it from Seurat not Scanpy.

basically as bellow:

# monocle3 function
gene_annotation = as.data.frame(rownames(my.seurat.obj@assays$RNA@counts))
colnames(gene_annotation) = "gene_short_name"
rownames(gene_annotation) = gene_annotation$gene_short_name

cds <- new_cell_data_set(
  my.seurat.obj@assays$RNA@counts,
  cell_metadata = my.seurat.obj@meta.data,
  gene_metadata = gene_annotation
  )

cds <- preprocess_cds(cds, num_dim = 30)
cds <- reduce_dimension(cds)
cds <- cluster_cells(cds)
cds <- learn_graph(cds)
cds <- order_cells(cds) # this step requires interactive selection for ordering the cells.

now if I try the following: `

cds_from_seurat = cds
#cds_from_seurat@reduce_dim_aux@listData$seuUMAP = my.seurat.obj@reductions$umap@cell.embeddings
cds_from_seurat@reduce_dim_aux@listData[["UMAP"]] <- my.seurat.obj@reductions$umap@cell.embeddings #seurat@reductions[["umap"]]@cell.embeddings

### Assign feature loading for downstream module analysis

cds_from_seurat@preprocess_aux$gene_loadings <- my.seurat.obj@reductions[["pca"]]@feature.loadings

the error is as following:

Error in cds_from_seurat@preprocess_aux$gene_loadings <- my.seurat.obj@reductions[["pca"]]@feature.loadings:
   no slot of the name "preprocess_aux" for this object of the class "cell_data_set"

if I try the above:

reducedDim(cds_from_seurat, type = "PCA") <- my.seurat.obj@reductions$pca@cell.embeddings
cds_from_seurat@int_colData@listData$reducedDims$UMAP <- my.seurat.obj@reductions$umap@cell.embeddings
cds_from_seurat@reduce_dim_aux@listData[["UMAP"]] <-my.seurat.obj@reductions[["umap"]]@cell.embeddings
cds_from_seurat@clusters$UMAP_so$clusters <- my.seurat.obj@meta.data$your_clusters

cds_from_seurat@preprocess_aux$gene_loadings <- my.seurat.obj@reductions[["pca"]]@feature.loadings
cds_from_seurat@preprocess_aux$prop_var_expl <- my.seurat.obj@reductions$pca@stdev

I only get error from: cds_from_seurat@preprocess_aux

can you show me the structure of your cds?

micosacak commented 9 months ago

here it is:

> cds
class: cell_data_set 
dim: 19035 1328 
metadata(2): cds_version citations
assays(1): counts
rownames(19035): fgfr1op2 znf1114 ... CABZ01113815.1 CABZ01090361.1
rowData names(1): gene_short_name
colnames(1328): her.les_AAACCCACACTCATAG her.les_AAACGAAAGTAACGAT ...
  her.nai_TTTGGAGAGAGGGTGG her.nai_TTTGGAGGTGGCATCC
colData names(13): orig.ident nCount_RNA ... integrated_snn_res.2.5
  Size_Factor
reducedDimNames(2): PCA UMAP
mainExpName: NULL
altExpNames(0):
> cds_from_seurat
class: cell_data_set 
dim: 19035 1328 
metadata(2): cds_version citations
assays(1): counts
rownames(19035): fgfr1op2 znf1114 ... CABZ01113815.1 CABZ01090361.1
rowData names(1): gene_short_name
colnames(1328): her.les_AAACCCACACTCATAG her.les_AAACGAAAGTAACGAT ...
  her.nai_TTTGGAGAGAGGGTGG her.nai_TTTGGAGGTGGCATCC
colData names(13): orig.ident nCount_RNA ... integrated_snn_res.2.5
  Size_Factor
reducedDimNames(2): PCA UMAP
mainExpName: NULL
altExpNames(0):
micosacak commented 9 months ago

found the solution here: 2833. Almost same, except I skipped adding;

cds_from_seurat@preprocess_aux steps.

apal6 commented 2 months ago

Hi,

I have the same error. Error in cds_from_seurat@preprocess_aux$gene_loadings <-seurat@reductions[["pca"]]@feature.loadings : no slot of name "preprocess_aux" for this object of class "cell_data_set"

Any suggestions?

Thank you