Comments (10)
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.
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.
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.
Thanks! This is great. I was looking for that function... after trying getCurves()
I got a little more careful though ;).
from slingshot.
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.
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.
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.
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.
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
Let me know if this doesn't work for you or if you're still having trouble on your dataset!
from slingshot.
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)
- Average curve weights and Pseudotime HOT 1
- slingshot analysis on PCA but visualization on UMAP HOT 3
- how to analyze with 3 different treatments HOT 4
- how to calclate the POS to compare other algorithm? HOT 2
- Pulling and plotting Differential pseudotime data across different conditions/metadata slots HOT 1
- `embedCurves` should also map MST into new space HOT 1
- Slingshot followed by CellRank HOT 1
- is slingshot using only the variable genes? HOT 2
- Pick one lineage from many for conditiontest HOT 3
- How do I extract feature_info in my rds file? HOT 4
- What does a curve represent biologically? HOT 7
- Overlapping curve issue - change to code needed? HOT 3
- Removing a lineage from a `PseudotimeOrdering` object? HOT 3
- Error in graph.adjacency.dense: Adjacency matrix should be symmetric to produce an undirected graph. Invalid value HOT 5
- pseudotime in two lineage? HOT 2
- Slingshot error HOT 1
- Error while plotting the Minimum Distances Between Cell-Type Centroids using Slingshot in r HOT 6
- Error: (converted from warning) useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = FALSE. HOT 1
- Slingshot package ------ Error in crossprod(out) : "crossprod" is not BUILTIN function HOT 1
- confusion about the end of a lineage HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slingshot.