kstreet13 / slingshot

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

Lineage plots connecting between all cells? #111

Closed scideas closed 3 years ago

scideas commented 3 years ago

Dear slingshot team,

EDIT: I solved my own issue- realized it was a problem with the lineages being plotted using the reduced dimensions function rather than the raw data set

I have chosen to use slingshot for trajectory analysis because its automated lineage algorithm works impressively well. I haven't been able to get monocle3 to cooperate so am moving on with your package :).

First off, here is the code for how I created the slingshot object after converting a seurat object to a SingleCellExperiment object: sce <- as.SingleCellExperiment(scharm) sim <- slingshot(sce, reducedDim = 'UMAP', start.clus = c('0'),

end.clus = c('5', '9', '6', '10'),

             clusterLabels = scharm$seurat_clusters, 
               approx_points = 100) #approx_points = 100

It initially appeared as though my lineages were constructed correctly (there are 10 end states that look biologically meaningful but I'm only plotting one of the cell sets here): colors <- colorRampPalette(brewer.pal(11,'Spectral')[-6])(100) plotcol <- colors[cut(sim$slingPseudotime_7, breaks=100)] plot(reducedDims(sim)$UMAP, col = plotcol, pch=16, asp = 1) lines(SlingshotDataSet(sim), lwd=2, col='black') image

However, when I plotted the lineages using a different approach, the plot looks bizarre, as though it's trying to pass a lineage through every cell:

Here's the code: nc <- 3 pt <- slingPseudotime(sim) nms <- colnames(pt) nr <- ceiling(length(nms)/nc) pal <- viridis(100, end = 0.95) par(mfrow = c(nr, nc))

for (i in nms) { colors <- pal[cut(pt[,i], breaks = 100)] plot(reducedDim(sim, type = 'UMAP'), col = colors, pch = 16, cex = 0.5, main = i) lines(reducedDim(sim), type = 'lineages',lwd = 2, col = 'black') # } slingshot-lineages-results.pdf

I've spent a while reading through what I could, but still haven't found an easy answer for what is happening. I'm much more familiar with plotting in ggplot, so I don't follow every command for plotting used in the vignette I followed.

Am I doing something blatantly wrong here?

Thanks for your help!