kstreet13 / slingshot

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

Error while plotting the Minimum Distances Between Cell-Type Centroids using Slingshot in r #249

Open HappinessEricst opened 1 month ago

HappinessEricst commented 1 month ago

Hi please i am encountering similar issue how did you fix it. Here is the code:

Run Slingshot p3.neuron.sds <- slingshot(Embeddings(object=p3.moe.neuron.integrated, "pca")[,1:50], clusterLabels = p3.moe.neuron.integrated@active.ident, start.clus = "GBC", end.clus = "mOSN",
stretch = 0))

p3.neuron.sds class: PseudotimeOrdering dim: 33388 1 metadata(4): lineages mst slingParams curves pathStats(2): pseudotime weights cellnames(33388): P3_WT_AAACCTGAGATCTGAA P3_WT_AAACCTGAGCACGCCT ... P3_tetH19s_wt_TTTGTTGGTTAACCTG-1 P3_tetH19s_wt_TTTGTTGTCGCCATAA-1 cellData names(2): reducedDim clusterLabels pathnames(1): Lineage1 pathData names(0):

And i am trying to plot the result

svglite(filename = paste0(paper_images,"p3.slingshot.centroids.cell_type.svg"),width=10,height=10) plot(reducedDim(p3.neuron.sds),col=p3.neuron.celltype.col,pch=16,cex=0.5) lines(p3.neuron.sds,lwd=2,type='lineages',col='black') legend("topright",legend=levels(p3.moe.neuron.integrated@active.ident), col=p3.moe.neuron.colors.cell_type,pch=16,bty='n') invisible(dev.off())

i keep getting this error message:

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'plot': unable to find an inherited method for function 'reducedDim' for signature '"PseudotimeOrdering", "missing"'

can anyone help me out.

kstreet13 commented 1 month ago

I don't know why reducedDim(p3.neuron.sds) isn't working, but as a simple workaround, reducedDim(as.SlingshotDataSet(p3.neuron.sds)) seems to work for me.

In the future, please don't post the same issue in three different places.

HappinessEricst commented 1 month ago

So sorry about that. Let me try it out. Thanks.

HappinessEricst commented 1 month ago

i did it and it didn't work as expected as it gave this image p3 slingshot centroids cell_type

do you please have any idea to how to reduce the dimensions

kstreet13 commented 1 month ago

It's already only 2 dimensions. Did you change the code from what it was above? Because that code should plot the data as points, but now you're plotting it as a line, which is why it looks like this.

HappinessEricst commented 1 month ago

no i didn't but let me redo it. Thanks

HappinessEricst commented 1 month ago

Thank you it worked.