kstreet13 / slingshot

Functions for identifying and characterizing continuous developmental trajectories in single-cell data.
259 stars 42 forks source link

`embedCurves` should also map MST into new space #238

Closed Yunuuuu closed 6 months ago

Yunuuuu commented 6 months ago

sling_obj is a object returned by slingshot::slingshot in the corrected PCA (with fastMNN) space, here we want to use UMAP space to plot, so we use embedCurves to embed the curves in a UMAP space, and we found the internal MST remains unchanged.

paths <- slingshot::embedCurves(sling_obj, "UMAP")
head(slingshot::slingMST(sling_obj)) # the orginal MST

image

head(slingshot::slingMST(paths)) # the embed MST

image

identical(slingshot::slingMST(sling_obj), slingshot::slingMST(paths))
> [1] TRUE
kstreet13 commented 6 months ago

Hi @Yunuuuu,

Thank you for the suggestion, but I think this could end up being quite misleading. For one, there is no guarantee that the MST in the original space would still be the MST in the new space, as distances between clusters have likely changed. More subtly, the MST is an important part of how Slingshot calculates pseudotime values, and that only happens in the original space (corrected PCA, in your case). If we "translated" the MST to the new space while keeping the original pseudotimes, that would be inconsistent and could be misleading. And since embedCurves is really only intended as a visualization tool, I don't think we'd want to re-calculate the pseudotime values in the new space.

For visualization purposes, however, you can still plot the MST in the new embedding space the same way you would in the original space (I typically use the lines function).

Best, Kelly