kstreet13 / slingshot

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

Reverse direction of the path without providing clusters #170

Closed YOU-k closed 2 years ago

YOU-k commented 2 years ago

Hi there, I am trying slingshot on our new datasets these days, with code as sce.sling <- slingshot(sce, reducedDim='PCA') embedded <- embedCurves(sce.sling, "UMAP") embedded <- slingCurves(embedded)[[1]]

It worked well since the path shows exactly what we expect to see. However, the starting and the end should be swapped based on biological information. I found that the starting node can be selected if cluster labels are provided. So we provide the clustering result, however, the direction of the path changed. I can tell that the new path goes through these clusters, and end in one of the clusters. This is not what we want, since all the cells we have formed into one big cluster, and we don't really believe in the clustering result. So, is there a way to reverse the direction of the path without using any clustering results? Appreciate your answers. Cheers, Yue

kstreet13 commented 2 years ago

Hi @YOU-k ,

So, I think I should start by clarifying how Slingshot uses cluster labels. If you're using Slingshot, then it's already assumed that the cells follow a trajectory structure and so the distinctions between different clusters are somewhat arbitrary. The clusters are really only used for establishing the basic structure of the trajectory, including its direction.

In your case, it sounds like you have a single lineage? So hopefully your results look pretty similar whether you use clusters or not and I don't see any issue with using them to set the direction. With a single lineage and no clusters, you are basically fitting a principal curve which, like a principal component, has an arbitrary direction. So if you really want to avoid the clusters, you can just manually reverse the pseudotimes and there would be nothing theoretically wrong with that.

Hope this helps! Kelly

YOU-k commented 2 years ago

Yep. I have a single lineage. Good to confirm that manually reversing the pseudotime is theoretically ok. Cheers, Yue