dpeerlab / Palantir

Single cell trajectory detection

Home Page:https://palantir.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in palantir.plot.plot_diffusion_components(umap, dm_res)

st4302 opened this issue · comments

Hello,

I am following your tutorial but I keep getting an error at this step:
palantir.plot.plot_diffusion_components(umap, dm_res)

The error is:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
[<ipython-input-315-7cbcba274001>](https://localhost:8080/#) in <module>
----> 1 palantir.plot.plot_diffusion_components(umap, dm_res)

2 frames
[/usr/local/lib/python3.8/dist-packages/pandas/core/indexes/range.py](https://localhost:8080/#) in get_loc(self, key, method, tolerance)
    386                 except ValueError as err:
    387                     raise KeyError(key) from err
--> 388             raise KeyError(key)
    389         return super().get_loc(key, method=method, tolerance=tolerance)
    390 

KeyError: 'x'

How can I fix this?

The UMAP looks like this:


                                                            0	      1
AAACCCAAGATAGCTA-1-0	7.693128	10.518767
AAACCCATCCATAAGC-1-0	8.449496	12.627493
AAACGAATCGATGCAT-1-0	8.182425	11.091985
AAACGCTTCGCCAACG-1-0	7.905481	10.491224
AAAGAACCATACCATG-1-0	10.100371	8.583208
...	...	...
TTTCAGTTCCTAACAG-1-3	10.279884	4.997492
TTTCGATAGACGACGT-1-3	8.339639	6.235906
TTTGATCAGACCAGAC-1-3	10.603064	6.300741
TTTGATCCACTCTCGT-1-3	9.351139	5.385613
TTTGGTTGTACCGGCT-1-3	8.074388	5.161654
3489 rows × 2 columns

The dm_res like this:

{'T': <3489x3489 sparse matrix of type '<class 'numpy.float64'>'
 	with 165452 stored elements in Compressed Sparse Row format>,
 'EigenVectors':                             0         1         2         3         4
 AAACCCAAGATAGCTA-1-0 -0.01693 -0.001429  0.005914 -0.010811 -0.004006
 AAACCCATCCATAAGC-1-0 -0.01693 -0.001356  0.006489 -0.013253 -0.008432
 AAACGAATCGATGCAT-1-0 -0.01693 -0.001479  0.005864 -0.011387 -0.003724
 AAACGCTTCGCCAACG-1-0 -0.01693 -0.001493  0.005729 -0.009450 -0.006522
 AAAGAACCATACCATG-1-0 -0.01693 -0.002563  0.002697  0.001889  0.007615
 ...                       ...       ...       ...       ...       ...
 TTTCAGTTCCTAACAG-1-3 -0.01693 -0.003093 -0.003663  0.019242  0.012358
 TTTCGATAGACGACGT-1-3 -0.01693  0.023604 -0.004408  0.011898  0.002167
 TTTGATCAGACCAGAC-1-3 -0.01693 -0.002492 -0.000834  0.011405  0.006017
 TTTGATCCACTCTCGT-1-3 -0.01693 -0.002674 -0.002274  0.018819  0.005962
 TTTGGTTGTACCGGCT-1-3 -0.01693 -0.002431 -0.001375  0.015350 -0.000283
 
 [3489 rows x 5 columns],
 'EigenValues': 0    1.000000
 1    0.969623
 2    0.966975
 3    0.949074
 4    0.944321
 dtype: float64,
 'kernel': <3489x3489 sparse matrix of type '<class 'numpy.float64'>'
 	with 165452 stored elements in Compressed Sparse Row format>}

commented

I have this error as well. How did you fix it?

I fixed it by this code-
umap.rename(columns={0:"x",1:"y"},inplace=True)