dpeerlab/Palantir

IndexError in run_diffusion_maps

shneyour opened this issue · 2 comments

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

Solved it by playing with n_top_genes

gqhhh commented

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