kstreet13 / slingshot

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

Plot issue: cant see the cells #158

Closed christoforos-dimitropoulos closed 2 years ago

christoforos-dimitropoulos commented 2 years ago

Hey everyone,

I am running the following code in order to plot a trajectory analysis on my umap created in my Seurat object

sce<-as.SingleCellExperiment(seu_all) sds <- slingshot(data = sce,clusterLabels = sce$seurat_clusters,start.clus=9,reducedDim="UMAP")

sds<-as.SlingshotDataSet(sds)

plot(sds, pch = 16, cex = 0.5,cols=clustercol2)

(where seu: Seurat object, clustercol2: a vector with the hex codes of my cluster colors on UMAP)

However, the resulting plot is just the lines, without the cells.. How can I solve this? Ideally I would like to show my clusters (same colour as UMAP) and black smooth lines showing the trajectory (as the ones in the resulted plot)

image

thanks a lot in advance!

kstreet13 commented 2 years ago

Hi @christoforos-dimitropoulos,

I think the easiest way to achieve this is by plotting the dimensionality reduction first and then adding the Slingshot results, similar to how we do the plotting in the vignette.

Based on your code above, something like this should work:

plot(reducedDims(sce)$UMAP, asp = 1,  cex = 0.5, cols = clustercol2)
lines(sds)

Best, Kelly

christoforos-dimitropoulos commented 2 years ago

Hi @christoforos-dimitropoulos,

I think the easiest way to achieve this is by plotting the dimensionality reduction first and then adding the Slingshot results, similar to how we do the plotting in the vignette.

Based on your code above, something like this should work:

plot(reducedDims(sce)$UMAP, asp = 1,  cex = 0.5, cols = clustercol2)
lines(sds)

Best, Kelly

Hey Kelly,

thanks for the prompt response. However my cells are still not colored by cluster, any idea?

kstreet13 commented 2 years ago

They should be colored by clustercol2, but I don't know how you made that object, so I can't say with any certainty why it isn't working. Depending on the number of clusters you have, you could try making a custom palette and using the Seurat cluster labels (which usually start with 0) as an index:

pal <- brewer.pal(9, "Set1") # for <=9 clusters
plot(reducedDims(sce)$UMAP, asp = 1,  cex = 0.5, col = pal[sce$seurat_clusters + 1])

(also, apologies for cols in the last code snippet, should be col)

christoforos-dimitropoulos commented 2 years ago

Great thanks! clustercol2[sce$seurat_clusters] worked just fine