dpeerlab / Palantir

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

IndexError in run_diffusion_maps #108

Closed shneyour closed 1 year ago

shneyour commented 1 year ago

Hi, thanks for this amazing tool!

I am using a code that worked for me on another dataset but now raises an error:

Traceback (most recent call last):
  File "palantir_fat.py", line 39, in <module>
    dm_res = palantir.utils.run_diffusion_maps(adata, n_components=5)
  File "miniconda3/envs/cpdb/lib/python3.9/site-packages/palantir/utils.py", line 366, in run_diffusion_maps
    adaptive_std[i] = np.sort(kNN.data[kNN.indptr[i] : kNN.indptr[i + 1]])[
IndexError: index 9 is out of bounds for axis 0 with size 6

Here is my code (I used the same imports as shown in the example notebook):

sc.pp.normalize_per_cell(adata)
palantir.preprocess.log_transform(adata)
sc.pp.highly_variable_genes(adata, n_top_genes=1500, flavor="cell_ranger")
sc.pp.pca(adata)
dm_res = palantir.utils.run_diffusion_maps(adata, n_components=5)

Any ideas what the problem might be? Thanks

shneyour commented 1 year ago

Solved it by playing with n_top_genes

gqhhh commented 11 months ago

Hi I got the same issue. Could you please explain how to play with n_top_genes in a more detail way? Thanks!