dpeerlab / Palantir

Single cell trajectory detection
https://palantir.readthedocs.io
GNU General Public License v2.0
213 stars 50 forks source link

Issue with tsne #100

Closed st4302 closed 1 year ago

st4302 commented 1 year ago

Hello,

I am trying to use palantir using scanpy and then the plotting commands from your notebook.

I tried to run sc.tl.tsne(adata, n_pcs=2, use_rep='X_palantir_multiscale', perplexity=150)but I am getting the following error: ValueError: X_palantir_multiscale does not have enough Dimensions. Provide a Representation with equal or more dimensions thann_pcsor lowern_pcs

I had run palantir previously that way with other samples but I have not encountered this before. Is it a problem with my data?

I run palantir like shown here:

start_cell = 'AAACCCAAGACATGCG-1-1'
pr_res = sce.tl.palantir_results(
    adata,
    early_cell=start_cell,
    ms_data='X_palantir_multiscale',
    num_waypoints=500,
)

And I plotted it also like shown below with umap:

# Check where start cell is in umap
cell = ['AAACCCAAGACATGCG-1-1']

umap = pd.DataFrame(adata.obsm['X_umap'][:,0:2], index=adata.obs_names, columns=['x', 'y'])
plt.scatter(umap["x"], umap["y"], s=5, color="lightgrey")
plt.scatter(umap.loc[cell, "x"], umap.loc[cell, "y"], s=30)

#Plot results
palantir.plot.plot_palantir_results(pr_res, umap)

Plotting with UMAP is not giving me any issues.

Thank you

ManuSetty commented 1 year ago

Hello - We recommend the use of umaps or force directed layouts over tSNE computed on diffusion components. Is there a reason, why you would need to compute tSNE. The n_pcs parameter should be bumped up for tsne to work.