digitalcytometry / cytotrace2

CytoTRACE 2 is an interpretable AI method for predicting cellular potency and absolute developmental potential from scRNA-seq data.
Other
85 stars 6 forks source link

Umap mapping #14

Closed wxpbioinfo closed 4 months ago

wxpbioinfo commented 5 months ago

Why is the umap coordinate produced by the drawing different from the original coordinate? How should I solve it?

savagyan00 commented 5 months ago

Hello and thank you for reaching out about CytoTRACE 2!

When you use the plotData function, it internally generates a new UMAP using the RunUMAP function with its default seed of 42 and the dimensions set by the pc_dims input argument, which defaults to 30. If the UMAP coordinates on your Seurat object differ from what our tool produces, it could be due to different parameters used in your initial UMAP calculation. To better assist you, could you please share the parameters you used when running RunUMAP on your object? This information will help us guide you on how to reproduce your original plot or understand the differences.

Thanks!

wxpbioinfo commented 5 months ago

Yes, my pc_dims is not 30, my code is as follows:RunUMAP(NSC,dims=1:15,reduction = "harmony") Does cytotrace2 provide a parameter that does not run umap so that the umap layer is the same as the original?

Thanks!

savagyan00 commented 5 months ago

Hi,

Currently, CytoTRACE 2 does not support using a precalculated UMAP embedding in your input to the plotData function. If specifying the pc_dims argument as 15 does not align with your original UMAP because the dimensionality reduction method is different, you can manually replace the UMAP coordinates in the output with your original "harmony" reduction embeddings. Here's how you can do it with a Seurat object:


# Replace 'your_seurat_object' with your specific Seurat object name
emb_1 <- your_seurat_object@reductions$harmony@cell.embeddings[,1]  # First dimension of your "harmony" reduction embedding
emb_2 <- your_seurat_object@reductions$harmony@cell.embeddings[,2]  # Second dimension of your "harmony" reduction embedding

# replace CytoTRACE2_UMAP embeddings
plots[["CytoTRACE2_UMAP"]][[1]][["data"]]["UMAP_1"] <- emb_1
plots[["CytoTRACE2_UMAP"]][[1]][["data"]]["UMAP_2"]<- emb_2

plots$CytoTRACE2_UMAP

This code assumes that the results of plotData function are saved as the plots object and Harmony embeddings are stored under the harmony key in the reductions slot of your Seurat object. You can adjust the slot and object names based on your actual data structure.

Please let us know if this works for you or if you need further assistance!

wxpbioinfo commented 5 months ago

Roger that. Thank you for your answer.

peipp410 commented 4 weeks ago

Hello! I have another problem regarding this issue. I have replaced CytoTRACE2_UMAP embeddings with my pre-computed UMAP embeddings, but how to modify the x and y axis ranges since the new embeddings do not fit the original scale. I have tried plots$CytoTRACE2_UMAP + xlim(-10, 15) + ylim(-12, 10) like ggplot but it doesn't work. Thanks!

savagyan00 commented 3 weeks ago

Hi, Thank you for using CytoTRACE 2 and reaching out with your question!

Could you please try plots$CytoTRACE2_UMAP + coord_cartesian(xlim = range(-10, 15), ylim = range(-12, 10)) instead. Please let us know if it works as you expect.

peipp410 commented 3 weeks ago

Hi, Thank you for using CytoTRACE 2 and reaching out with your question!

Could you please try plots$CytoTRACE2_UMAP + coord_cartesian(xlim = range(-10, 15), ylim = range(-12, 10)) instead. Please let us know if it works as you expect.

That works! Thank you for your reply.