scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.9k stars 597 forks source link

How can i replace the adata's X_umap coordinate with seurat's umap coordinate #1718

Closed honghh2018 closed 6 months ago

honghh2018 commented 3 years ago

Hi @ALL, I had the scVelo object of 'adata' to run the scv.tl.umap(adata) with different coordinate bewteen seurat's umap coordinate and the scVelo object's umap coordinate. So, i hope to visulize the umap plot using the seurat's umap coordinate. based on this request, i hope to substitute the scVelo's X_umap coordinate with seurat's umap coordinate. how can i do for above request? any advice would be appreciated. Best, hanhuihong

dawe commented 3 years ago

You can set adata.obsm['X_umap'] to the array you have, given that the row order is conserved. Also creating a specific matrix is ok, say adata.obsm['X_seurat'], then use that as basis for all visualizations and calculations (e.g. scv.pl.scatter(adata, basis='seurat'…))

honghh2018 commented 3 years ago

Very appreciate your reply @dawe. it was fine by me. But i confused the order of AnnData's obsm['X_umap'] 's barcode ,because of it was array without rownames, so how can i obtain the cell barcode that was identical with X_umap order. i want to save the X_umap coordinate with the cell barcode into csv file. how should i do for this condition. any advice would be appreciated Best, hanhuihong

dawe commented 3 years ago

Retrieve cell names in the Seurat object used to create the embedding, then simply reorder AnnData accordingly (adata = adata[cell_names]).

honghh2018 commented 3 years ago

Hi @dawe , I follow your code and it work well, but the result showing weird, the scvelo arrow indicate the development direction just was in contrast to the monocle direction. In the other word, the scvelo's 'scv.pl.velocity_embedding_stream' showing terminal differentiation cells develop to original cells. this was incorrected logically. why the scvelo showed the inverted result contrast with monocle result. I guess what i make the cell order was wrong ? i follow your code-adata = adata[cell_names]- to order the cell , i wonder whether the code just sorted the cell barcode on annData.obs but the annData.X's matrix? why was the order runing so quickly that the matrix of annData not be sorted at the same time? Best, hanhuihong

LuckyMD commented 3 years ago

Hi @honghh2018,

There are several cases where scvelo doesn't work as expected such as for blood, early development, etc. I would report this in the scvelo github repo, where you can get a more specific answer about this.

dawe commented 3 years ago

In the other word, the scvelo's 'scv.pl.velocity_embedding_stream' showing terminal differentiation cells develop to original cells. this was incorrected logically. why the scvelo showed the inverted result contrast with monocle result.

As @LuckyMD said, this is a question for scvelo.

I guess what i make the cell order was wrong ?

The best way to check if ordering went wrong is to plot an embedding colored by some known grouping. If colors are all mixed up you know a mistake has done.

i wonder whether the code just sorted the cell barcode on annData.obs but the annData.X's matrix? why was the order runing so quickly that the matrix of annData not be sorted at the same time?

Luckily AnnData is quite robust and it reorder any slot (obs, obsp, obsm…) according to the specified cell names.

d

dawe commented 3 years ago

Hello @LuckyMD

There are several cases where scvelo doesn't work as expected such as for blood, early development, etc.

That's interesting! Do you have any resource supporting this? I'm asking as I'm using scvelo a lot these days on a developmental model.

LuckyMD commented 3 years ago

Hi @dawe,

@VolkerBergen is just writing a manuscript on this as it has been coming up a in scvelo issues. He will be able to explain a lot better, but I can try to give you an idea. For developmental datasets time scales of splicing kinetics and development don't really match up very well, so you often don't observe a fixed kinetic for a sufficient time to model it before it changes. Also, you may be observing multiple different kinetics e.g., in the blood.

honghh2018 commented 3 years ago

Hi @honghh2018,

There are several cases where scvelo doesn't work as expected such as for blood, early development, etc. I would report this in the scvelo github repo, where you can get a more specific answer about this. Thanks the reply, this tools was great so far, but still had improve space on your reported. i hope this issue can be solved. Best, hanhuihong

honghh2018 commented 3 years ago

In the other word, the scvelo's 'scv.pl.velocity_embedding_stream' showing terminal differentiation cells develop to original cells. this was incorrected logically. why the scvelo showed the inverted result contrast with monocle result.

As @LuckyMD said, this is a question for scvelo.

I guess what i make the cell order was wrong ?

The best way to check if ordering went wrong is to plot an embedding colored by some known grouping. If colors are all mixed up you know a mistake has done.

i wonder whether the code just sorted the cell barcode on annData.obs but the annData.X's matrix? why was the order runing so quickly that the matrix of annData not be sorted at the same time?

Luckily AnnData is quite robust and it reorder any slot (obs, obsp, obsm…) according to the specified cell names.

d Thanks i would check currently, and reported the result as soon as possible. Best, hanhuihong

honghh2018 commented 6 months ago

您好!已经收到邮件,祝好!                                    洪汉辉