Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about plot function #57

Closed
trueth1206 opened this issue Sep 9, 2019 · 2 comments
Closed

Question about plot function #57

trueth1206 opened this issue Sep 9, 2019 · 2 comments

Comments

@trueth1206
Copy link

Hi, Thank you for developing this great package. I am trying to apply this package to do pseudotime for a single cell experiment in two conditions. I used Seurat for filtering and data merge. Then I converted the result to a SingleCellExperiment. The script went smoothly but I found that I lost some dots in the pseudotime plot.

Here is my script:

Obj <- as.SingleCellExperiment(seuratobj)

sce <- slingshot(Obj, clusterLabels = 'seurat_clusters', reducedDim = 'PCA')

colors <- colorRampPalette(brewer.pal(11,'Spectral')[-6])(100)
plotcol <- colors[cut(sce$slingPseudotime_1, breaks=100)]
plot(reducedDims(sce)$PCA, col = plotcol, pch=16, asp = 1)
lines(SlingshotDataSet(sce), lwd=2, col='black')
Rplot03

plot(reducedDims(sce)$PCA, col = brewer.pal(12,'Set3')[sce$seurat_clusters], pch=16, asp = 1)
lines(SlingshotDataSet(sce), lwd=2, type = 'lineages', col = 'black')
Rplot02

But I have 6000 cells and the plot should look like this if it's not colored. The above plots showed only part of the cells.
Rplot01

Is there anything I can do for it to get the correct plots? Thank you.

@kstreet13
Copy link
Owner

Hi @trueth1206,

Hm, that is definitely strange, so thank you for bringing it to my attention. I think the first plot makes sense because you have multiple lineages and are only coloring by pseudotime along the first one. All cells with a weight of zero for that first lineage will end up with an NA for the color and therefore not be plotted. If you didn't intend for this, you can avoid it by replacing sce$slingPseudotime_1 with slingPseudotime(sce, na=FALSE)[,1].

The second plot is much more concerning. I see no reason why you wouldn't get all of the cells, but it looks like you're getting the same subset as from the previous plot, despite not using the Slingshot output in any way. My best guess is that this has something to do with sce$seurat_clusters being used as an index for a color vector of length 12. It looks like you only have ~10 clusters, so if that variable is a factor, I wouldn't expect this behavior (and don't know what might be causing it). If the variable is an integer, it might have values outside the range 1-12 (ie. a "0" cluster)? If that's the case I would replace it with factor(sce$seurat_clusters).

Hope this helps! Let me know if you're still having problems.

@trueth1206
Copy link
Author

Hi,

Thank you for your reply and you're absolutely right. The first plot was solved by using slingPseudotime(sce, na=FALSE)[,1], slingPseudotime(sce, na=FALSE)[,2]... And the second plot came from a subset that contains clusters named "0" and "17". The issue has been solved by using factor(sce$seurat_clusters). Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants