monocle-release icon indicating copy to clipboard operation
monocle-release copied to clipboard

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

Open MariaRosariaNucera opened this issue 4 years ago • 9 comments

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 :)

MariaRosariaNucera avatar Jun 22 '21 08:06 MariaRosariaNucera

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

AY-LIANG avatar Apr 03 '22 12:04 AY-LIANG

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

caroatria avatar Aug 11 '22 09:08 caroatria

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@[email protected] cds_seur@preprocess_aux$prop_var_expl <- your_seurat_ob@reductions$pca@stdev cds_seur@int_colData@listData$reducedDims$UMAP <- your_seurat_ob@[email protected] 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 <- [email protected]$your_clusters

MariaRosariaNucera avatar Nov 14 '22 14:11 MariaRosariaNucera

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 avatar Oct 12 '23 09:10 micosacak

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 = [email protected],
  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@[email protected]
cds_from_seurat@reduce_dim_aux@listData[["UMAP"]] <- my.seurat.obj@[email protected] #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@[email protected]
cds_from_seurat@int_colData@listData$reducedDims$UMAP <- my.seurat.obj@[email protected]
cds_from_seurat@reduce_dim_aux@listData[["UMAP"]] <-my.seurat.obj@reductions[["umap"]]@cell.embeddings
cds_from_seurat@clusters$UMAP_so$clusters <- [email protected]$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

micosacak avatar Oct 12 '23 12:10 micosacak

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 = [email protected],
  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@[email protected]
cds_from_seurat@reduce_dim_aux@listData[["UMAP"]] <- my.seurat.obj@[email protected] #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@[email protected]
cds_from_seurat@int_colData@listData$reducedDims$UMAP <- my.seurat.obj@[email protected]
cds_from_seurat@reduce_dim_aux@listData[["UMAP"]] <-my.seurat.obj@reductions[["umap"]]@cell.embeddings
cds_from_seurat@clusters$UMAP_so$clusters <- [email protected]$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?

MariaRosariaNucera avatar Oct 12 '23 12:10 MariaRosariaNucera

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 avatar Oct 12 '23 13:10 micosacak

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

cds_from_seurat@preprocess_aux steps.

micosacak avatar Oct 26 '23 06:10 micosacak

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

apal6 avatar Apr 30 '24 19:04 apal6