Git Product home page Git Product logo

Comments (10)

kstreet13 avatar kstreet13 commented on July 21, 2024 1

Yes, you can use plot() to plot the curve alone or lines() to add it to an existing plot. For coloring points, I think you can set "color = pseudotime" in ggplot, or set up a color palette using your own colors:
mypal <- colorRampPalette(colors)
z <- cut(pseudotime, breaks = 100)
colvec <- mypal(length(levels(x)))[x]

from slingshot.

LuckyMD avatar LuckyMD commented on July 21, 2024

Hi, I'm having the same problem and am not quite sure how I can solve this. I see that I can subset the data to plot only the cells in a particular lineage, but when I plot the curves on top I'm not sure how to access an individual curve. Using code from your tutorial, I'm currently doing this:

plot(reducedDims(sce)$PCA[,c(1,2)], col = colors[cut(sce$slingPseudotime_1,breaks=100)], pch=16, asp = 1)
lines(SlingshotDataSet(sce), lwd=2)

Which is hiding data points not in slingPseudotime_1 due to NA color values, but it's always plotting all the lineages that it found. I'm not sure how to select only the first curve to plot using lines().

Is there something like getCurves(SlingshotDataSet(sce))$Curve1?

from slingshot.

kstreet13 avatar kstreet13 commented on July 21, 2024

Hi @LuckyMD
Yes, it's very similar to that. You can access the curves with the slingCurves() function, which returns a list of principal_curve objects, each of which can be individually plotted. For your example, I believe this would look like lines(slingCurves(sce)$curve1) or just lines(slingCurves(sce)[[1]]).

from slingshot.

LuckyMD avatar LuckyMD commented on July 21, 2024

Thanks! This is great. I was looking for that function... after trying getCurves() I got a little more careful though ;).

from slingshot.

dpschreiner avatar dpschreiner commented on July 21, 2024

Thanks for the excellent package and, equally important, the informative support here!

Can you suggest a way to subset in this way for the lineages as well? i.e. for the plot generated as follows i'd like to show only lineage at a time:

plot(reducedDims(sce)[[rdx]], col = some_colors, pch=16, asp = 1)
lines(SlingshotDataSet(sce), lwd=5, type = 'lineages')

passing slingLineages(sce)[[k]] to lines() does not have the desired effect, presumably due to the additional logic in your plot function for type lineages.

from slingshot.

kstreet13 avatar kstreet13 commented on July 21, 2024

Thanks! That's a great question and it's something I had never thought of before. Unfortunately, I can't think of any similar workaround for the lineages as we have with the curves (briefly, because the output of slingCurves contains everything needed for plotting, but slingLineages only contains the ordered cluster names).

For now, it is probably easiest to find the cluster centers externally and plot them in the order given by slingLineages. But since this seems to be a common use case, I'll re-open this issue as a reminder to add an argument to the plotting functions giving the option to only plot some lineages/curves.

from slingshot.

kstreet13 avatar kstreet13 commented on July 21, 2024

Hey all! The new version on github now includes the linInd argument for the plotting functions, allowing you to specify which lineages you want to plot (should work with type = 'lineages' and type = 'curves'). Thank you for the suggestion and I hope this is helpful!

from slingshot.

raveancic avatar raveancic commented on July 21, 2024

Thank you very much for this!
I downloaded the latest version of the package from github (1.5.1) but I am not able to use the parameter linInd. Would you be so kind to put an example in here on how to use it?
Thank you very much again.

Alessandro

from slingshot.

kstreet13 avatar kstreet13 commented on July 21, 2024

Hi Alessandro,
Thanks for the report! Here is a small example that works for me (also using version 1.5.1):

data("slingshotExample")
rd <- slingshotExample$rd
cl <- slingshotExample$cl
sds <- slingshot(rd, cl)

plot(rd, asp = 1, col = cl)
lines(sds, linInd = 1) # draws smooth curve for the upper lineage
lines(sds, linInd = 2, type='l') # draws MST edges for the lower lineage

image

Let me know if this doesn't work for you or if you're still having trouble on your dataset!

from slingshot.

raveancic avatar raveancic commented on July 21, 2024

Thank you very much for the fast answer!
It was my fault, there was some kind of conflict with the previous version and now I have solved unloading and reloading the package, thank you!
Have a great day.

Alessandro

from slingshot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.